소스 검색

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}`.
Brad King 2 년 전
부모
커밋
a4c5b91f80
38개의 변경된 파일228개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      Help/manual/cmake-policies.7.rst
  2. 29 0
      Help/policy/CMP0148.rst
  3. 6 0
      Help/release/dev/remove-FindPythonInterp-FindPythonLibs.rst
  4. 13 0
      Modules/FindPythonInterp.cmake
  5. 13 0
      Modules/FindPythonLibs.cmake
  6. 2 0
      Source/cmFindPackageCommand.cxx
  7. 2 0
      Source/cmIncludeCommand.cxx
  8. 3 0
      Source/cmPolicies.h
  9. 4 0
      Tests/RunCMake/find_package/CMP0148-Interp-NEW-stderr.txt
  10. 7 0
      Tests/RunCMake/find_package/CMP0148-Interp-NEW.cmake
  11. 7 0
      Tests/RunCMake/find_package/CMP0148-Interp-OLD.cmake
  12. 8 0
      Tests/RunCMake/find_package/CMP0148-Interp-WARN-stderr.txt
  13. 6 0
      Tests/RunCMake/find_package/CMP0148-Interp-WARN.cmake
  14. 4 0
      Tests/RunCMake/find_package/CMP0148-Libs-NEW-stderr.txt
  15. 7 0
      Tests/RunCMake/find_package/CMP0148-Libs-NEW.cmake
  16. 7 0
      Tests/RunCMake/find_package/CMP0148-Libs-OLD.cmake
  17. 8 0
      Tests/RunCMake/find_package/CMP0148-Libs-WARN-stderr.txt
  18. 6 0
      Tests/RunCMake/find_package/CMP0148-Libs-WARN.cmake
  19. 6 0
      Tests/RunCMake/find_package/RunCMakeTest.cmake
  20. 1 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-name-result.txt
  21. 6 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-name-stderr.txt
  22. 2 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-name.cmake
  23. 1 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-path-result.txt
  24. 6 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-path-stderr.txt
  25. 2 0
      Tests/RunCMake/include/CMP0148-Interp-NEW-path.cmake
  26. 7 0
      Tests/RunCMake/include/CMP0148-Interp-OLD.cmake
  27. 8 0
      Tests/RunCMake/include/CMP0148-Interp-WARN-stderr.txt
  28. 7 0
      Tests/RunCMake/include/CMP0148-Interp-WARN.cmake
  29. 1 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-name-result.txt
  30. 6 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-name-stderr.txt
  31. 2 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-name.cmake
  32. 1 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-path-result.txt
  33. 6 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-path-stderr.txt
  34. 2 0
      Tests/RunCMake/include/CMP0148-Libs-NEW-path.cmake
  35. 7 0
      Tests/RunCMake/include/CMP0148-Libs-OLD.cmake
  36. 8 0
      Tests/RunCMake/include/CMP0148-Libs-WARN-stderr.txt
  37. 7 0
      Tests/RunCMake/include/CMP0148-Libs-WARN.cmake
  38. 9 0
      Tests/RunCMake/include/RunCMakeTest.cmake

+ 1 - 0
Help/manual/cmake-policies.7.rst

@@ -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 - 0
Help/policy/CMP0148.rst

@@ -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

+ 6 - 0
Help/release/dev/remove-FindPythonInterp-FindPythonLibs.rst

@@ -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`.

+ 13 - 0
Modules/FindPythonInterp.cmake

@@ -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)

+ 13 - 0
Modules/FindPythonLibs.cmake

@@ -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}")

+ 2 - 0
Source/cmFindPackageCommand.cxx

@@ -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;
 }
 

+ 2 - 0
Source/cmIncludeCommand.cxx

@@ -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;
   }
 

+ 3 - 0
Source/cmPolicies.h

@@ -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)

+ 4 - 0
Tests/RunCMake/find_package/CMP0148-Interp-NEW-stderr.txt

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Interp-NEW.cmake

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Interp-OLD.cmake

@@ -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()

+ 8 - 0
Tests/RunCMake/find_package/CMP0148-Interp-WARN-stderr.txt

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Interp-WARN.cmake

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Libs-NEW-stderr.txt

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Libs-NEW.cmake

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Libs-OLD.cmake

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Libs-WARN-stderr.txt

@@ -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 - 0
Tests/RunCMake/find_package/CMP0148-Libs-WARN.cmake

@@ -0,0 +1,6 @@
+set(_FindPythonLibs_testing TRUE)
+find_package(PythonLibs MODULE)
+
+if(NOT _FindPythonLibs_included)
+  message(FATAL_ERROR "FindPythonLibs.cmake not included")
+endif()

+ 6 - 0
Tests/RunCMake/find_package/RunCMakeTest.cmake

@@ -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)

+ 1 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-name-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-name-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-name.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0148 NEW)
+include(FindPythonInterp)

+ 1 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-path-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-path-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Interp-NEW-path.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0148 NEW)
+include(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)

+ 7 - 0
Tests/RunCMake/include/CMP0148-Interp-OLD.cmake

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Interp-WARN-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Interp-WARN.cmake

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-name-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-name-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-name.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0148 NEW)
+include(FindPythonLibs)

+ 1 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-path-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-path-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Libs-NEW-path.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0148 NEW)
+include(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)

+ 7 - 0
Tests/RunCMake/include/CMP0148-Libs-OLD.cmake

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Libs-WARN-stderr.txt

@@ -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 - 0
Tests/RunCMake/include/CMP0148-Libs-WARN.cmake

@@ -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()

+ 9 - 0
Tests/RunCMake/include/RunCMakeTest.cmake

@@ -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)