diff --git a/CMakeLists.txt b/CMakeLists.txt index d343b58..b7c8e83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include (config/project_config_embeddable.cmake) project (simlfs) set_project_names (simlfs SimLFS) set_project_brief ("C++ Simulated Low Fare Search (LFS) Library") -set_project_versions (1 00 2) +set_project_versions (1 00 3) ## # Project options diff --git a/ChangeLog b/ChangeLog index 35c6ffe..a91ee5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* Sat Jun 26 2021 Denis Arnaud - 1.00.3 +- Upgraded CMake support files + * Sat May 30 2020 Denis Arnaud - 1.00.2 - Removed dependency on Python diff --git a/NEWS b/NEWS index 13651f8..8134831 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +2021-06-26: +- Version 1.00.3 +- Upgraded CMake support files + 2020-05-30: - Version 1.00.2 - Removed dependency on Python diff --git a/README.md b/README.md index 6baa767..3efc2b2 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,13 @@ but names may vary according to distributions): ## Building the library and test binary from the tarball The latest stable source tarball (`simlfs*.tar.gz` or `.bz2`) can be found here: -https://github.com/airsim/simlfs/archive/simlfs-1.00.2.tar.gz +https://github.com/airsim/simlfs/archive/simlfs-1.00.3.tar.gz To customise the following to your environment, you can alter the path to the installation directory: ```bash export INSTALL_BASEDIR="${HOME}/dev/deliveries" -export LFS_VER="1.00.2" +export LFS_VER="1.00.3" if [ -d /usr/lib64 ]; then LIBSUFFIX="64"; fi export LIBSUFFIX_4_CMAKE="-DLIB_SUFFIX=$LIBSUFFIX" `` diff --git a/autogen.sh b/autogen.sh index 0c5ed66..ba87b4b 100755 --- a/autogen.sh +++ b/autogen.sh @@ -51,7 +51,7 @@ fi # VERSION_MAJOR=1 VERSION_MINOR=00 -VERSION_PATCH=2 +VERSION_PATCH=3 VERSION_TMP_STRING=`grep "set_project_versions" CMakeLists.txt | sed -e "s/set_project_versions.*\([0-9]\+.\+[0-9]\+.\+[0-9]\+\).\+/\1/"` VERSION_STRING=`echo "${VERSION_TMP_STRING}" | grep "^[0-9]\+.[0-9]\+.[0-9]\+$"` diff --git a/config/FindBoost.cmake b/config/FindBoost.cmake index 80d11bd..f7605c4 100644 --- a/config/FindBoost.cmake +++ b/config/FindBoost.cmake @@ -7,7 +7,9 @@ FindBoost Find Boost include dirs and libraries -Use this module by invoking find_package with the form:: +Use this module by invoking :command:`find_package` with the form: + +.. code-block:: cmake find_package(Boost [version] [EXACT] # Minimum or EXACT version e.g. 1.67.0 @@ -20,97 +22,134 @@ Use this module by invoking find_package with the form:: This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Boost CMake" build. For the -latter case skip to the "Boost CMake" section below. For the former -case results are reported in variables:: - - Boost_FOUND - True if headers and requested libraries were found - Boost_INCLUDE_DIRS - Boost include directories - Boost_LIBRARY_DIRS - Link directories for Boost libraries - Boost_LIBRARIES - Boost component libraries to be linked - Boost__FOUND - True if component was found ( is upper-case) - Boost__LIBRARY - Libraries to link for component (may include - target_link_libraries debug/optimized keywords) - Boost_VERSION_MACRO - BOOST_VERSION value from boost/version.hpp - Boost_VERSION_STRING - Boost version number in x.y.z format - Boost_VERSION - if CMP0093 NEW => same as Boost_VERSION_STRING - if CMP0093 OLD or unset => same as Boost_VERSION_MACRO - Boost_LIB_VERSION - Version string appended to library filenames - Boost_VERSION_MAJOR - Boost major version number (X in X.y.z) - alias: Boost_MAJOR_VERSION - Boost_VERSION_MINOR - Boost minor version number (Y in x.Y.z) - alias: Boost_MINOR_VERSION - Boost_VERSION_PATCH - Boost subminor version number (Z in x.y.Z) - alias: Boost_SUBMINOR_VERSION - Boost_VERSION_COUNT - Amount of version components (3) - Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows) - - Pass to add_definitions() to have diagnostic - information about Boost's automatic linking - displayed during compilation - -Note that Boost Python components require a Python version suffix -(Boost 1.67 and later), e.g. ``python36`` or ``python27`` for the -versions built against Python 3.6 and 2.7, respectively. This also -applies to additional components using Python including -``mpi_python`` and ``numpy``. Earlier Boost releases may use -distribution-specific suffixes such as ``2``, ``3`` or ``2.7``. -These may also be used as suffixes, but note that they are not -portable. - -This module reads hints about search locations from variables:: - - BOOST_ROOT - Preferred installation prefix - (or BOOSTROOT) - BOOST_INCLUDEDIR - Preferred include directory e.g. /include - BOOST_LIBRARYDIR - Preferred library directory e.g. /lib - Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not - specified by these hint variables. Default is OFF. - Boost_ADDITIONAL_VERSIONS - - List of Boost versions not known to this module - (Boost install locations may contain the version) - -and saves search results persistently in CMake cache entries:: - - Boost_INCLUDE_DIR - Directory containing Boost headers - Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries - Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries - Boost__LIBRARY_DEBUG - Component library debug variant - Boost__LIBRARY_RELEASE - Component library release variant - -The following :prop_tgt:`IMPORTED` targets are also defined:: - - Boost::headers - Target for header-only dependencies - (Boost include directory) - alias: Boost::boost - Boost:: - Target for specific component dependency - (shared or static library); is lower- - case - Boost::diagnostic_definitions - interface target to enable diagnostic - information about Boost's automatic linking - during compilation (adds BOOST_LIB_DIAGNOSTIC) - Boost::disable_autolinking - interface target to disable automatic - linking with MSVC (adds BOOST_ALL_NO_LIB) - Boost::dynamic_linking - interface target to enable dynamic linking - linking with MSVC (adds BOOST_ALL_DYN_LINK) +latter case skip to the :ref:`Boost CMake` section below. -Implicit dependencies such as ``Boost::filesystem`` requiring -``Boost::system`` will be automatically detected and satisfied, even -if system is not specified when using :command:`find_package` and if -``Boost::system`` is not added to :command:`target_link_libraries`. If using -``Boost::thread``, then ``Threads::Threads`` will also be added automatically. +.. versionadded:: 3.7 + ``bzip2`` and ``zlib`` components (Windows only). -It is important to note that the imported targets behave differently -than variables created by this module: multiple calls to -:command:`find_package(Boost)` in the same directory or sub-directories with -different options (e.g. static or shared) will not override the -values of the targets created by the first call. +.. versionadded:: 3.11 + The ``OPTIONAL_COMPONENTS`` option. + +.. versionadded:: 3.13 + ``stacktrace_*`` components. + +.. versionadded:: 3.19 + ``bzip2`` and ``zlib`` components on all platforms. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``Boost_FOUND`` + True if headers and requested libraries were found. + +``Boost_INCLUDE_DIRS`` + Boost include directories. + +``Boost_LIBRARY_DIRS`` + Link directories for Boost libraries. + +``Boost_LIBRARIES`` + Boost component libraries to be linked. + +``Boost__FOUND`` + True if component ```` was found (```` name is upper-case). + +``Boost__LIBRARY`` + Libraries to link for component ```` (may include + :command:`target_link_libraries` debug/optimized keywords). + +``Boost_VERSION_MACRO`` + ``BOOST_VERSION`` value from ``boost/version.hpp``. + +``Boost_VERSION_STRING`` + Boost version number in ``X.Y.Z`` format. + +``Boost_VERSION`` + Boost version number in ``X.Y.Z`` format (same as ``Boost_VERSION_STRING``). + + .. versionchanged:: 3.15 + In previous CMake versions, this variable used the raw version string + from the Boost header (same as ``Boost_VERSION_MACRO``). + See policy :policy:`CMP0093`. + +``Boost_LIB_VERSION`` + Version string appended to library filenames. + +``Boost_VERSION_MAJOR``, ``Boost_MAJOR_VERSION`` + Boost major version number (``X`` in ``X.Y.Z``). + +``Boost_VERSION_MINOR``, ``Boost_MINOR_VERSION`` + Boost minor version number (``Y`` in ``X.Y.Z``). + +``Boost_VERSION_PATCH``, ``Boost_SUBMINOR_VERSION`` + Boost subminor version number (``Z`` in ``X.Y.Z``). + +``Boost_VERSION_COUNT`` + Amount of version components (3). + +``Boost_LIB_DIAGNOSTIC_DEFINITIONS`` (Windows-specific) + Pass to :command:`add_definitions` to have diagnostic + information about Boost's automatic linking + displayed during compilation + +.. versionadded:: 3.15 + The ``Boost_VERSION_`` variables. + +Cache variables +^^^^^^^^^^^^^^^ + +Search results are saved persistently in CMake cache entries: + +``Boost_INCLUDE_DIR`` + Directory containing Boost headers. + +``Boost_LIBRARY_DIR_RELEASE`` + Directory containing release Boost libraries. + +``Boost_LIBRARY_DIR_DEBUG`` + Directory containing debug Boost libraries. + +``Boost__LIBRARY_DEBUG`` + Component ```` library debug variant. + +``Boost__LIBRARY_RELEASE`` + Component ```` library release variant. + +.. versionadded:: 3.3 + Per-configuration variables ``Boost_LIBRARY_DIR_RELEASE`` and + ``Boost_LIBRARY_DIR_DEBUG``. + +Hints +^^^^^ + +This module reads hints about search locations from variables: + +``BOOST_ROOT``, ``BOOSTROOT`` + Preferred installation prefix. + +``BOOST_INCLUDEDIR`` + Preferred include directory e.g. ``/include``. + +``BOOST_LIBRARYDIR`` + Preferred library directory e.g. ``/lib``. + +``Boost_NO_SYSTEM_PATHS`` + Set to ``ON`` to disable searching in locations not + specified by these hint variables. Default is ``OFF``. + +``Boost_ADDITIONAL_VERSIONS`` + List of Boost versions not known to this module. + (Boost install locations may contain the version). Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but instead use the above result variables. Note that some hint names start in upper-case -"BOOST". One may specify these as environment variables if they are +``BOOST``. One may specify these as environment variables if they are not specified as CMake variables or cache entries. -This module first searches for the ``Boost`` header files using the above +This module first searches for the Boost header files using the above hint variables (excluding ``BOOST_LIBRARYDIR``) and saves the result in ``Boost_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints (excluding ``BOOST_INCLUDEDIR`` and @@ -118,79 +157,170 @@ using the above hints (excluding ``BOOST_INCLUDEDIR`` and and the library name configuration settings below. It saves the library directories in ``Boost_LIBRARY_DIR_DEBUG`` and ``Boost_LIBRARY_DIR_RELEASE`` and individual library -locations in ``Boost__LIBRARY_DEBUG`` and ``Boost__LIBRARY_RELEASE``. +locations in ``Boost__LIBRARY_DEBUG`` and ``Boost__LIBRARY_RELEASE``. When one changes settings used by previous searches in the same build tree (excluding environment variables) this module discards previous search results affected by the changes and searches again. +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.5 + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``Boost::boost`` + Target for header-only dependencies. (Boost include directory). + +``Boost::headers`` + .. versionadded:: 3.15 + Alias for ``Boost::boost``. + +``Boost::`` + Target for specific component dependency (shared or static library); + ```` name is lower-case. + +``Boost::diagnostic_definitions`` + Interface target to enable diagnostic information about Boost's automatic + linking during compilation (adds ``-DBOOST_LIB_DIAGNOSTIC``). + +``Boost::disable_autolinking`` + Interface target to disable automatic linking with MSVC + (adds ``-DBOOST_ALL_NO_LIB``). + +``Boost::dynamic_linking`` + Interface target to enable dynamic linking with MSVC + (adds ``-DBOOST_ALL_DYN_LINK``). + +Implicit dependencies such as ``Boost::filesystem`` requiring +``Boost::system`` will be automatically detected and satisfied, even +if system is not specified when using :command:`find_package` and if +``Boost::system`` is not added to :command:`target_link_libraries`. If using +``Boost::thread``, then ``Threads::Threads`` will also be added automatically. + +It is important to note that the imported targets behave differently +than variables created by this module: multiple calls to +:command:`find_package(Boost)` in the same directory or sub-directories with +different options (e.g. static or shared) will not override the +values of the targets created by the first call. + +Other Variables +^^^^^^^^^^^^^^^ + Boost libraries come in many variants encoded in their file name. Users or projects may tell this module which variant to find by -setting variables:: - - Boost_USE_DEBUG_LIBS - Set to ON or OFF to specify whether to search - and use the debug libraries. Default is ON. - Boost_USE_RELEASE_LIBS - Set to ON or OFF to specify whether to search - and use the release libraries. Default is ON. - Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded - libraries ('mt' tag). Default is ON. - Boost_USE_STATIC_LIBS - Set to ON to force the use of the static - libraries. Default is OFF. - Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use - libraries linked statically to the C++ runtime - ('s' tag). Default is platform dependent. - Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use - libraries linked to the MS debug C++ runtime - ('g' tag). Default is ON. - Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a - debug Python build ('y' tag). Default is OFF. - Boost_USE_STLPORT - Set to ON to use libraries compiled with - STLPort ('p' tag). Default is OFF. - Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS - - Set to ON to use libraries compiled with - STLPort deprecated "native iostreams" - ('n' tag). Default is OFF. - Boost_COMPILER - Set to the compiler-specific library suffix - (e.g. "-gcc43"). Default is auto-computed - for the C++ compiler in use. A list may be - used if multiple compatible suffixes should - be tested for, in decreasing order of - preference. - Boost_ARCHITECTURE - Set to the architecture-specific library suffix - (e.g. "-x64"). Default is auto-computed for the - C++ compiler in use. - Boost_THREADAPI - Suffix for "thread" component library name, - such as "pthread" or "win32". Names with - and without this suffix will both be tried. - Boost_NAMESPACE - Alternate namespace used to build boost with - e.g. if set to "myboost", will search for - myboost_thread instead of boost_thread. - -Other variables one may set to control this module are:: - - Boost_DEBUG - Set to ON to enable debug output from FindBoost. - Please enable this before filing any bug report. - Boost_REALPATH - Set to ON to resolve symlinks for discovered - libraries to assist with packaging. For example, - the "system" component library may be resolved to - "/usr/lib/libboost_system.so.1.67.0" instead of - "/usr/lib/libboost_system.so". This does not - affect linking and should not be enabled unless - the user needs this information. - Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and - Boost_LIBRARY_DIR_DEBUG. +setting variables: + +``Boost_USE_DEBUG_LIBS`` + .. versionadded:: 3.10 + + Set to ``ON`` or ``OFF`` to specify whether to search and use the debug + libraries. Default is ``ON``. + +``Boost_USE_RELEASE_LIBS`` + .. versionadded:: 3.10 + + Set to ``ON`` or ``OFF`` to specify whether to search and use the release + libraries. Default is ``ON``. + +``Boost_USE_MULTITHREADED`` + Set to OFF to use the non-multithreaded libraries ("mt" tag). Default is + ``ON``. + +``Boost_USE_STATIC_LIBS`` + Set to ON to force the use of the static libraries. Default is ``OFF``. + +``Boost_USE_STATIC_RUNTIME`` + Set to ``ON`` or ``OFF`` to specify whether to use libraries linked + statically to the C++ runtime ("s" tag). Default is platform dependent. + +``Boost_USE_DEBUG_RUNTIME`` + Set to ``ON`` or ``OFF`` to specify whether to use libraries linked to the + MS debug C++ runtime ("g" tag). Default is ``ON``. + +``Boost_USE_DEBUG_PYTHON`` + Set to ``ON`` to use libraries compiled with a debug Python build ("y" + tag). Default is ``OFF``. + +``Boost_USE_STLPORT`` + Set to ``ON`` to use libraries compiled with STLPort ("p" tag). Default is + ``OFF``. + +``Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS`` + Set to ON to use libraries compiled with STLPort deprecated "native + iostreams" ("n" tag). Default is ``OFF``. + +``Boost_COMPILER`` + Set to the compiler-specific library suffix (e.g. ``-gcc43``). Default is + auto-computed for the C++ compiler in use. + + .. versionchanged:: 3.9 + A list may be used if multiple compatible suffixes should be tested for, + in decreasing order of preference. + +``Boost_LIB_PREFIX`` + .. versionadded:: 3.18 + + Set to the platform-specific library name prefix (e.g. ``lib``) used by + Boost static libs. This is needed only on platforms where CMake does not + know the prefix by default. + +``Boost_ARCHITECTURE`` + .. versionadded:: 3.13 + + Set to the architecture-specific library suffix (e.g. ``-x64``). + Default is auto-computed for the C++ compiler in use. + +``Boost_THREADAPI`` + Suffix for ``thread`` component library name, such as ``pthread`` or + ``win32``. Names with and without this suffix will both be tried. + +``Boost_NAMESPACE`` + Alternate namespace used to build boost with e.g. if set to ``myboost``, + will search for ``myboost_thread`` instead of ``boost_thread``. + +Other variables one may set to control this module are: + +``Boost_DEBUG`` + Set to ``ON`` to enable debug output from ``FindBoost``. + Please enable this before filing any bug report. + +``Boost_REALPATH`` + Set to ``ON`` to resolve symlinks for discovered libraries to assist with + packaging. For example, the "system" component library may be resolved to + ``/usr/lib/libboost_system.so.1.67.0`` instead of + ``/usr/lib/libboost_system.so``. This does not affect linking and should + not be enabled unless the user needs this information. + +``Boost_LIBRARY_DIR`` + Default value for ``Boost_LIBRARY_DIR_RELEASE`` and + ``Boost_LIBRARY_DIR_DEBUG``. + +``Boost_NO_WARN_NEW_VERSIONS`` + .. versionadded:: 3.20 + + Set to ``ON`` to suppress the warning about unknown dependencies for new + Boost versions. On Visual Studio and Borland compilers Boost headers request automatic linking to corresponding libraries. This requires matching libraries to be linked explicitly or available in the link library search path. In this case setting ``Boost_USE_STATIC_LIBS`` to ``OFF`` may not achieve dynamic linking. Boost automatic linking typically requests static -libraries with a few exceptions (such as ``Boost.Python``). Use:: +libraries with a few exceptions (such as ``Boost.Python``). Use: + +.. code-block:: cmake add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) to ask Boost to report information about automatic linking requests. -Example to find Boost headers only:: +Examples +^^^^^^^^ + +Find Boost headers only: + +.. code-block:: cmake find_package(Boost 1.36.0) if(Boost_FOUND) @@ -198,7 +328,9 @@ Example to find Boost headers only:: add_executable(foo foo.cc) endif() -Example to find Boost libraries and use imported targets:: +Find Boost libraries and use imported targets: + +.. code-block:: cmake find_package(Boost 1.56 REQUIRED COMPONENTS date_time filesystem iostreams) @@ -206,17 +338,21 @@ Example to find Boost libraries and use imported targets:: target_link_libraries(foo Boost::date_time Boost::filesystem Boost::iostreams) -Example to find Boost Python 3.6 libraries and use imported targets:: +Find Boost Python 3.6 libraries and use imported targets: + +.. code-block:: cmake find_package(Boost 1.67 REQUIRED COMPONENTS python36 numpy36) add_executable(foo foo.cc) target_link_libraries(foo Boost::python36 Boost::numpy36) -Example to find Boost headers and some *static* (release only) libraries:: +Find Boost headers and some *static* (release only) libraries: + +.. code-block:: cmake set(Boost_USE_STATIC_LIBS ON) # only find static libs - set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and + set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and set(Boost_USE_RELEASE_LIBS ON) # only find release libs set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) @@ -227,6 +363,8 @@ Example to find Boost headers and some *static* (release only) libraries:: target_link_libraries(foo ${Boost_LIBRARIES}) endif() +.. _`Boost CMake`: + Boost CMake ^^^^^^^^^^^ @@ -234,7 +372,7 @@ If Boost was built using the boost-cmake project or from Boost 1.70.0 on it provides a package configuration file for use with find_package's config mode. This module looks for the package configuration file called ``BoostConfig.cmake`` or ``boost-config.cmake`` and stores the result in -``CACHE`` entry "Boost_DIR". If found, the package configuration file is loaded +``CACHE`` entry ``Boost_DIR``. If found, the package configuration file is loaded and this module returns with no further action. See documentation of the Boost CMake package configuration for details on what it provides. @@ -248,9 +386,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # Save project's policies cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST -if (POLICY CMP0102) - cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) -endif (POLICY CMP0102) +cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) function(_boost_get_existing_target component target_var) set(names "${component}") @@ -303,7 +439,7 @@ function(_boost_get_canonical_target_name component target_var) endfunction() macro(_boost_set_in_parent_scope name value) - # Set a variable in parent scope and make it visibile in current scope + # Set a variable in parent scope and make it visible in current scope set(${name} "${value}" PARENT_SCOPE) set(${name} "${value}") endmacro() @@ -440,10 +576,27 @@ if (NOT Boost_NO_BOOST_CMAKE) endif() endif() + set(_boost_FIND_PACKAGE_ARGS "") + if(Boost_NO_SYSTEM_PATHS) + list(APPEND _boost_FIND_PACKAGE_ARGS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) + endif() + # Do the same find_package call but look specifically for the CMake version. # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no # need to delegate them to this find_package call. - find_package(Boost QUIET NO_MODULE) + if(BOOST_ROOT AND NOT Boost_ROOT) + # Honor BOOST_ROOT by setting Boost_ROOT with CMP0074 NEW behavior. + cmake_policy(PUSH) + cmake_policy(SET CMP0074 NEW) + set(Boost_ROOT "${BOOST_ROOT}") + set(_Boost_ROOT_FOR_CONFIG 1) + endif() + find_package(Boost QUIET NO_MODULE ${_boost_FIND_PACKAGE_ARGS}) + if(_Boost_ROOT_FOR_CONFIG) + unset(_Boost_ROOT_FOR_CONFIG) + unset(Boost_ROOT) + cmake_policy(POP) + endif() if (DEFINED Boost_DIR) mark_as_advanced(Boost_DIR) endif () @@ -706,7 +859,8 @@ endfunction() # Guesses Boost's compiler prefix used in built library names # Returns the guess by setting the variable pointed to by _ret function(_Boost_GUESS_COMPILER_PREFIX _ret) - if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel") + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel" + OR "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "xIntelLLVM") if(WIN32) set (_boost_COMPILER "-iw") else() @@ -1167,11 +1321,26 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(Boost_VERSION_STRING VERSION_LESS 1.75.0) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) + set(_Boost_COROUTINE_DEPENDENCIES context) + set(_Boost_FIBER_DEPENDENCIES context) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) + set(_Boost_TIMER_DEPENDENCIES chrono) + set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_JSON_DEPENDENCIES container) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) @@ -1181,7 +1350,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.74.0) + if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.77.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -1236,6 +1405,7 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_LOCALE_HEADERS "boost/locale.hpp") set(_Boost_LOG_HEADERS "boost/log/core.hpp") set(_Boost_LOG_SETUP_HEADERS "boost/log/detail/setup_config.hpp") + set(_Boost_JSON_HEADERS "boost/json.hpp") set(_Boost_MATH_HEADERS "boost/math_fwd.hpp") set(_Boost_MATH_C99_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_C99F_HEADERS "boost/math/tr1.hpp") @@ -1268,10 +1438,8 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp") set(_Boost_WAVE_HEADERS "boost/wave.hpp") set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp") - if(WIN32) - set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") - set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") - endif() + set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") + set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") string(TOUPPER ${component} uppercomponent) set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE) @@ -1455,6 +1623,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65" "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" @@ -1646,11 +1815,9 @@ if(Boost_INCLUDE_DIR) set(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}") # Define final Boost_VERSION - if (POLICY CMP0093) - cmake_policy(GET CMP0093 _Boost_CMP0093 - PARENT_SCOPE # undocumented, do not use outside of CMake - ) - endif (POLICY CMP0093) + cmake_policy(GET CMP0093 _Boost_CMP0093 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) if("x${_Boost_CMP0093}x" STREQUAL "xNEWx") set(Boost_VERSION ${Boost_VERSION_STRING}) else() @@ -1671,10 +1838,17 @@ endif() # Prefix initialization # ------------------------------------------------------------------------ -set(Boost_LIB_PREFIX "") -if ( (GHSMULTI AND Boost_USE_STATIC_LIBS) OR - (WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) ) - set(Boost_LIB_PREFIX "lib") +if ( NOT DEFINED Boost_LIB_PREFIX ) + # Boost's static libraries use a "lib" prefix on DLL platforms + # to distinguish them from the DLL import libraries. + if (Boost_USE_STATIC_LIBS AND ( + (WIN32 AND NOT CYGWIN) + OR GHSMULTI + )) + set(Boost_LIB_PREFIX "lib") + else() + set(Boost_LIB_PREFIX "") + endif() endif() if ( NOT Boost_NAMESPACE ) @@ -1740,7 +1914,8 @@ endif() if(WIN32 AND Boost_USE_DEBUG_RUNTIME) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang" - OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel") + OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel" + OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntelLLVM") string(APPEND _boost_DEBUG_ABI_TAG "g") endif() endif() diff --git a/config/FindPackageHandleStandardArgs.cmake b/config/FindPackageHandleStandardArgs.cmake index a078049..fbcf7cd 100644 --- a/config/FindPackageHandleStandardArgs.cmake +++ b/config/FindPackageHandleStandardArgs.cmake @@ -5,16 +5,19 @@ FindPackageHandleStandardArgs ----------------------------- -This module provides a function intended to be used in :ref:`Find Modules` -implementing :command:`find_package()` calls. It handles the -``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. -It also sets the ``_FOUND`` variable. The package is -considered found if all variables listed contain valid results, e.g. -valid filepaths. +This module provides functions intended to be used in :ref:`Find Modules` +implementing :command:`find_package()` calls. .. command:: find_package_handle_standard_args - There are two signatures:: + This command handles the ``REQUIRED``, ``QUIET`` and version-related + arguments of :command:`find_package`. It also sets the + ``_FOUND`` variable. The package is considered found if all + variables listed contain valid results, e.g. valid filepaths. + + There are two signatures: + + .. code-block:: cmake find_package_handle_standard_args( (DEFAULT_MSG|) @@ -25,6 +28,7 @@ valid filepaths. [FOUND_VAR ] [REQUIRED_VARS ...] [VERSION_VAR ] + [HANDLE_VERSION_RANGE] [HANDLE_COMPONENTS] [CONFIG_MODE] [NAME_MISMATCHED] @@ -47,7 +51,9 @@ valid filepaths. (recommended). Not valid in the full signature. ``FOUND_VAR `` - Obsolete. Specifies either ``_FOUND`` or + .. deprecated:: 3.3 + + Specifies either ``_FOUND`` or ``_FOUND`` as the result variable. This exists only for compatibility with older versions of CMake and is now ignored. Result variables of both names are always set for compatibility. @@ -59,6 +65,9 @@ valid filepaths. typically be cache entries such as ``FOO_LIBRARY`` and not output variables like ``FOO_LIBRARIES``. + .. versionchanged:: 3.18 + If ``HANDLE_COMPONENTS`` is specified, this option can be omitted. + ``VERSION_VAR `` Specify the name of a variable that holds the version of the package that has been found. This version will be checked against the @@ -68,6 +77,13 @@ valid filepaths. version and the version which has been actually found, both if the version is ok or not. + ``HANDLE_VERSION_RANGE`` + .. versionadded:: 3.19 + + Enable handling of a version range, if one is specified. Without this + option, a developer warning will be displayed if a version range is + specified. + ``HANDLE_COMPONENTS`` Enable handling of package components. In this case, the command will report which components have been found and which are missing, @@ -84,6 +100,8 @@ valid filepaths. was found. ``REASON_FAILURE_MESSAGE `` + .. versionadded:: 3.16 + Specify a custom message of the reason for the failure which will be appended to the default generated message. @@ -92,6 +110,8 @@ valid filepaths. generated message. Not recommended. ``NAME_MISMATCHED`` + .. versionadded:: 3.17 + Indicate that the ```` does not match ``${CMAKE_FIND_PACKAGE_NAME}``. This is usually a mistake and raises a warning, but it may be intentional for usage of the command for components @@ -150,10 +170,56 @@ In this case, a ``FindAutmoc4.cmake`` module wraps a call to directory for ``automoc4``. Then the call to ``find_package_handle_standard_args`` produces a proper success/failure message. + +.. command:: find_package_check_version + + .. versionadded:: 3.19 + + Helper function which can be used to check if a ```` is valid + against version-related arguments of :command:`find_package`. + + .. code-block:: cmake + + find_package_check_version( + [HANDLE_VERSION_RANGE] + [RESULT_MESSAGE_VARIABLE ] + ) + + The ```` will hold a boolean value giving the result of the check. + + The options are: + + ``HANDLE_VERSION_RANGE`` + Enable handling of a version range, if one is specified. Without this + option, a developer warning will be displayed if a version range is + specified. + + ``RESULT_MESSAGE_VARIABLE `` + Specify a variable to get back a message describing the result of the check. + +Example for the usage: + +.. code-block:: cmake + + find_package_check_version(1.2.3 result HANDLE_VERSION_RANGE + RESULT_MESSAGE_VARIABLE reason) + if (result) + message (STATUS "${reason}") + else() + message (FATAL_ERROR "${reason}") + endif() #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) + +cmake_policy(PUSH) +# numbers and boolean constants +cmake_policy (SET CMP0012 NEW) +# IN_LIST operator +cmake_policy (SET CMP0057 NEW) + + # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) set (__msg "${_msg}") @@ -206,10 +272,110 @@ macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) endmacro() +function(FIND_PACKAGE_CHECK_VERSION version result) + cmake_parse_arguments (PARSE_ARGV 2 FPCV "HANDLE_VERSION_RANGE;NO_AUTHOR_WARNING_VERSION_RANGE" "RESULT_MESSAGE_VARIABLE" "") + + if (FPCV_UNPARSED_ARGUMENTS) + message (FATAL_ERROR "find_package_check_version(): ${FPCV_UNPARSED_ARGUMENTS}: unexpected arguments") + endif() + if ("RESULT_MESSAGE_VARIABLE" IN_LIST FPCV_KEYWORDS_MISSING_VALUES) + message (FATAL_ERROR "find_package_check_version(): RESULT_MESSAGE_VARIABLE expects an argument") + endif() + + set (${result} FALSE PARENT_SCOPE) + if (FPCV_RESULT_MESSAGE_VARIABLE) + unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE) + endif() + + if (_CMAKE_FPHSA_PACKAGE_NAME) + set (package "${_CMAKE_FPHSA_PACKAGE_NAME}") + elseif (CMAKE_FIND_PACKAGE_NAME) + set (package "${CMAKE_FIND_PACKAGE_NAME}") + else() + message (FATAL_ERROR "find_package_check_version(): Cannot be used outside a 'Find Module'") + endif() + + if (NOT FPCV_NO_AUTHOR_WARNING_VERSION_RANGE + AND ${package}_FIND_VERSION_RANGE AND NOT FPCV_HANDLE_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the option " + "HANDLE_VERSION_RANGE` is not passed to `find_package_check_version()`. " + "Only the lower endpoint of the range will be used.") + endif() + + + set (version_ok FALSE) + unset (version_msg) + + if (FPCV_HANDLE_VERSION_RANGE AND ${package}_FIND_VERSION_RANGE) + if ((${package}_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" + AND version VERSION_GREATER_EQUAL ${package}_FIND_VERSION_MIN) + AND ((${package}_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" + AND version VERSION_LESS_EQUAL ${package}_FIND_VERSION_MAX) + OR (${package}_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" + AND version VERSION_LESS ${package}_FIND_VERSION_MAX))) + set (version_ok TRUE) + set(version_msg "(found suitable version \"${version}\", required range is \"${${package}_FIND_VERSION_RANGE}\")") + else() + set(version_msg "Found unsuitable version \"${version}\", required range is \"${${package}_FIND_VERSION_RANGE}\"") + endif() + elseif (DEFINED ${package}_FIND_VERSION) + if(${package}_FIND_VERSION_EXACT) # exact version required + # count the dots in the version string + string(REGEX REPLACE "[^.]" "" version_dots "${version}") + # add one dot because there is one dot more than there are components + string(LENGTH "${version_dots}." version_dots) + if (version_dots GREATER ${package}_FIND_VERSION_COUNT) + # Because of the C++ implementation of find_package() ${package}_FIND_VERSION_COUNT + # is at most 4 here. Therefore a simple lookup table is used. + if (${package}_FIND_VERSION_COUNT EQUAL 1) + set(version_regex "[^.]*") + elseif (${package}_FIND_VERSION_COUNT EQUAL 2) + set(version_regex "[^.]*\\.[^.]*") + elseif (${package}_FIND_VERSION_COUNT EQUAL 3) + set(version_regex "[^.]*\\.[^.]*\\.[^.]*") + else() + set(version_regex "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") + endif() + string(REGEX REPLACE "^(${version_regex})\\..*" "\\1" version_head "${version}") + if (NOT ${package}_FIND_VERSION VERSION_EQUAL version_head) + set(version_msg "Found unsuitable version \"${version}\", but required is exact version \"${${package}_FIND_VERSION}\"") + else () + set(version_ok TRUE) + set(version_msg "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + else () + if (NOT ${package}_FIND_VERSION VERSION_EQUAL version) + set(version_msg "Found unsuitable version \"${version}\", but required is exact version \"${${package}_FIND_VERSION}\"") + else () + set(version_ok TRUE) + set(version_msg "(found suitable exact version \"${version}\")") + endif () + endif () + else() # minimum version + if (${package}_FIND_VERSION VERSION_GREATER version) + set(version_msg "Found unsuitable version \"${version}\", but required is at least \"${${package}_FIND_VERSION}\"") + else() + set(version_ok TRUE) + set(version_msg "(found suitable version \"${version}\", minimum required is \"${${package}_FIND_VERSION}\")") + endif() + endif() + else () + set(version_ok TRUE) + set(version_msg "(found version \"${version}\")") + endif() + + set (${result} ${version_ok} PARENT_SCOPE) + if (FPCV_RESULT_MESSAGE_VARIABLE) + set (${FPCV_RESULT_MESSAGE_VARIABLE} "${version_msg}" PARENT_SCOPE) + endif() +endfunction() + + function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED) + set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED HANDLE_VERSION_RANGE) set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR) set(multiValueArgs REQUIRED_VARS) @@ -257,7 +423,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_VERSION_VAR ${_NAME}_VERSION) endif() - if(NOT FPHSA_REQUIRED_VARS) + if(NOT FPHSA_REQUIRED_VARS AND NOT FPHSA_HANDLE_COMPONENTS) message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") endif() endif() @@ -277,13 +443,25 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) "to follow a certain pattern.") endif () -# now that we collected all arguments, process them + if (${_NAME}_FIND_VERSION_RANGE AND NOT FPHSA_HANDLE_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the module ${_NAME} does " + "not support this capability. Only the lower endpoint of the range " + "will be used.") + endif() + + # to propagate package name to FIND_PACKAGE_CHECK_VERSION + set(_CMAKE_FPHSA_PACKAGE_NAME "${_NAME}") + + # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") endif() - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + if (FPHSA_REQUIRED_VARS) + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + endif() string(TOUPPER ${_NAME} _NAME_UPPER) string(TOLOWER ${_NAME} _NAME_LOWER) @@ -361,61 +539,22 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) if (DEFINED ${_NAME}_FIND_VERSION) if(DEFINED ${FPHSA_VERSION_VAR}) set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - # count the dots in the version string - string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") - # add one dot because there is one dot more than there are components - string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) - if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) - # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT - # is at most 4 here. Therefore a simple lookup table is used. - if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) - set(_VERSION_REGEX "[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) - set(_VERSION_REGEX "[^.]*\\.[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") - else () - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") - endif () - string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") - unset(_VERSION_REGEX) - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - unset(_VERSION_HEAD) - else () - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - endif () - unset(_VERSION_DOTS) - - else() # minimum version specified: - if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () + if (FPHSA_HANDLE_VERSION_RANGE) + set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + else() + set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) endif() - + find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG + ${FPCV_HANDLE_VERSION_RANGE}) else() - # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + elseif (FPHSA_HANDLE_VERSION_RANGE AND ${_NAME}_FIND_VERSION_RANGE) + set(VERSION_MSG "(Required is version range \"${${_NAME}_FIND_VERSION_RANGE}\")") else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") endif() - endif() else () # Check with DEFINED as the found version may be 0. @@ -440,7 +579,17 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) _FPHSA_HANDLE_FAILURE_CONFIG_MODE() else() if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + set(RESULT_MSG) + if (_FIRST_REQUIRED_VAR) + string (APPEND RESULT_MSG "found ${${_FIRST_REQUIRED_VAR}}") + endif() + if (COMPONENT_MSG) + if (RESULT_MSG) + string (APPEND RESULT_MSG ", ") + endif() + string (APPEND RESULT_MSG "${FOUND_COMPONENTS_MSG}") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (${RESULT_MSG})") else() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") endif() @@ -451,3 +600,6 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) endfunction() + + +cmake_policy(POP) diff --git a/config/FindPython.cmake b/config/FindPython.cmake index 9dfa222..a4b7a03 100644 --- a/config/FindPython.cmake +++ b/config/FindPython.cmake @@ -5,21 +5,45 @@ FindPython ---------- +.. versionadded:: 3.12 + Find Python interpreter, compiler and development environment (include directories and libraries). +.. versionadded:: 3.19 + When a version is requested, it can be specified as a simple value or as a + range. For a detailed description of version range usage and capabilities, + refer to the :command:`find_package` command. + The following components are supported: * ``Interpreter``: search for Python interpreter. * ``Compiler``: search for Python compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries). + + .. versionadded:: 3.18 + This component includes two sub-components which can be specified + independently: + + * ``Development.Module``: search for artifacts for Python module + developments. + * ``Development.Embed``: search for artifacts for Python embedding + developments. + * ``NumPy``: search for NumPy include directories. +.. versionadded:: 3.14 + Added the ``NumPy`` component. + If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed. +If component ``Development`` is specified, it implies sub-components +``Development.Module`` and ``Development.Embed``. + To ensure consistent versions between components ``Interpreter``, ``Compiler``, -``Development`` and ``NumPy``, specify all components at the same time:: +``Development`` (or one of its sub-components) and ``NumPy``, specify all +components at the same time:: find_package (Python COMPONENTS Interpreter Development) @@ -30,28 +54,39 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and .. note:: - If components ``Interpreter`` and ``Development`` are both specified, this - module search only for interpreter with same platform architecture as the one - defined by ``CMake`` configuration. This contraint does not apply if only - ``Interpreter`` component is specified. + If components ``Interpreter`` and ``Development`` (or one of its + sub-components) are both specified, this module search only for interpreter + with same platform architecture as the one defined by ``CMake`` + configuration. This constraint does not apply if only ``Interpreter`` + component is specified. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets ` -(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): +This module defines the following :ref:`Imported Targets `: + +.. versionchanged:: 3.14 + :ref:`Imported Targets ` are only created when + :prop_gbl:`CMAKE_ROLE` is ``PROJECT``. ``Python::Interpreter`` Python interpreter. Target defined if component ``Interpreter`` is found. ``Python::Compiler`` Python compiler. Target defined if component ``Compiler`` is found. + +``Python::Module`` + .. versionadded:: 3.15 + + Python library for Python module. Target defined if component + ``Development.Module`` is found. + ``Python::Python`` Python library for Python embedding. Target defined if component - ``Development`` is found. -``Python::Module`` - Python library for Python module. Target defined if component ``Development`` - is found. + ``Development.Embed`` is found. + ``Python::NumPy`` + .. versionadded:: 3.14 + NumPy Python library. Target defined if component ``NumPy`` is found. Result Variables @@ -73,33 +108,44 @@ This module will set the following variables in your project * Anaconda * Canopy * IronPython + * PyPy ``Python_STDLIB`` Standard platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)`` + or else ``sysconfig.get_path('stdlib')``. ``Python_STDARCH`` Standard platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)`` + or else ``sysconfig.get_path('platstdlib')``. ``Python_SITELIB`` Third-party platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)`` + or else ``sysconfig.get_path('purelib')``. ``Python_SITEARCH`` Third-party platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)`` + or else ``sysconfig.get_path('platlib')``. + ``Python_SOABI`` + .. versionadded:: 3.17 + Extension suffix for modules. Information returned by - ``distutils.sysconfig.get_config_flag('SOABI')`` or computed from - ``distutils.sysconfig.get_config_flag('EXT_SUFFIX')`` or - ``python-config --extension-suffix``. + ``distutils.sysconfig.get_config_var('SOABI')`` or computed from + ``distutils.sysconfig.get_config_var('EXT_SUFFIX')`` or + ``python-config --extension-suffix``. If package ``distutils.sysconfig`` is + not available, ``sysconfig.get_config_var('SOABI')`` or + ``sysconfig.get_config_var('EXT_SUFFIX')`` are used. + ``Python_Compiler_FOUND`` System has the Python compiler. ``Python_COMPILER`` @@ -107,10 +153,35 @@ This module will set the following variables in your project ``Python_COMPILER_ID`` A short string unique to the compiler. Possible values include: * IronPython + +``Python_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python_Development_FOUND`` System has the Python development artifacts. + +``Python_Development.Module_FOUND`` + .. versionadded:: 3.18 + + System has the Python development artifacts for Python module. + +``Python_Development.Embed_FOUND`` + .. versionadded:: 3.18 + + System has the Python development artifacts for Python embedding. + ``Python_INCLUDE_DIRS`` + The Python include directories. + +``Python_LINK_OPTIONS`` + .. versionadded:: 3.19 + + The Python link options. Some configurations require specific link options + for a correct build and execution. + ``Python_LIBRARIES`` The Python libraries. ``Python_LIBRARY_DIRS`` @@ -125,11 +196,25 @@ This module will set the following variables in your project Python minor version. ``Python_VERSION_PATCH`` Python patch version. + +``Python_PyPy_VERSION`` + .. versionadded:: 3.18 + + Python PyPy version. + ``Python_NumPy_FOUND`` + .. versionadded:: 3.14 + System has the NumPy. + ``Python_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + .. versionadded:: 3.14 + + The NumPy include directories. + ``Python_NumPy_VERSION`` + .. versionadded:: 3.14 + The NumPy version. Hints @@ -145,6 +230,8 @@ Hints * If set to FALSE, search **only** for shared libraries. ``Python_FIND_ABI`` + .. versionadded:: 3.16 + This variable defines which ABIs, as defined in `PEP 3149 `_, should be searched. @@ -162,7 +249,7 @@ Hints * ``ON``: Corresponding flag is selected. * ``OFF``: Corresponding flag is not selected. - * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched. + * ``ANY``: The two possibilities (``ON`` and ``OFF``) will be searched. From this 3-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, ``debug`` versions will be @@ -190,9 +277,10 @@ Hints each flag is ``OFF`` or ``ANY``. ``Python_FIND_STRATEGY`` + .. versionadded:: 3.15 + This variable defines how lookup will be done. - The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -203,10 +291,11 @@ Hints This is the default if policy :policy:`CMP0094` is set to ``NEW``. ``Python_FIND_REGISTRY`` + .. versionadded:: 3.13 + On Windows the ``Python_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - the ``Python_FIND_REGISTRY`` variable can be set to empty or one of the - following: + the ``Python_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -214,10 +303,12 @@ Hints * ``NEVER``: Never try to use registry. ``Python_FIND_FRAMEWORK`` + .. versionadded:: 3.15 + On macOS the ``Python_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -227,32 +318,90 @@ Hints variable will be used, if any. ``Python_FIND_VIRTUALENV`` + .. versionadded:: 3.15 + This variable defines the handling of virtual environments managed by ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. * ``ONLY``: Only the virtual environment is used to look-up for the interpreter. * ``STANDARD``: The virtual environment is not used to look-up for the - interpreter. In this case, variable ``Python_FIND_REGISTRY`` (Windows) - or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + interpreter but environment variable ``PATH`` is always considered. + In this case, variable ``Python_FIND_REGISTRY`` (Windows) or + ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or ``NEVER`` to select preferably the interpreter from the virtual environment. + .. versionadded:: 3.17 + Added support for ``conda`` environments. + .. note:: If the component ``Development`` is requested, it is **strongly** recommended to also include the component ``Interpreter`` to get expected result. +``Python_FIND_IMPLEMENTATIONS`` + .. versionadded:: 3.18 + + This variable defines, in an ordered list, the different implementations + which will be searched. The ``Python_FIND_IMPLEMENTATIONS`` variable can + hold the following values: + + * ``CPython``: this is the standard implementation. Various products, like + ``Anaconda`` or ``ActivePython``, rely on this implementation. + * ``IronPython``: This implementation use the ``CSharp`` language for + ``.NET Framework`` on top of the `Dynamic Language Runtime` (``DLR``). + See `IronPython `_. + * ``PyPy``: This implementation use ``RPython`` language and + ``RPython translation toolchain`` to produce the python interpreter. + See `PyPy `_. + + The default value is: + + * Windows platform: ``CPython``, ``IronPython`` + * Other platforms: ``CPython`` + + .. note:: + + This hint has the lowest priority of all hints, so even if, for example, + you specify ``IronPython`` first and ``CPython`` in second, a python + product based on ``CPython`` can be selected because, for example with + ``Python_FIND_STRATEGY=LOCATION``, each location will be search first for + ``IronPython`` and second for ``CPython``. + + .. note:: + + When ``IronPython`` is specified, on platforms other than ``Windows``, the + ``.Net`` interpreter (i.e. ``mono`` command) is expected to be available + through the ``PATH`` variable. + +``Python_FIND_UNVERSIONED_NAMES`` + .. versionadded:: 3.20 + + This variable defines how the generic names will be searched. Currently, it + only applies to the generic names of the interpreter, namely, ``python3`` or + ``python2`` and ``python``. + The ``Python_FIND_UNVERSIONED_NAMES`` variable can be set to one of the + following values: + + * ``FIRST``: The generic names are searched before the more specialized ones + (such as ``python2.5`` for example). + * ``LAST``: The generic names are searched after the more specialized ones. + This is the default. + * ``NEVER``: The generic name are not searched at all. + Artifacts Specification ^^^^^^^^^^^^^^^^^^^^^^^ +.. versionadded:: 3.16 + To solve special cases, it is possible to specify directly the artifacts by setting the following variables: @@ -262,9 +411,14 @@ setting the following variables: ``Python_COMPILER`` The path to the compiler. +``Python_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python_LIBRARIES``, ``Python_LIBRAY_DIRS`` and + variables ``Python_LIBRARIES``, ``Python_LIBRARY_DIRS`` and ``Python_RUNTIME_LIBRARY_DIRS``. ``Python_INCLUDE_DIR`` @@ -285,9 +439,27 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controlled with the following variable: + +``Python_ARTIFACTS_INTERACTIVE`` + .. versionadded:: 3.18 + + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ @@ -302,18 +474,45 @@ Python module naming rules:: If the library type is not specified, ``MODULE`` is assumed. -For ``MODULE`` library type, if option ``WITH_SOABI`` is specified, the -module suffix will include the ``Python_SOABI`` value, if any. +.. versionadded:: 3.17 + For ``MODULE`` library type, if option ``WITH_SOABI`` is specified, the + module suffix will include the ``Python_SOABI`` value, if any. #]=======================================================================] -set (_PYTHON_PREFIX Python) +cmake_policy(PUSH) +# numbers and boolean constants +cmake_policy (SET CMP0012 NEW) + -if (DEFINED Python_FIND_VERSION) +set (_PYTHON_PREFIX Python) +unset (_Python_REQUIRED_VERSION_MAJOR) +unset (_Python_REQUIRED_VERSIONS) + +if (Python_FIND_VERSION_RANGE) + # compute list of major versions + foreach (_Python_MAJOR IN ITEMS 3 2) + if (_Python_MAJOR VERSION_GREATER_EQUAL Python_FIND_VERSION_MIN_MAJOR + AND ((Python_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND _Python_MAJOR VERSION_LESS_EQUAL Python_FIND_VERSION_MAX) + OR (Python_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND _Python_MAJOR VERSION_LESS Python_FIND_VERSION_MAX))) + list (APPEND _Python_REQUIRED_VERSIONS ${_Python_MAJOR}) + endif() + endforeach() + list (LENGTH _Python_REQUIRED_VERSIONS _Python_VERSION_COUNT) + if (_Python_VERSION_COUNT EQUAL 0) + unset (_Python_REQUIRED_VERSIONS) + elseif (_Python_VERSION_COUNT EQUAL 1) + set (_Python_REQUIRED_VERSION_MAJOR ${_Python_REQUIRED_VERSIONS}) + endif() +elseif (DEFINED Python_FIND_VERSION) set (_Python_REQUIRED_VERSION_MAJOR ${Python_FIND_VERSION_MAJOR}) +else() + set (_Python_REQUIRED_VERSIONS 3 2) +endif() +if (_Python_REQUIRED_VERSION_MAJOR) include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake) -else() +elseif (_Python_REQUIRED_VERSIONS) # iterate over versions in quiet and NOT required modes to avoid multiple # "Found" messages and prematurally failure. set (_Python_QUIETLY ${Python_FIND_QUIETLY}) @@ -321,7 +520,6 @@ else() set (Python_FIND_QUIETLY TRUE) set (Python_FIND_REQUIRED FALSE) - set (_Python_REQUIRED_VERSIONS 3 2) set (_Python_REQUIRED_VERSION_LAST 2) unset (_Python_INPUT_VARS) @@ -355,10 +553,21 @@ else() set (Python_FIND_REQUIRED ${_Python_REQUIRED}) if (Python_FIND_REQUIRED OR NOT Python_FIND_QUIETLY) # call again validation command to get "Found" or error message - find_package_handle_standard_args (Python HANDLE_COMPONENTS + find_package_handle_standard_args (Python HANDLE_COMPONENTS HANDLE_VERSION_RANGE REQUIRED_VARS ${_Python_REQUIRED_VARS} VERSION_VAR Python_VERSION) endif() +else() + # supported versions not in the specified range. Call final check + if (NOT Python_FIND_COMPONENTS) + set (Python_FIND_COMPONENTS Interpreter) + set (Python_FIND_REQUIRED_Interpreter TRUE) + endif() + + include (${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + find_package_handle_standard_args (Python HANDLE_COMPONENTS HANDLE_VERSION_RANGE + VERSION_VAR Python_VERSION + REASON_FAILURE_MESSAGE "Version range specified \"${Python_FIND_VERSION_RANGE}\" does not include supported versions") endif() if (COMMAND __Python_add_library) @@ -368,3 +577,5 @@ if (COMMAND __Python_add_library) endif() unset (_PYTHON_PREFIX) + +cmake_policy(POP) diff --git a/config/FindPython2.cmake b/config/FindPython2.cmake index af8ad39..bb965b9 100644 --- a/config/FindPython2.cmake +++ b/config/FindPython2.cmake @@ -5,21 +5,45 @@ FindPython2 ----------- +.. versionadded:: 3.12 + Find Python 2 interpreter, compiler and development environment (include directories and libraries). +.. versionadded:: 3.19 + When a version is requested, it can be specified as a simple value or as a + range. For a detailed description of version range usage and capabilities, + refer to the :command:`find_package` command. + The following components are supported: * ``Interpreter``: search for Python 2 interpreter * ``Compiler``: search for Python 2 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and - libraries) + libraries). + + .. versionadded:: 3.18 + This component includes two sub-components which can be specified + independently: + + * ``Development.Module``: search for artifacts for Python 2 module + developments. + * ``Development.Embed``: search for artifacts for Python 2 embedding + developments. + * ``NumPy``: search for NumPy include directories. +.. versionadded:: 3.14 + Added the ``NumPy`` component. + If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed. +If component ``Development`` is specified, it implies sub-components +``Development.Module`` and ``Development.Embed``. + To ensure consistent versions between components ``Interpreter``, ``Compiler``, -``Development`` and ``NumPy``, specify all components at the same time:: +``Development`` (or one of its sub-components) and ``NumPy``, specify all +components at the same time:: find_package (Python2 COMPONENTS Interpreter Development) @@ -31,28 +55,38 @@ for you. .. note:: - If components ``Interpreter`` and ``Development`` are both specified, this - module search only for interpreter with same platform architecture as the one - defined by ``CMake`` configuration. This contraint does not apply if only - ``Interpreter`` component is specified. + If components ``Interpreter`` and ``Development`` (or one of its + sub-components) are both specified, this module search only for interpreter + with same platform architecture as the one defined by ``CMake`` + configuration. This constraint does not apply if only ``Interpreter`` + component is specified. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets ` -(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): +This module defines the following :ref:`Imported Targets `: + +.. versionchanged:: 3.14 + :ref:`Imported Targets ` are only created when + :prop_gbl:`CMAKE_ROLE` is ``PROJECT``. ``Python2::Interpreter`` Python 2 interpreter. Target defined if component ``Interpreter`` is found. ``Python2::Compiler`` Python 2 compiler. Target defined if component ``Compiler`` is found. -``Python2::Python`` - Python 2 library for Python embedding. Target defined if component - ``Development`` is found. ``Python2::Module`` + .. versionadded:: 3.15 + Python 2 library for Python module. Target defined if component - ``Development`` is found. + ``Development.Module`` is found. + +``Python2::Python`` + Python 2 library for Python embedding. Target defined if component + ``Development.Embed`` is found. + ``Python2::NumPy`` + .. versionadded:: 3.14 + NumPy library for Python 2. Target defined if component ``NumPy`` is found. Result Variables @@ -74,26 +108,31 @@ This module will set the following variables in your project * Anaconda * Canopy * IronPython + * PyPy ``Python2_STDLIB`` Standard platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)`` + or else ``sysconfig.get_path('stdlib')``. ``Python2_STDARCH`` Standard platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)`` + or else ``sysconfig.get_path('platstdlib')``. ``Python2_SITELIB`` Third-party platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)`` + or else ``sysconfig.get_path('purelib')``. ``Python2_SITEARCH`` Third-party platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)`` + or else ``sysconfig.get_path('platlib')``. ``Python2_Compiler_FOUND`` System has the Python 2 compiler. ``Python2_COMPILER`` @@ -101,10 +140,34 @@ This module will set the following variables in your project ``Python2_COMPILER_ID`` A short string unique to the compiler. Possible values include: * IronPython + +``Python2_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python2_Development_FOUND`` System has the Python 2 development artifacts. + +``Python2_Development.Module_FOUND`` + .. versionadded:: 3.18 + + System has the Python 2 development artifacts for Python module. + +``Python2_Development.Embed_FOUND`` + .. versionadded:: 3.18 + + System has the Python 2 development artifacts for Python embedding. + ``Python2_INCLUDE_DIRS`` The Python 2 include directories. + +``Python2_LINK_OPTIONS`` + .. versionadded:: 3.19 + + The Python 2 link options. Some configurations require specific link options + for a correct build and execution. + ``Python2_LIBRARIES`` The Python 2 libraries. ``Python2_LIBRARY_DIRS`` @@ -119,11 +182,25 @@ This module will set the following variables in your project Python 2 minor version. ``Python2_VERSION_PATCH`` Python 2 patch version. + +``Python2_PyPy_VERSION`` + .. versionadded:: 3.18 + + Python 2 PyPy version. + ``Python2_NumPy_FOUND`` + .. versionadded:: 3.14 + System has the NumPy. + ``Python2_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + .. versionadded:: 3.14 + + The NumPy include directories. + ``Python2_NumPy_VERSION`` + .. versionadded:: 3.14 + The NumPy version. Hints @@ -139,9 +216,10 @@ Hints * If set to FALSE, search **only** for shared libraries. ``Python2_FIND_STRATEGY`` + .. versionadded:: 3.15 + This variable defines how lookup will be done. - The ``Python2_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python2_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -152,10 +230,11 @@ Hints This is the default if policy :policy:`CMP0094` is set to ``NEW``. ``Python2_FIND_REGISTRY`` + .. versionadded:: 3.13 + On Windows the ``Python2_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the - following: + the ``Python2_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -163,10 +242,12 @@ Hints * ``NEVER``: Never try to use registry. ``Python2_FIND_FRAMEWORK`` + .. versionadded:: 3.15 + On macOS the ``Python2_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -176,32 +257,90 @@ Hints variable will be used, if any. ``Python2_FIND_VIRTUALENV`` + .. versionadded:: 3.15 + This variable defines the handling of virtual environments managed by ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python2_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. * ``ONLY``: Only the virtual environment is used to look-up for the interpreter. * ``STANDARD``: The virtual environment is not used to look-up for the - interpreter. In this case, variable ``Python2_FIND_REGISTRY`` (Windows) - or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + interpreter but environment variable ``PATH`` is always considered. + In this case, variable ``Python2_FIND_REGISTRY`` (Windows) or + ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or ``NEVER`` to select preferably the interpreter from the virtual environment. + .. versionadded:: 3.17 + Added support for ``conda`` environments. + .. note:: If the component ``Development`` is requested, it is **strongly** recommended to also include the component ``Interpreter`` to get expected result. +``Python2_FIND_IMPLEMENTATIONS`` + .. versionadded:: 3.18 + + This variable defines, in an ordered list, the different implementations + which will be searched. The ``Python2_FIND_IMPLEMENTATIONS`` variable can + hold the following values: + + * ``CPython``: this is the standard implementation. Various products, like + ``Anaconda`` or ``ActivePython``, rely on this implementation. + * ``IronPython``: This implementation use the ``CSharp`` language for + ``.NET Framework`` on top of the `Dynamic Language Runtime` (``DLR``). + See `IronPython `_. + * ``PyPy``: This implementation use ``RPython`` language and + ``RPython translation toolchain`` to produce the python interpreter. + See `PyPy `_. + + The default value is: + + * Windows platform: ``CPython``, ``IronPython`` + * Other platforms: ``CPython`` + + .. note:: + + This hint has the lowest priority of all hints, so even if, for example, + you specify ``IronPython`` first and ``CPython`` in second, a python + product based on ``CPython`` can be selected because, for example with + ``Python2_FIND_STRATEGY=LOCATION``, each location will be search first for + ``IronPython`` and second for ``CPython``. + + .. note:: + + When ``IronPython`` is specified, on platforms other than ``Windows``, the + ``.Net`` interpreter (i.e. ``mono`` command) is expected to be available + through the ``PATH`` variable. + +``Python2_FIND_UNVERSIONED_NAMES`` + .. versionadded:: 3.20 + + This variable defines how the generic names will be searched. Currently, it + only applies to the generic names of the interpreter, namely, ``python2`` and + ``python``. + The ``Python2_FIND_UNVERSIONED_NAMES`` variable can be set to one of the + following values: + + * ``FIRST``: The generic names are searched before the more specialized ones + (such as ``python2.5`` for example). + * ``LAST``: The generic names are searched after the more specialized ones. + This is the default. + * ``NEVER``: The generic name are not searched at all. + Artifacts Specification ^^^^^^^^^^^^^^^^^^^^^^^ +.. versionadded:: 3.16 + To solve special cases, it is possible to specify directly the artifacts by setting the following variables: @@ -211,9 +350,14 @@ setting the following variables: ``Python2_COMPILER`` The path to the compiler. +``Python2_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python2_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python2_LIBRARIES``, ``Python2_LIBRAY_DIRS`` and + variables ``Python2_LIBRARIES``, ``Python2_LIBRARY_DIRS`` and ``Python2_RUNTIME_LIBRARY_DIRS``. ``Python2_INCLUDE_DIR`` @@ -234,9 +378,27 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controlled with the following variable: + +``Python2_ARTIFACTS_INTERACTIVE`` + .. versionadded:: 3.18 + + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ diff --git a/config/FindPython3.cmake b/config/FindPython3.cmake index e3a8a11..f826fcf 100644 --- a/config/FindPython3.cmake +++ b/config/FindPython3.cmake @@ -5,21 +5,45 @@ FindPython3 ----------- +.. versionadded:: 3.12 + Find Python 3 interpreter, compiler and development environment (include directories and libraries). +.. versionadded:: 3.19 + When a version is requested, it can be specified as a simple value or as a + range. For a detailed description of version range usage and capabilities, + refer to the :command:`find_package` command. + The following components are supported: * ``Interpreter``: search for Python 3 interpreter * ``Compiler``: search for Python 3 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and - libraries) + libraries). + + .. versionadded:: 3.18 + This component includes two sub-components which can be specified + independently: + + * ``Development.Module``: search for artifacts for Python 3 module + developments. + * ``Development.Embed``: search for artifacts for Python 3 embedding + developments. + * ``NumPy``: search for NumPy include directories. +.. versionadded:: 3.14 + Added the ``NumPy`` component. + If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed. +If component ``Development`` is specified, it implies sub-components +``Development.Module`` and ``Development.Embed``. + To ensure consistent versions between components ``Interpreter``, ``Compiler``, -``Development`` and ``NumPy``, specify all components at the same time:: +``Development`` (or one of its sub-components) and ``NumPy``, specify all +components at the same time:: find_package (Python3 COMPONENTS Interpreter Development) @@ -31,28 +55,39 @@ for you. .. note:: - If components ``Interpreter`` and ``Development`` are both specified, this - module search only for interpreter with same platform architecture as the one - defined by ``CMake`` configuration. This contraint does not apply if only - ``Interpreter`` component is specified. + If components ``Interpreter`` and ``Development`` (or one of its + sub-components) are both specified, this module search only for interpreter + with same platform architecture as the one defined by ``CMake`` + configuration. This constraint does not apply if only ``Interpreter`` + component is specified. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets ` -(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): +This module defines the following :ref:`Imported Targets `: + +.. versionchanged:: 3.14 + :ref:`Imported Targets ` are only created when + :prop_gbl:`CMAKE_ROLE` is ``PROJECT``. ``Python3::Interpreter`` Python 3 interpreter. Target defined if component ``Interpreter`` is found. ``Python3::Compiler`` Python 3 compiler. Target defined if component ``Compiler`` is found. -``Python3::Python`` - Python 3 library for Python embedding. Target defined if component - ``Development`` is found. + ``Python3::Module`` + .. versionadded:: 3.15 + Python 3 library for Python module. Target defined if component - ``Development`` is found. + ``Development.Module`` is found. + +``Python3::Python`` + Python 3 library for Python embedding. Target defined if component + ``Development.Embed`` is found. + ``Python3::NumPy`` + .. versionadded:: 3.14 + NumPy library for Python 3. Target defined if component ``NumPy`` is found. Result Variables @@ -74,33 +109,44 @@ This module will set the following variables in your project * Anaconda * Canopy * IronPython + * PyPy ``Python3_STDLIB`` Standard platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)`` + or else ``sysconfig.get_path('stdlib')``. ``Python3_STDARCH`` Standard platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)`` + or else ``sysconfig.get_path('platstdlib')``. ``Python3_SITELIB`` Third-party platform independent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)`` + or else ``sysconfig.get_path('purelib')``. ``Python3_SITEARCH`` Third-party platform dependent installation directory. Information returned by - ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. + ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)`` + or else ``sysconfig.get_path('platlib')``. + ``Python3_SOABI`` + .. versionadded:: 3.17 + Extension suffix for modules. Information returned by - ``distutils.sysconfig.get_config_var('SO')`` or computed from + ``distutils.sysconfig.get_config_var('SOABI')`` or computed from ``distutils.sysconfig.get_config_var('EXT_SUFFIX')`` or - ``python3-config --extension-suffix``. + ``python3-config --extension-suffix``. If package ``distutils.sysconfig`` is + not available, ``sysconfig.get_config_var('SOABI')`` or + ``sysconfig.get_config_var('EXT_SUFFIX')`` are used. + ``Python3_Compiler_FOUND`` System has the Python 3 compiler. ``Python3_COMPILER`` @@ -108,10 +154,36 @@ This module will set the following variables in your project ``Python3_COMPILER_ID`` A short string unique to the compiler. Possible values include: * IronPython + +``Python3_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python3_Development_FOUND`` + System has the Python 3 development artifacts. + +``Python3_Development.Module_FOUND`` + .. versionadded:: 3.18 + + System has the Python 3 development artifacts for Python module. + +``Python3_Development.Embed_FOUND`` + .. versionadded:: 3.18 + + System has the Python 3 development artifacts for Python embedding. + ``Python3_INCLUDE_DIRS`` + The Python 3 include directories. + +``Python3_LINK_OPTIONS`` + .. versionadded:: 3.19 + + The Python 3 link options. Some configurations require specific link options + for a correct build and execution. + ``Python3_LIBRARIES`` The Python 3 libraries. ``Python3_LIBRARY_DIRS`` @@ -126,11 +198,25 @@ This module will set the following variables in your project Python 3 minor version. ``Python3_VERSION_PATCH`` Python 3 patch version. + +``Python3_PyPy_VERSION`` + .. versionadded:: 3.18 + + Python 3 PyPy version. + ``Python3_NumPy_FOUND`` + .. versionadded:: 3.14 + System has the NumPy. + ``Python3_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + .. versionadded:: 3.14 + + The NumPy include directories. + ``Python3_NumPy_VERSION`` + .. versionadded:: 3.14 + The NumPy version. Hints @@ -146,6 +232,8 @@ Hints * If set to FALSE, search **only** for shared libraries. ``Python3_FIND_ABI`` + .. versionadded:: 3.16 + This variable defines which ABIs, as defined in `PEP 3149 `_, should be searched. @@ -159,7 +247,7 @@ Hints * ``ON``: Corresponding flag is selected. * ``OFF``: Corresponding flag is not selected. - * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched. + * ``ANY``: The two possibilities (``ON`` and ``OFF``) will be searched. From this 3-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, ``debug`` versions will be @@ -187,9 +275,10 @@ Hints each flag is ``OFF`` or ``ANY``. ``Python3_FIND_STRATEGY`` + .. versionadded:: 3.15 + This variable defines how lookup will be done. - The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python3_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -200,10 +289,11 @@ Hints This is the default if policy :policy:`CMP0094` is set to ``NEW``. ``Python3_FIND_REGISTRY`` + .. versionadded:: 3.13 + On Windows the ``Python3_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - The ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the - following: + The ``Python3_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -211,10 +301,12 @@ Hints * ``NEVER``: Never try to use registry. ``Python3_FIND_FRAMEWORK`` + .. versionadded:: 3.15 + On macOS the ``Python3_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -224,32 +316,90 @@ Hints variable will be used, if any. ``Python3_FIND_VIRTUALENV`` + .. versionadded:: 3.15 + This variable defines the handling of virtual environments managed by ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python3_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. * ``ONLY``: Only the virtual environment is used to look-up for the interpreter. * ``STANDARD``: The virtual environment is not used to look-up for the - interpreter. In this case, variable ``Python3_FIND_REGISTRY`` (Windows) - or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + interpreter but environment variable ``PATH`` is always considered. + In this case, variable ``Python3_FIND_REGISTRY`` (Windows) or + ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or ``NEVER`` to select preferably the interpreter from the virtual environment. + .. versionadded:: 3.17 + Added support for ``conda`` environments. + .. note:: If the component ``Development`` is requested, it is **strongly** recommended to also include the component ``Interpreter`` to get expected result. +``Python3_FIND_IMPLEMENTATIONS`` + .. versionadded:: 3.18 + + This variable defines, in an ordered list, the different implementations + which will be searched. The ``Python3_FIND_IMPLEMENTATIONS`` variable can + hold the following values: + + * ``CPython``: this is the standard implementation. Various products, like + ``Anaconda`` or ``ActivePython``, rely on this implementation. + * ``IronPython``: This implementation use the ``CSharp`` language for + ``.NET Framework`` on top of the `Dynamic Language Runtime` (``DLR``). + See `IronPython `_. + * ``PyPy``: This implementation use ``RPython`` language and + ``RPython translation toolchain`` to produce the python interpreter. + See `PyPy `_. + + The default value is: + + * Windows platform: ``CPython``, ``IronPython`` + * Other platforms: ``CPython`` + + .. note:: + + This hint has the lowest priority of all hints, so even if, for example, + you specify ``IronPython`` first and ``CPython`` in second, a python + product based on ``CPython`` can be selected because, for example with + ``Python3_FIND_STRATEGY=LOCATION``, each location will be search first for + ``IronPython`` and second for ``CPython``. + + .. note:: + + When ``IronPython`` is specified, on platforms other than ``Windows``, the + ``.Net`` interpreter (i.e. ``mono`` command) is expected to be available + through the ``PATH`` variable. + +``Python3_FIND_UNVERSIONED_NAMES`` + .. versionadded:: 3.20 + + This variable defines how the generic names will be searched. Currently, it + only applies to the generic names of the interpreter, namely, ``python3`` and + ``python``. + The ``Python3_FIND_UNVERSIONED_NAMES`` variable can be set to one of the + following values: + + * ``FIRST``: The generic names are searched before the more specialized ones + (such as ``python3.5`` for example). + * ``LAST``: The generic names are searched after the more specialized ones. + This is the default. + * ``NEVER``: The generic name are not searched at all. + Artifacts Specification ^^^^^^^^^^^^^^^^^^^^^^^ +.. versionadded:: 3.16 + To solve special cases, it is possible to specify directly the artifacts by setting the following variables: @@ -259,9 +409,14 @@ setting the following variables: ``Python3_COMPILER`` The path to the compiler. +``Python3_DOTNET_LAUNCHER`` + .. versionadded:: 3.18 + + The ``.Net`` interpreter. Only used by ``IronPython`` implementation. + ``Python3_LIBRARY`` The path to the library. It will be used to compute the - variables ``Python3_LIBRARIES``, ``Python3_LIBRAY_DIRS`` and + variables ``Python3_LIBRARIES``, ``Python3_LIBRARY_DIRS`` and ``Python3_RUNTIME_LIBRARY_DIRS``. ``Python3_INCLUDE_DIR`` @@ -282,9 +437,27 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controlled with the following variable: + +``Python3_ARTIFACTS_INTERACTIVE`` + .. versionadded:: 3.18 + + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ @@ -299,8 +472,9 @@ of Python module naming rules:: If the library type is not specified, ``MODULE`` is assumed. -For ``MODULE`` library type, if option ``WITH_SOABI`` is specified, the -module suffix will include the ``Python3_SOABI`` value, if any. +.. versionadded:: 3.17 + For ``MODULE`` library type, if option ``WITH_SOABI`` is specified, the + module suffix will include the ``Python3_SOABI`` value, if any. #]=======================================================================] diff --git a/config/FindPythonInterp.cmake b/config/FindPythonInterp.cmake index 1e01a99..efe0f11 100644 --- a/config/FindPythonInterp.cmake +++ b/config/FindPythonInterp.cmake @@ -54,7 +54,7 @@ unset(_Python_NAMES) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonInterp_FIND_VERSION) if(PythonInterp_FIND_VERSION_COUNT GREATER 1) diff --git a/config/FindPythonLibs.cmake b/config/FindPythonLibs.cmake index d3ec7be..396f0d2 100644 --- a/config/FindPythonLibs.cmake +++ b/config/FindPythonLibs.cmake @@ -79,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonLibs_FIND_VERSION) if(PythonLibs_FIND_VERSION_COUNT GREATER 1) diff --git a/config/FindPythonLibsWrapper.cmake b/config/FindPythonLibsWrapper.cmake index ceb57e3..969d59a 100644 --- a/config/FindPythonLibsWrapper.cmake +++ b/config/FindPythonLibsWrapper.cmake @@ -22,7 +22,7 @@ if ("${PYTHON_LIBRARIES}" MATCHES "libpython[1-9.]*.a") # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS} - 3.7 3.6 3.5 3.4 2.8 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) + 3.10 3.9 3.8 3.7 3.6 3.5 3.4 2.8 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) foreach (_CURRENT_VERSION ${_Python_VERSIONS}) string (REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})