diff --git a/GNUInstallDirs.cmake b/GNUInstallDirs.cmake
index f95e6e2c5..fbf56b86c 100644
--- a/GNUInstallDirs.cmake
+++ b/GNUInstallDirs.cmake
@@ -124,9 +124,6 @@ Macros
absolute paths where necessary, using the same logic.
#]=======================================================================]
-cmake_policy(PUSH)
-cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
-
# Convert a cache variable to PATH type
macro(_GNUInstallDirs_cache_convert_to_path var description)
@@ -380,5 +377,3 @@ foreach(dir
)
GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir})
endforeach()
-
-cmake_policy(POP)
diff --git a/README.md b/README.md
index 0380943e5..824ca5514 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-Shared CMake submodule
-======================
+# Shared CMake submodule
[![Documentation Status](https://readthedocs.org/projects/jrl-cmakemodules/badge/?version=master)](https://jrl-cmakemodules.readthedocs.io/en/master/?badge=master)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/jrl-umi3218/jrl-cmakemodules/master.svg)](https://results.pre-commit.ci/latest/github/jrl-umi3218/jrl-cmakemodules/master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
+
This repository is meant to be used as a submodule for any project
from CNRS LAAS/HPP or JRL.
@@ -20,7 +20,11 @@ You can also checkout the more complete [documentation] of the modules.
[documentation]: http://jrl-cmakemodules.readthedocs.io/en/master/
-# pre-commit
+## Supported CMake versions
+
+We currently support CMake >= 3.10
+
+## pre-commit
This project use [pre-commit](https://pre-commit.com) and [pre-commit.ci](https://pre-commit.ci).
diff --git a/_unittests/test_pkg-config.cmake b/_unittests/test_pkg-config.cmake
index 97bae316a..ca33930bc 100644
--- a/_unittests/test_pkg-config.cmake
+++ b/_unittests/test_pkg-config.cmake
@@ -1,6 +1,5 @@
include(cmake/pkg-config.cmake)
-cmake_policy(SET CMP0054 NEW)
# cmake -P
macro(EXPECT_STREQUAL _lhs _rhs)
if(NOT "${_lhs}" STREQUAL ${_rhs})
diff --git a/base.cmake b/base.cmake
index ca16b73bd..ec46e83ba 100644
--- a/base.cmake
+++ b/base.cmake
@@ -119,6 +119,10 @@
# ------
#
+if(${CMAKE_VERSION} VERSION_LESS 3.10)
+ message(FATAL_ERROR "JRL-CMakemodules require CMake >= 3.10")
+endif()
+
set(PROJECT_JRL_CMAKE_MODULE_DIR
${CMAKE_CURRENT_LIST_DIR}
CACHE INTERNAL "")
@@ -257,19 +261,9 @@ 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()
+ # To be more robust, value should be stripped
+ if(NOT "${VALUE}" IN_LIST ${LIST})
+ list(APPEND ${LIST} "${VALUE}")
endif()
endmacro(
_ADD_TO_LIST_IF_NOT_PRESENT
@@ -355,22 +349,9 @@ 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
- set(${_project_VARIABLE} ${_project_LANGUAGES})
- endif(CMAKE_VERSION VERSION_GREATER "3.0.0")
+ set(${_project_VARIABLE}
+ VERSION ${PROJECT_VERSION_FULL} LANGUAGES ${_project_LANGUAGES}
+ DESCRIPTION ${PROJECT_DESCRIPTION})
endmacro(COMPUTE_PROJECT_ARGS)
# .rst: .. ifmode:: user
diff --git a/boost/FindBoost.cmake b/boost/FindBoost.cmake
index 38b0d0026..4be6aedc4 100644
--- a/boost/FindBoost.cmake
+++ b/boost/FindBoost.cmake
@@ -384,8 +384,6 @@ Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake.
include(FindPackageHandleStandardArgs)
# 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()
@@ -628,8 +626,6 @@ if (NOT Boost_NO_BOOST_CMAKE)
find_package_handle_standard_args(Boost HANDLE_COMPONENTS CONFIG_MODE)
_boost_set_legacy_variables_from_config()
- # Restore project's policies
- cmake_policy(POP)
return()
endif()
endif()
diff --git a/cmake_reinstall.cmake.in b/cmake_reinstall.cmake.in
index fae9569ba..3b98befcb 100644
--- a/cmake_reinstall.cmake.in
+++ b/cmake_reinstall.cmake.in
@@ -12,7 +12,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-cmake_policy(SET CMP0007 NEW)
if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
execute_process(COMMAND "@CMAKE_COMMAND@" --build "@PROJECT_BINARY_DIR@" --target uninstall --config $)
endif()
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
index 2d6c62c08..1dd0999c4 100644
--- a/cmake_uninstall.cmake.in
+++ b/cmake_uninstall.cmake.in
@@ -14,7 +14,6 @@
# along with this program. If not, see .
#
# This files comes from the CMake FAQ: http://www.cmake.org/Wiki/CMake_FAQ
-cmake_policy(SET CMP0007 NEW)
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
RETURN()
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
diff --git a/cxx11.cmake b/cxx11.cmake
index 8c6779a9e..a3b623d8d 100644
--- a/cxx11.cmake
+++ b/cxx11.cmake
@@ -13,52 +13,16 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
-include(CheckCXXCompilerFlag)
-
-# .rst: .. ifmode:: user
-#
-# .. command:: CHECK_CXX11_SUPPORT
-#
-# Set ouput variable CXX11_SUPPORTED to TRUE if C++11 is supported by the
-# current compiler. Set to FALSE otherwise.
-#
-function(CHECK_CXX11_SUPPORT CXX11_SUPPORTED)
- 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)
- set(${CXX11_SUPPORTED}
- TRUE
- PARENT_SCOPE)
- else()
- set(${CXX11_SUPPORTED}
- FALSE
- PARENT_SCOPE)
- endif()
-endfunction(CHECK_CXX11_SUPPORT)
-
# .rst: .. ifmode:: user
#
# .. command:: PROJECT_USE_CXX11
#
-# This macro set up the project to compile the whole project with C++11
-# standards.
+# DEPRECATED. This macro set up the project to compile the whole project with
+# C++11 standards.
#
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()
- else()
- message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
- endif()
+ message(
+ DEPRECATION
+ "This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead.")
+ check_minimal_cxx_standard(11 REQUIRED)
endmacro(PROJECT_USE_CXX11)
diff --git a/cython/python/FindPython/Support.cmake b/cython/python/FindPython/Support.cmake
index 82f0493b3..e0590b3ea 100644
--- a/cython/python/FindPython/Support.cmake
+++ b/cython/python/FindPython/Support.cmake
@@ -5,7 +5,7 @@
# This file is a "template" file used by various FindPython modules.
#
-cmake_policy (VERSION 3.5)
+cmake_policy (VERSION 3.10)
#
# Initial configuration
diff --git a/find-external/OpenMP/FindOpenMP.cmake b/find-external/OpenMP/FindOpenMP.cmake
index 3b6725a16..4a66db9f6 100644
--- a/find-external/OpenMP/FindOpenMP.cmake
+++ b/find-external/OpenMP/FindOpenMP.cmake
@@ -92,11 +92,6 @@ should use the ``OpenMP__INCLUDE_DIRS`` _output_ variable if it needs
to know what include directories are needed.
#]=======================================================================]
-cmake_policy(PUSH)
-cmake_policy(SET CMP0012 NEW) # if() recognizes numbers and booleans
-cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
-cmake_policy(SET CMP0057 NEW) # if IN_LIST
-
function(_OPENMP_FLAG_CANDIDATES LANG)
if(NOT OpenMP_${LANG}_FLAG)
unset(OpenMP_FLAG_CANDIDATES)
@@ -775,5 +770,3 @@ unset(OpenMP_Fortran_TEST_SOURCE)
unset(OpenMP_C_CXX_CHECK_VERSION_SOURCE)
unset(OpenMP_Fortran_CHECK_VERSION_SOURCE)
unset(OpenMP_Fortran_INCLUDE_LINE)
-
-cmake_policy(POP)
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()
diff --git a/version-script.cmake b/version-script.cmake
index 4a548a8ac..335e4a482 100644
--- a/version-script.cmake
+++ b/version-script.cmake
@@ -18,10 +18,7 @@ include(CheckCCompilerFlag)
if(${CMAKE_VERSION} VERSION_LESS 3.18.0)
# Do nothing
else()
- cmake_policy(PUSH)
- cmake_policy(SET CMP0057 NEW) # if IN_LIST
include(CheckLinkerFlag)
- cmake_policy(POP)
endif()
# _CHECK_VERSION_SCRIPT_SUPPORT