From 5f614438e12d622d9aa805538d50bc74c84e4f5b Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sat, 16 Sep 2023 17:01:10 +0200 Subject: [PATCH] remove conditions about CMAKE_VERSION < 3.10 --- base.cmake | 41 ++-- cxx11.cmake | 12 +- logging.cmake | 6 +- msvc-specific.cmake | 4 - python.cmake | 8 - python/FindPythonInterp.cmake | 171 --------------- python/FindPythonLibs.cmake | 399 ---------------------------------- 7 files changed, 16 insertions(+), 625 deletions(-) delete mode 100644 python/FindPythonInterp.cmake delete mode 100644 python/FindPythonLibs.cmake diff --git a/base.cmake b/base.cmake index ca16b73bd..7ea1ba7de 100644 --- a/base.cmake +++ b/base.cmake @@ -257,20 +257,13 @@ endmacro( # LIST : the list. VALUE : the value to be appended. # macro(_ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE) - if(CMAKE_VERSION VERSION_GREATER "3.3.0") - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) - # To be more robust, value should be stripped - if(NOT "${VALUE}" IN_LIST ${LIST}) - list(APPEND ${LIST} "${VALUE}") - endif() - cmake_policy(POP) - else() - list(FIND LIST "${VALUE}" _index) - if(${_index} EQUAL -1) - list(APPEND LIST "${VALUE}") - endif() + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + # To be more robust, value should be stripped + if(NOT "${VALUE}" IN_LIST ${LIST}) + list(APPEND ${LIST} "${VALUE}") endif() + cmake_policy(POP) endmacro( _ADD_TO_LIST_IF_NOT_PRESENT LIST @@ -355,22 +348,14 @@ macro(COMPUTE_PROJECT_ARGS _project_VARIABLE) set(_project_LANGUAGES "CXX") endif() - if(CMAKE_VERSION VERSION_GREATER "3.0.0") - # CMake >= 3.0 - cmake_policy(SET CMP0048 NEW) - set(${_project_VARIABLE} VERSION ${PROJECT_VERSION_FULL} LANGUAGES - ${_project_LANGUAGES}) - - # Append description for CMake >= 3.9 - if(CMAKE_VERSION VERSION_GREATER "3.9.0") - set(${_project_VARIABLE} ${${_project_VARIABLE}} DESCRIPTION - ${PROJECT_DESCRIPTION}) - endif(CMAKE_VERSION VERSION_GREATER "3.9.0") - else(CMAKE_VERSION VERSION_GREATER "3.0.0") + # CMake >= 3.0 + cmake_policy(SET CMP0048 NEW) + set(${_project_VARIABLE} VERSION ${PROJECT_VERSION_FULL} LANGUAGES + ${_project_LANGUAGES}) - # CMake < 3.0 - set(${_project_VARIABLE} ${_project_LANGUAGES}) - endif(CMAKE_VERSION VERSION_GREATER "3.0.0") + # Append description for CMake >= 3.9 + set(${_project_VARIABLE} ${${_project_VARIABLE}} DESCRIPTION + ${PROJECT_DESCRIPTION}) endmacro(COMPUTE_PROJECT_ARGS) # .rst: .. ifmode:: user diff --git a/cxx11.cmake b/cxx11.cmake index 8c6779a9e..1be7fd60e 100644 --- a/cxx11.cmake +++ b/cxx11.cmake @@ -48,16 +48,8 @@ macro(PROJECT_USE_CXX11) check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X) check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11) - if(CMAKE_VERSION VERSION_LESS "3.1") - if(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - elseif(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif() - else() - set(CMAKE_CXX_STANDARD 11) - set(CXX_STANDARD_REQUIRED ON) - endif() + set(CMAKE_CXX_STANDARD 11) + set(CXX_STANDARD_REQUIRED ON) else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") endif() diff --git a/logging.cmake b/logging.cmake index bab05a3ad..b9b8a88a7 100644 --- a/logging.cmake +++ b/logging.cmake @@ -67,11 +67,7 @@ endif(UNIX) # function(LOGGING_INITIALIZE) # Retrieve interesting information. - if(${CMAKE_VERSION} VERSION_LESS 2.8) - set(HOSTNAME "unknown (CMake >= 2.8 required)") - else() - site_name(HOSTNAME) - endif() + site_name(HOSTNAME) # Write logging file. file(REMOVE ${JRL_CMAKEMODULE_LOGGING_FILENAME}) diff --git a/msvc-specific.cmake b/msvc-specific.cmake index f7ff9e299..286f84445 100644 --- a/msvc-specific.cmake +++ b/msvc-specific.cmake @@ -146,10 +146,6 @@ macro(REQUIRE_MINIMUM_MSVC_VERSION VERSION) endif(${MSVC_TOOLS_VERSION}) endmacro(REQUIRE_MINIMUM_MSVC_VERSION) -if(${CMAKE_VERSION} VERSION_LESS "3.5.0") - include(CMakeParseArguments) -endif() - # GENERATE_MSVC_DOT_USER_FILE( []) # GENERATE_MSVC_DOT_USER_FILE(NAME [COMMAND ] [COMMAND_ARGS # ] [WORKING_DIRECTORY ] [ADDITIONAL_PATH ]) diff --git a/python.cmake b/python.cmake index 88726c2d9..dcfa17f74 100644 --- a/python.cmake +++ b/python.cmake @@ -55,14 +55,6 @@ # nothing for CMake < 3.12 which doesn't have those. This also export: - # `FIND_NUMPY` and/or `SEARCH_FOR_BOOST_PYTHON` if necessary. -if(CMAKE_VERSION VERSION_LESS "3.2") - set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/python ${CMAKE_MODULE_PATH}) - message( - STATUS - "CMake versions older than 3.2 do not properly find Python. Custom macros are used to find it." - ) -endif(CMAKE_VERSION VERSION_LESS "3.2") - macro(FINDPYTHON) if(DEFINED FINDPYTHON_ALREADY_CALLED) message( diff --git a/python/FindPythonInterp.cmake b/python/FindPythonInterp.cmake deleted file mode 100644 index 1e01a99cb..000000000 --- a/python/FindPythonInterp.cmake +++ /dev/null @@ -1,171 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPythonInterp ----------------- - -.. deprecated:: 3.12 - - Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. - -Find python interpreter - -This module finds if Python interpreter is installed and determines -where the executables are. This code sets the following variables: - -:: - - PYTHONINTERP_FOUND - Was the Python executable found - PYTHON_EXECUTABLE - path to the Python interpreter - - - -:: - - PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 - PYTHON_VERSION_MAJOR - Python major version found e.g. 2 - PYTHON_VERSION_MINOR - Python minor version found e.g. 5 - PYTHON_VERSION_PATCH - Python patch version found e.g. 2 - - - -The Python_ADDITIONAL_VERSIONS variable can be used to specify a list -of version numbers that should be taken into account when searching -for Python. You need to set this variable before calling -find_package(PythonInterp). - -If calling both ``find_package(PythonInterp)`` and -``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to -get the currently active Python version by default with a consistent version -of PYTHON_LIBRARIES. - -.. note:: - - A call to ``find_package(PythonInterp ${V})`` for python version ``V`` - may find a ``python`` executable with no version suffix. In this case - no attempt is made to avoid python executables from other versions. - Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` - instead. - -#]=======================================================================] - -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) - -if(PythonInterp_FIND_VERSION) - if(PythonInterp_FIND_VERSION_COUNT GREATER 1) - set(_PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION_MAJOR}.${PythonInterp_FIND_VERSION_MINOR}") - list(APPEND _Python_NAMES - python${_PYTHON_FIND_MAJ_MIN} - python${PythonInterp_FIND_VERSION_MAJOR}) - unset(_PYTHON_FIND_OTHER_VERSIONS) - if(NOT PythonInterp_FIND_VERSION_EXACT) - foreach(_PYTHON_V ${_PYTHON${PythonInterp_FIND_VERSION_MAJOR}_VERSIONS}) - if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) - list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) - endif() - endforeach() - endif() - unset(_PYTHON_FIND_MAJ_MIN) - else() - list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION_MAJOR}) - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION_MAJOR}_VERSIONS}) - endif() -else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) -endif() -find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) - -# 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}) -# If FindPythonInterp has already found the major and minor version, -# insert that version next to get consistent versions of the interpreter and -# library. -if(DEFINED PYTHONLIBS_VERSION_STRING) - string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}") - list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR) - list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR) - list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR}) -endif() -# Search for the current active python version first -list(APPEND _Python_VERSIONS ";") -list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) - -unset(_PYTHON_FIND_OTHER_VERSIONS) -unset(_PYTHON1_VERSIONS) -unset(_PYTHON2_VERSIONS) -unset(_PYTHON3_VERSIONS) - -# Search for newest python version if python executable isn't found -if(NOT PYTHON_EXECUTABLE) - foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS) - set(_Python_NAMES python${_CURRENT_VERSION}) - if(CMAKE_HOST_WIN32) - list(APPEND _Python_NAMES python) - endif() - find_program(PYTHON_EXECUTABLE - NAMES ${_Python_NAMES} - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-32\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-64\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-32\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-64\\InstallPath] - ) - endforeach() -endif() - -# determine python version string -if(PYTHON_EXECUTABLE) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c - "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" - OUTPUT_VARIABLE _VERSION - RESULT_VARIABLE _PYTHON_VERSION_RESULT - ERROR_QUIET) - if(NOT _PYTHON_VERSION_RESULT) - string(REPLACE ";" "." PYTHON_VERSION_STRING "${_VERSION}") - list(GET _VERSION 0 PYTHON_VERSION_MAJOR) - list(GET _VERSION 1 PYTHON_VERSION_MINOR) - list(GET _VERSION 2 PYTHON_VERSION_PATCH) - if(PYTHON_VERSION_PATCH EQUAL 0) - # it's called "Python 2.7", not "2.7.0" - string(REGEX REPLACE "\\.0$" "" PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}") - endif() - else() - # sys.version predates sys.version_info, so use that - # sys.version was first documented for Python 1.5, so assume version 1.4 - # if retrieving sys.version fails. - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "try: import sys; sys.stdout.write(sys.version)\nexcept: sys.stdout.write(\"1.4.0\")" - OUTPUT_VARIABLE _VERSION - RESULT_VARIABLE _PYTHON_VERSION_RESULT - ERROR_QUIET) - if(NOT _PYTHON_VERSION_RESULT) - string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}") - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") - if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)") - set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}") - else() - set(PYTHON_VERSION_PATCH "0") - endif() - else() - unset(PYTHON_VERSION_STRING) - unset(PYTHON_VERSION_MAJOR) - unset(PYTHON_VERSION_MINOR) - unset(PYTHON_VERSION_PATCH) - endif() - endif() - unset(_PYTHON_VERSION_RESULT) - unset(_VERSION) -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) - -mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/python/FindPythonLibs.cmake b/python/FindPythonLibs.cmake deleted file mode 100644 index d3ec7beec..000000000 --- a/python/FindPythonLibs.cmake +++ /dev/null @@ -1,399 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPythonLibs --------------- - -.. deprecated:: 3.12 - - Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. - -Find python libraries - -This module finds if Python is installed and determines where the -include files and libraries are. It also determines what the name of -the library is. This code sets the following variables: - -:: - - PYTHONLIBS_FOUND - have the Python libs been found - PYTHON_LIBRARIES - path to the python library - PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) - PYTHON_INCLUDE_DIRS - path to where Python.h is found - PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) - PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) - - - -The Python_ADDITIONAL_VERSIONS variable can be used to specify a list -of version numbers that should be taken into account when searching -for Python. You need to set this variable before calling -find_package(PythonLibs). - -If you'd like to specify the installation of Python to use, you should -modify the following cache variables: - -:: - - PYTHON_LIBRARY - path to the python library - PYTHON_INCLUDE_DIR - path to where Python.h is found - -If calling both ``find_package(PythonInterp)`` and -``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to -get the currently active Python version by default with a consistent version -of PYTHON_LIBRARIES. -#]=======================================================================] - -# Use the executable's path as a hint -set(_Python_LIBRARY_PATH_HINT) -if(IS_ABSOLUTE "${PYTHON_EXECUTABLE}") - if(WIN32) - get_filename_component(_Python_PREFIX "${PYTHON_EXECUTABLE}" PATH) - if(_Python_PREFIX) - set(_Python_LIBRARY_PATH_HINT ${_Python_PREFIX}/libs) - endif() - unset(_Python_PREFIX) - else() - get_filename_component(_Python_PREFIX "${PYTHON_EXECUTABLE}" PATH) - get_filename_component(_Python_PREFIX "${_Python_PREFIX}" PATH) - if(_Python_PREFIX) - set(_Python_LIBRARY_PATH_HINT ${_Python_PREFIX}/lib) - endif() - unset(_Python_PREFIX) - endif() -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) -# Search for the python framework on Apple. -CMAKE_FIND_FRAMEWORKS(Python) - -# Save CMAKE_FIND_FRAMEWORK -if(DEFINED CMAKE_FIND_FRAMEWORK) - set(_PythonLibs_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) -else() - unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) -endif() -# To avoid picking up the system Python.h pre-maturely. -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) - -if(PythonLibs_FIND_VERSION) - if(PythonLibs_FIND_VERSION_COUNT GREATER 1) - set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}") - unset(_PYTHON_FIND_OTHER_VERSIONS) - if(PythonLibs_FIND_VERSION_EXACT) - if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) - set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") - else() - set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") - endif() - else() - foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS}) - if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) - list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) - endif() - endforeach() - endif() - unset(_PYTHON_FIND_MAJ_MIN) - else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS}) - endif() -else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) -endif() - -# Set up the versions we know about, in the order we will search. Always add -# the user supplied additional versions to the front. -# If FindPythonInterp has already found the major and minor version, -# insert that version between the user supplied versions and the stock -# version list. -set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) -if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR) - list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -endif() -list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) - -unset(_PYTHON_FIND_OTHER_VERSIONS) -unset(_PYTHON1_VERSIONS) -unset(_PYTHON2_VERSIONS) -unset(_PYTHON3_VERSIONS) - -# Python distribution: define which architectures can be used -if (CMAKE_SIZEOF_VOID_P) - # In this case, search only for 64bit or 32bit - math (EXPR _PYTHON_ARCH "${CMAKE_SIZEOF_VOID_P} * 8") - set (_PYTHON_ARCH2 _PYTHON_PREFIX_ARCH}) -else() - if (PYTHON_EXECUTABLE) - # determine interpreter architecture - execute_process (COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" - RESULT_VARIABLE _PYTHON_RESULT - OUTPUT_VARIABLE _PYTHON_IS64BIT - ERROR_VARIABLE _PYTHON_IS64BIT) - if (NOT _PYTHON_RESULT) - if (_PYTHON_IS64BIT) - set (_PYTHON_ARCH 64) - set (_PYTHON_ARCH2 64) - else() - set (_PYTHON_ARCH 32) - set (_PYTHON_ARCH2 32) - endif() - endif() - else() - # architecture unknown, search for both 64bit and 32bit - set (_PYTHON_ARCH 64) - set (_PYTHON_ARCH2 32) - endif() -endif() - -foreach(_CURRENT_VERSION ${_Python_VERSIONS}) - string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) - if(WIN32) - find_library(PYTHON_DEBUG_LIBRARY - NAMES python${_CURRENT_VERSION_NO_DOTS}_d python - NAMES_PER_DIR - HINTS ${_Python_LIBRARY_PATH_HINT} - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - ) - endif() - - set(PYTHON_FRAMEWORK_LIBRARIES) - if(Python_FRAMEWORKS AND NOT PYTHON_LIBRARY) - foreach(dir ${Python_FRAMEWORKS}) - list(APPEND PYTHON_FRAMEWORK_LIBRARIES - ${dir}/Versions/${_CURRENT_VERSION}/lib) - endforeach() - endif() - find_library(PYTHON_LIBRARY - NAMES - python${_CURRENT_VERSION_NO_DOTS} - python${_CURRENT_VERSION}mu - python${_CURRENT_VERSION}m - python${_CURRENT_VERSION}u - python${_CURRENT_VERSION} - NAMES_PER_DIR - HINTS - ${_Python_LIBRARY_PATH_HINT} - PATHS - ${PYTHON_FRAMEWORK_LIBRARIES} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - ) - # Look for the static library in the Python config directory - find_library(PYTHON_LIBRARY - NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} - NAMES_PER_DIR - # This is where the static library is usually located - PATH_SUFFIXES python${_CURRENT_VERSION}/config - ) - - # Don't search for include dir until library location is known - if(PYTHON_LIBRARY) - - # Use the library's install prefix as a hint - set(_Python_INCLUDE_PATH_HINT) - # PYTHON_LIBRARY may contain a list because of SelectLibraryConfigurations - # which may have been run previously. If it is the case, the list can be: - # optimized;;debug; - foreach(lib ${PYTHON_LIBRARY} ${PYTHON_DEBUG_LIBRARY}) - if(IS_ABSOLUTE "${lib}") - get_filename_component(_Python_PREFIX "${lib}" PATH) - get_filename_component(_Python_PREFIX "${_Python_PREFIX}" PATH) - if(_Python_PREFIX) - list(APPEND _Python_INCLUDE_PATH_HINT ${_Python_PREFIX}/include) - endif() - unset(_Python_PREFIX) - endif() - endforeach() - - # Add framework directories to the search paths - set(PYTHON_FRAMEWORK_INCLUDES) - if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) - foreach(dir ${Python_FRAMEWORKS}) - list(APPEND PYTHON_FRAMEWORK_INCLUDES - ${dir}/Versions/${_CURRENT_VERSION}/include) - endforeach() - endif() - - find_path(PYTHON_INCLUDE_DIR - NAMES Python.h - HINTS - ${_Python_INCLUDE_PATH_HINT} - PATHS - ${PYTHON_FRAMEWORK_INCLUDES} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include - PATH_SUFFIXES - python${_CURRENT_VERSION}mu - python${_CURRENT_VERSION}m - python${_CURRENT_VERSION}u - python${_CURRENT_VERSION} - ) - endif() - - # For backward compatibility, set PYTHON_INCLUDE_PATH. - set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") - - if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") - file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str - REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") - string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" - PYTHONLIBS_VERSION_STRING "${python_version_str}") - unset(python_version_str) - endif() - - if(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR) - break() - endif() -endforeach() - -unset(_Python_INCLUDE_PATH_HINT) -unset(_Python_LIBRARY_PATH_HINT) - -mark_as_advanced( - PYTHON_DEBUG_LIBRARY - PYTHON_LIBRARY - PYTHON_INCLUDE_DIR -) - -# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the -# cache entries because they are meant to specify the location of a single -# library. We now set the variables listed by the documentation for this -# module. -set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") -set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") - -# These variables have been historically named in this module different from -# what SELECT_LIBRARY_CONFIGURATIONS() expects. -set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}") -set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}") -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -SELECT_LIBRARY_CONFIGURATIONS(PYTHON) -# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library. -# Unset this, this prefix doesn't match the module prefix, they are different -# for historical reasons. -unset(PYTHON_FOUND) - -# Restore CMAKE_FIND_FRAMEWORK -if(DEFINED _PythonLibs_CMAKE_FIND_FRAMEWORK) - set(CMAKE_FIND_FRAMEWORK ${_PythonLibs_CMAKE_FIND_FRAMEWORK}) - unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) -else() - unset(CMAKE_FIND_FRAMEWORK) -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs - REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS - VERSION_VAR PYTHONLIBS_VERSION_STRING) - -# PYTHON_ADD_MODULE( src1 src2 ... srcN) is used to build modules for python. -# PYTHON_WRITE_MODULES_HEADER() writes a header file you can include -# in your sources to initialize the static python modules -function(PYTHON_ADD_MODULE _NAME ) - get_property(_TARGET_SUPPORTS_SHARED_LIBS - GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) - option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) - option(PYTHON_MODULE_${_NAME}_BUILD_SHARED - "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) - - # Mark these options as advanced - mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME} - PYTHON_MODULE_${_NAME}_BUILD_SHARED) - - if(PYTHON_ENABLE_MODULE_${_NAME}) - if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - set(PY_MODULE_TYPE MODULE) - else() - set(PY_MODULE_TYPE STATIC) - set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) - endif() - - set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) - add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) -# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES}) - - if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") - if(WIN32 AND NOT CYGWIN) - set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd") - endif() - endif() - - endif() -endfunction() - -function(PYTHON_WRITE_MODULES_HEADER _filename) - - get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST) - - get_filename_component(_name "${_filename}" NAME) - string(REPLACE "." "_" _name "${_name}") - string(TOUPPER ${_name} _nameUpper) - set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename}) - - set(_filenameTmp "${_filename}.in") - file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") - file(APPEND ${_filenameTmp} -"#ifndef ${_nameUpper} -#define ${_nameUpper} - -#include - -#ifdef __cplusplus -extern \"C\" { -#endif /* __cplusplus */ - -") - - foreach(_currentModule ${PY_STATIC_MODULES_LIST}) - file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n") - endforeach() - - file(APPEND ${_filenameTmp} -"#ifdef __cplusplus -} -#endif /* __cplusplus */ - -") - - - foreach(_currentModule ${PY_STATIC_MODULES_LIST}) - file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n") - endforeach() - - file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n") - foreach(_currentModule ${PY_STATIC_MODULES_LIST}) - file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n") - endforeach() - file(APPEND ${_filenameTmp} "}\n\n") - file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n") - -# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file() - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET) - -endfunction()