FindPython{Interp,Libs}: Add policy to remove these modules
The `FindPythonInterp` and `FindPythonLibs` modules have been deprecated since CMake 3.12. Add a policy to pretend they do not exist in order to encourage projects to port to `FindPython` or `FindPython{2,3}`.
This commit is contained in:
parent
4901fdb201
commit
a4c5b91f80
@ -57,6 +57,7 @@ Policies Introduced by CMake 3.27
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
CMP0148: The FindPythonInterp and FindPythonLibs modules are removed. </policy/CMP0148>
|
||||
CMP0147: Visual Studio generators build custom commands in parallel. </policy/CMP0147>
|
||||
CMP0146: The FindCUDA module is removed. </policy/CMP0146>
|
||||
CMP0145: The Dart and FindDart modules are removed. </policy/CMP0145>
|
||||
|
29
Help/policy/CMP0148.rst
Normal file
29
Help/policy/CMP0148.rst
Normal file
@ -0,0 +1,29 @@
|
||||
CMP0148
|
||||
-------
|
||||
|
||||
.. versionadded:: 3.27
|
||||
|
||||
The :module:`FindPythonInterp` and :module:`FindPythonLibs` modules are removed.
|
||||
|
||||
These modules have been deprecated since CMake 3.12.
|
||||
CMake 3.27 and above prefer to not provide the modules.
|
||||
This policy provides compatibility for projects that have not been
|
||||
ported away from them.
|
||||
|
||||
Projects using the :module:`FindPythonInterp` and/or :module:`FindPythonLibs`
|
||||
modules should be updated to use one of their replacements:
|
||||
|
||||
* :module:`FindPython3`
|
||||
* :module:`FindPython2`
|
||||
* :module:`FindPython`
|
||||
|
||||
The ``OLD`` behavior of this policy is for ``find_package(PythonInterp)``
|
||||
and ``find_package(PythonLibs)`` to load the deprecated modules. The ``NEW``
|
||||
behavior is for uses of the modules to fail as if they do not exist.
|
||||
|
||||
This policy was introduced in CMake version 3.27. CMake version
|
||||
|release| warns when the policy is not set and uses ``OLD`` behavior.
|
||||
Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
|
||||
explicitly.
|
||||
|
||||
.. include:: DEPRECATED.txt
|
@ -0,0 +1,6 @@
|
||||
remove-FindPythonInterp-FindPythonLibs
|
||||
--------------------------------------
|
||||
|
||||
* The :module:`FindPythonInterp` and :module:`FindPythonLibs` modules have
|
||||
been fully deprecated via policy :policy:`CMP0148`. Port projects to
|
||||
:module:`FindPython3`, :module:`FindPython2`, or :module:`FindPython`.
|
@ -5,6 +5,9 @@
|
||||
FindPythonInterp
|
||||
----------------
|
||||
|
||||
.. versionchanged:: 3.27
|
||||
This module is available only if policy :policy:`CMP0148` is not set to ``NEW``.
|
||||
|
||||
.. deprecated:: 3.12
|
||||
|
||||
Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead.
|
||||
@ -50,6 +53,16 @@ of PYTHON_LIBRARIES.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(GET CMP0148 _FindPythonInterp_CMP0148)
|
||||
if(_FindPythonInterp_CMP0148 STREQUAL "NEW")
|
||||
message(FATAL_ERROR "The FindPythonInterp module has been removed by policy CMP0148.")
|
||||
endif()
|
||||
|
||||
if(_FindPythonInterp_testing)
|
||||
set(_FindPythonInterp_included TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
unset(_Python_NAMES)
|
||||
|
||||
set(_PYTHON1_VERSIONS 1.6 1.5)
|
||||
|
@ -5,6 +5,9 @@
|
||||
FindPythonLibs
|
||||
--------------
|
||||
|
||||
.. versionchanged:: 3.27
|
||||
This module is available only if policy :policy:`CMP0148` is not set to ``NEW``.
|
||||
|
||||
.. deprecated:: 3.12
|
||||
|
||||
Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead.
|
||||
@ -45,6 +48,16 @@ get the currently active Python version by default with a consistent version
|
||||
of PYTHON_LIBRARIES.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(GET CMP0148 _FindPythonLibs_CMP0148)
|
||||
if(_FindPythonLibs_CMP0148 STREQUAL "NEW")
|
||||
message(FATAL_ERROR "The FindPythonLibs module has been removed by policy CMP0148.")
|
||||
endif()
|
||||
|
||||
if(_FindPythonLibs_testing)
|
||||
set(_FindPythonLibs_included TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Use the executable's path as a hint
|
||||
set(_Python_LIBRARY_PATH_HINT)
|
||||
if(IS_ABSOLUTE "${PYTHON_EXECUTABLE}")
|
||||
|
@ -549,6 +549,8 @@ cmFindPackageCommand::cmFindPackageCommand(cmExecutionStatus& status)
|
||||
|
||||
this->DeprecatedFindModules["CUDA"] = cmPolicies::CMP0146;
|
||||
this->DeprecatedFindModules["Dart"] = cmPolicies::CMP0145;
|
||||
this->DeprecatedFindModules["PythonInterp"] = cmPolicies::CMP0148;
|
||||
this->DeprecatedFindModules["PythonLibs"] = cmPolicies::CMP0148;
|
||||
this->DeprecatedFindModules["Qt"] = cmPolicies::CMP0084;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ bool cmIncludeCommand(std::vector<std::string> const& args,
|
||||
DeprecatedModules["Documentation"] = cmPolicies::CMP0106;
|
||||
DeprecatedModules["FindCUDA"] = cmPolicies::CMP0146;
|
||||
DeprecatedModules["FindDart"] = cmPolicies::CMP0145;
|
||||
DeprecatedModules["FindPythonInterp"] = cmPolicies::CMP0148;
|
||||
DeprecatedModules["FindPythonLibs"] = cmPolicies::CMP0148;
|
||||
DeprecatedModules["WriteCompilerDetectionHeader"] = cmPolicies::CMP0120;
|
||||
}
|
||||
|
||||
|
@ -444,6 +444,9 @@ class cmMakefile;
|
||||
cmPolicies::WARN) \
|
||||
SELECT(POLICY, CMP0147, \
|
||||
"Visual Studio generators build custom commands in parallel.", 3, \
|
||||
27, 0, cmPolicies::WARN) \
|
||||
SELECT(POLICY, CMP0148, \
|
||||
"The FindPythonInterp and FindPythonLibs modules are removed.", 3, \
|
||||
27, 0, cmPolicies::WARN)
|
||||
|
||||
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
||||
|
@ -0,0 +1,4 @@
|
||||
^CMake Warning at CMP0148-Interp-NEW\.cmake:[0-9]+ \(find_package\):
|
||||
No "FindPythonInterp\.cmake" found in CMAKE_MODULE_PATH\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
7
Tests/RunCMake/find_package/CMP0148-Interp-NEW.cmake
Normal file
7
Tests/RunCMake/find_package/CMP0148-Interp-NEW.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
set(_FindPythonInterp_testing TRUE)
|
||||
find_package(PythonInterp MODULE)
|
||||
|
||||
if(_FindPythonInterp_included)
|
||||
message(FATAL_ERROR "FindPythonInterp.cmake erroneously included")
|
||||
endif()
|
7
Tests/RunCMake/find_package/CMP0148-Interp-OLD.cmake
Normal file
7
Tests/RunCMake/find_package/CMP0148-Interp-OLD.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 OLD)
|
||||
set(_FindPythonInterp_testing TRUE)
|
||||
find_package(PythonInterp MODULE)
|
||||
|
||||
if(NOT _FindPythonInterp_included)
|
||||
message(FATAL_ERROR "FindPythonInterp.cmake not included")
|
||||
endif()
|
@ -0,0 +1,8 @@
|
||||
CMake Warning \(dev\) at CMP0148-Interp-WARN\.cmake:[0-9]+ \(find_package\):
|
||||
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
|
||||
are removed\. Run "cmake --help-policy CMP0148" for policy details\. Use
|
||||
the cmake_policy command to set the policy and suppress this warning\.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
6
Tests/RunCMake/find_package/CMP0148-Interp-WARN.cmake
Normal file
6
Tests/RunCMake/find_package/CMP0148-Interp-WARN.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
set(_FindPythonInterp_testing TRUE)
|
||||
find_package(PythonInterp MODULE)
|
||||
|
||||
if(NOT _FindPythonInterp_included)
|
||||
message(FATAL_ERROR "FindPythonInterp.cmake not included")
|
||||
endif()
|
4
Tests/RunCMake/find_package/CMP0148-Libs-NEW-stderr.txt
Normal file
4
Tests/RunCMake/find_package/CMP0148-Libs-NEW-stderr.txt
Normal file
@ -0,0 +1,4 @@
|
||||
^CMake Warning at CMP0148-Libs-NEW\.cmake:[0-9]+ \(find_package\):
|
||||
No "FindPythonLibs\.cmake" found in CMAKE_MODULE_PATH\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
7
Tests/RunCMake/find_package/CMP0148-Libs-NEW.cmake
Normal file
7
Tests/RunCMake/find_package/CMP0148-Libs-NEW.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
set(_FindPythonLibs_testing TRUE)
|
||||
find_package(PythonLibs MODULE)
|
||||
|
||||
if(_FindPythonLibs_included)
|
||||
message(FATAL_ERROR "FindPythonLibs.cmake erroneously included")
|
||||
endif()
|
7
Tests/RunCMake/find_package/CMP0148-Libs-OLD.cmake
Normal file
7
Tests/RunCMake/find_package/CMP0148-Libs-OLD.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 OLD)
|
||||
set(_FindPythonLibs_testing TRUE)
|
||||
find_package(PythonLibs MODULE)
|
||||
|
||||
if(NOT _FindPythonLibs_included)
|
||||
message(FATAL_ERROR "FindPythonLibs.cmake not included")
|
||||
endif()
|
8
Tests/RunCMake/find_package/CMP0148-Libs-WARN-stderr.txt
Normal file
8
Tests/RunCMake/find_package/CMP0148-Libs-WARN-stderr.txt
Normal file
@ -0,0 +1,8 @@
|
||||
CMake Warning \(dev\) at CMP0148-Libs-WARN\.cmake:[0-9]+ \(find_package\):
|
||||
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
|
||||
are removed\. Run "cmake --help-policy CMP0148" for policy details\. Use
|
||||
the cmake_policy command to set the policy and suppress this warning\.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
6
Tests/RunCMake/find_package/CMP0148-Libs-WARN.cmake
Normal file
6
Tests/RunCMake/find_package/CMP0148-Libs-WARN.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
set(_FindPythonLibs_testing TRUE)
|
||||
find_package(PythonLibs MODULE)
|
||||
|
||||
if(NOT _FindPythonLibs_included)
|
||||
message(FATAL_ERROR "FindPythonLibs.cmake not included")
|
||||
endif()
|
@ -47,6 +47,12 @@ if(RunCMake_GENERATOR MATCHES "Visual Studio")
|
||||
run_cmake(CMP0147-WARN)
|
||||
run_cmake(CMP0147-NEW)
|
||||
endif()
|
||||
run_cmake(CMP0148-Interp-OLD)
|
||||
run_cmake(CMP0148-Interp-WARN)
|
||||
run_cmake(CMP0148-Interp-NEW)
|
||||
run_cmake(CMP0148-Libs-OLD)
|
||||
run_cmake(CMP0148-Libs-WARN)
|
||||
run_cmake(CMP0148-Libs-NEW)
|
||||
run_cmake(WrongVersionRange)
|
||||
run_cmake(EmptyVersionRange)
|
||||
run_cmake(VersionRangeWithEXACT)
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,6 @@
|
||||
^CMake Error at CMP0148-Interp-NEW-name\.cmake:[0-9]+ \(include\):
|
||||
include could not find requested file:
|
||||
|
||||
FindPythonInterp
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
2
Tests/RunCMake/include/CMP0148-Interp-NEW-name.cmake
Normal file
2
Tests/RunCMake/include/CMP0148-Interp-NEW-name.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
include(FindPythonInterp)
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,6 @@
|
||||
^CMake Error at [^
|
||||
]*/Modules/FindPythonInterp.cmake:[0-9]+ \(message\):
|
||||
The FindPythonInterp module has been removed by policy CMP0148\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMP0148-Interp-NEW-path\.cmake:[0-9]+ \(include\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
2
Tests/RunCMake/include/CMP0148-Interp-NEW-path.cmake
Normal file
2
Tests/RunCMake/include/CMP0148-Interp-NEW-path.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
include(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)
|
7
Tests/RunCMake/include/CMP0148-Interp-OLD.cmake
Normal file
7
Tests/RunCMake/include/CMP0148-Interp-OLD.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 OLD)
|
||||
set(_FindPythonInterp_testing 1)
|
||||
include(FindPythonInterp)
|
||||
|
||||
if(NOT _FindPythonInterp_included)
|
||||
message(FATAL_ERROR "FindPythonInterp.cmake not included")
|
||||
endif()
|
8
Tests/RunCMake/include/CMP0148-Interp-WARN-stderr.txt
Normal file
8
Tests/RunCMake/include/CMP0148-Interp-WARN-stderr.txt
Normal file
@ -0,0 +1,8 @@
|
||||
^CMake Warning \(dev\) at CMP0148-Interp-WARN\.cmake:[0-9]+ \(include\):
|
||||
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
|
||||
are removed\. Run "cmake --help-policy CMP0148" for policy details\. Use
|
||||
the cmake_policy command to set the policy and suppress this warning\.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
7
Tests/RunCMake/include/CMP0148-Interp-WARN.cmake
Normal file
7
Tests/RunCMake/include/CMP0148-Interp-WARN.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
# Do not set CMP0148.
|
||||
set(_FindPythonInterp_testing 1)
|
||||
include(FindPythonInterp)
|
||||
|
||||
if(NOT _FindPythonInterp_included)
|
||||
message(FATAL_ERROR "FindPythonInterp.cmake not included")
|
||||
endif()
|
1
Tests/RunCMake/include/CMP0148-Libs-NEW-name-result.txt
Normal file
1
Tests/RunCMake/include/CMP0148-Libs-NEW-name-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/include/CMP0148-Libs-NEW-name-stderr.txt
Normal file
6
Tests/RunCMake/include/CMP0148-Libs-NEW-name-stderr.txt
Normal file
@ -0,0 +1,6 @@
|
||||
^CMake Error at CMP0148-Libs-NEW-name\.cmake:[0-9]+ \(include\):
|
||||
include could not find requested file:
|
||||
|
||||
FindPythonLibs
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
2
Tests/RunCMake/include/CMP0148-Libs-NEW-name.cmake
Normal file
2
Tests/RunCMake/include/CMP0148-Libs-NEW-name.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
include(FindPythonLibs)
|
1
Tests/RunCMake/include/CMP0148-Libs-NEW-path-result.txt
Normal file
1
Tests/RunCMake/include/CMP0148-Libs-NEW-path-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/include/CMP0148-Libs-NEW-path-stderr.txt
Normal file
6
Tests/RunCMake/include/CMP0148-Libs-NEW-path-stderr.txt
Normal file
@ -0,0 +1,6 @@
|
||||
^CMake Error at [^
|
||||
]*/Modules/FindPythonLibs.cmake:[0-9]+ \(message\):
|
||||
The FindPythonLibs module has been removed by policy CMP0148\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMP0148-Libs-NEW-path\.cmake:[0-9]+ \(include\)
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
2
Tests/RunCMake/include/CMP0148-Libs-NEW-path.cmake
Normal file
2
Tests/RunCMake/include/CMP0148-Libs-NEW-path.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
cmake_policy(SET CMP0148 NEW)
|
||||
include(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)
|
7
Tests/RunCMake/include/CMP0148-Libs-OLD.cmake
Normal file
7
Tests/RunCMake/include/CMP0148-Libs-OLD.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_policy(SET CMP0148 OLD)
|
||||
set(_FindPythonLibs_testing 1)
|
||||
include(FindPythonLibs)
|
||||
|
||||
if(NOT _FindPythonLibs_included)
|
||||
message(FATAL_ERROR "FindPythonLibs.cmake not included")
|
||||
endif()
|
8
Tests/RunCMake/include/CMP0148-Libs-WARN-stderr.txt
Normal file
8
Tests/RunCMake/include/CMP0148-Libs-WARN-stderr.txt
Normal file
@ -0,0 +1,8 @@
|
||||
^CMake Warning \(dev\) at CMP0148-Libs-WARN\.cmake:[0-9]+ \(include\):
|
||||
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
|
||||
are removed\. Run "cmake --help-policy CMP0148" for policy details\. Use
|
||||
the cmake_policy command to set the policy and suppress this warning\.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
7
Tests/RunCMake/include/CMP0148-Libs-WARN.cmake
Normal file
7
Tests/RunCMake/include/CMP0148-Libs-WARN.cmake
Normal file
@ -0,0 +1,7 @@
|
||||
# Do not set CMP0148.
|
||||
set(_FindPythonLibs_testing 1)
|
||||
include(FindPythonLibs)
|
||||
|
||||
if(NOT _FindPythonLibs_included)
|
||||
message(FATAL_ERROR "FindPythonLibs.cmake not included")
|
||||
endif()
|
@ -12,3 +12,12 @@ run_cmake(CMP0146-OLD)
|
||||
run_cmake(CMP0146-WARN)
|
||||
run_cmake(CMP0146-NEW-name)
|
||||
run_cmake(CMP0146-NEW-path)
|
||||
|
||||
run_cmake(CMP0148-Interp-OLD)
|
||||
run_cmake(CMP0148-Interp-WARN)
|
||||
run_cmake(CMP0148-Interp-NEW-name)
|
||||
run_cmake(CMP0148-Interp-NEW-path)
|
||||
run_cmake(CMP0148-Libs-OLD)
|
||||
run_cmake(CMP0148-Libs-WARN)
|
||||
run_cmake(CMP0148-Libs-NEW-name)
|
||||
run_cmake(CMP0148-Libs-NEW-path)
|
||||
|
Loading…
Reference in New Issue
Block a user