Kaynağa Gözat

Deprecate compatibility with CMake versions older than 3.10

Issue a deprecation warning on calls to `cmake_minimum_required` or
`cmake_policy` that set policies based on versions older than 3.10.
Note that the effective policy version includes `...<max>` treatment.
Update the check from commit 3a4791548d (Deprecate compatibility with
CMake versions older than 3.5, 2023-02-09, v3.27.0-rc1~508^2).
Brad King 1 yıl önce
ebeveyn
işleme
84db8506ff
35 değiştirilmiş dosya ile 82 ekleme ve 37 silme
  1. 8 0
      Help/command/DEPRECATED_POLICY_VERSIONS.txt
  2. 7 0
      Help/release/dev/deprecate-pre-3.10.rst
  3. 2 2
      Source/cmPolicies.cxx
  4. 1 0
      Tests/RunCMake/CMP0068/RunCMakeTest.cmake
  5. 1 0
      Tests/RunCMake/CMP0069/RunCMakeTest.cmake
  6. 8 1
      Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt
  7. 8 1
      Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt
  8. 8 1
      Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt
  9. 1 1
      Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt
  10. 1 1
      Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt
  11. 1 1
      Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
  12. 1 1
      Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt
  13. 1 1
      Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt
  14. 1 1
      Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt
  15. 1 1
      Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt
  16. 1 1
      Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt
  17. 1 1
      Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt
  18. 1 1
      Tests/RunCMake/RunCMake.cmake
  19. 1 1
      Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt
  20. 1 1
      Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt
  21. 1 1
      Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt
  22. 1 1
      Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt
  23. 1 1
      Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt
  24. 6 6
      Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt
  25. 2 2
      Tests/RunCMake/cmake_minimum_required/Before3_10.cmake
  26. 1 1
      Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt
  27. 1 1
      Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake
  28. 1 1
      Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt
  29. 1 1
      Tests/RunCMake/include/CMP0024-WARN-stderr.txt
  30. 1 1
      Tests/RunCMake/install/CMP0062-OLD-stderr.txt
  31. 1 1
      Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt
  32. 1 1
      Tests/RunCMake/project/CMP0048-NEW-stderr.txt
  33. 1 1
      Tests/RunCMake/project/CMP0048-OLD-stderr.txt
  34. 1 1
      Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt
  35. 7 0
      Tests/RunCMake/try_compile/CMP0066-stderr.txt

+ 8 - 0
Help/command/DEPRECATED_POLICY_VERSIONS.txt

@@ -1,3 +1,11 @@
+.. versionchanged:: 3.31
+
+  Compatibility with versions of CMake older than 3.10 is deprecated.
+  Calls to :command:`cmake_minimum_required(VERSION)` or
+  :command:`cmake_policy(VERSION)` that do not specify at least
+  3.10 as their policy version (optionally via ``...<max>``)
+  will produce a deprecation warning in CMake 3.31 and above.
+
 .. versionchanged:: 3.27
 
   Compatibility with versions of CMake older than 3.5 is deprecated.

+ 7 - 0
Help/release/dev/deprecate-pre-3.10.rst

@@ -0,0 +1,7 @@
+deprecate-pre-3.10
+------------------
+
+* Compatibility with versions of CMake older than 3.10 is now deprecated
+  and will be removed from a future version.  Calls to
+  :command:`cmake_minimum_required` or :command:`cmake_policy` that set
+  the policy version to an older value now issue a deprecation diagnostic.

+ 2 - 2
Source/cmPolicies.cxx

@@ -261,7 +261,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
 {
   // Warn about policy versions for which support will be removed.
   if (warnCompat == WarnCompat::On &&
-      (majorVer < 3 || (majorVer == 3 && minorVer < 5)) &&
+      (majorVer < 3 || (majorVer == 3 && minorVer < 10)) &&
       // Avoid warning on calls generated by install(EXPORT)
       // in CMake versions prior to 3.18.
       !(majorVer == 2 && minorVer == 6 && patchVer == 0 &&
@@ -270,7 +270,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
                                "cmake_policy") == 0)) {
     mf->IssueMessage(
       MessageType::DEPRECATION_WARNING,
-      "Compatibility with CMake < 3.5 will be removed from "
+      "Compatibility with CMake < 3.10 will be removed from "
       "a future version of CMake.\n"
       "Update the VERSION argument <min> value or use a ...<max> suffix "
       "to tell CMake that the project does not need compatibility with "

+ 1 - 0
Tests/RunCMake/CMP0068/RunCMakeTest.cmake

@@ -1,4 +1,5 @@
 include(RunCMake)
+set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
 run_cmake(CMP0068-OLD)
 run_cmake(CMP0068-NEW)

+ 1 - 0
Tests/RunCMake/CMP0069/RunCMakeTest.cmake

@@ -1,4 +1,5 @@
 include(RunCMake)
+set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
 run_cmake(CMP0069-OLD)
 run_cmake(CMP0069-NEW-cmake)

+ 8 - 1
Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt

@@ -1,4 +1,11 @@
-^CMake Deprecation Warning at CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\):
+^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
+  CMake\.
+
+  Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
+  CMake that the project does not need compatibility with older versions\.
++
+CMake Deprecation Warning at CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\):
   The OLD behavior for policy CMP0070 will be removed from a future version
   of CMake.
 

+ 8 - 1
Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt

@@ -1,4 +1,11 @@
-^(CMake Warning \(dev\) in CMakeLists.txt:
+^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
+  CMake\.
+
+  Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
+  CMake that the project does not need compatibility with older versions\.
++
+(CMake Warning \(dev\) in CMakeLists.txt:
   Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative
   paths.  Run "cmake --help-policy CMP0070" for policy details.  Use the
   cmake_policy command to set the policy and suppress this warning.

+ 8 - 1
Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt

@@ -1,4 +1,11 @@
-^CMake Deprecation Warning at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\):
+^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
+  CMake\.
+
+  Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
+  CMake that the project does not need compatibility with older versions\.
++
+CMake Deprecation Warning at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\):
   The OLD behavior for policy CMP0070 will be removed from a future version
   of CMake.
 

+ 1 - 1
Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0058-OLD-by\.cmake:[0-9] \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0058-OLD-no\.cmake:[0-9] \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0058-WARN-by\.cmake:[0-9] \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0058-WARN-no\.cmake:[0-9] \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/RunCMake.cmake

@@ -224,7 +224,7 @@ function(run_cmake test)
     string(REGEX REPLACE [[
 ^CMake Deprecation Warning at [^
 ]*CMakeLists.txt:1 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 6 - 6
Tests/RunCMake/cmake_minimum_required/Before3_5-stderr.txt → Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt

@@ -1,5 +1,5 @@
-^CMake Deprecation Warning at Before3_5\.cmake:1 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+^CMake Deprecation Warning at Before3_10\.cmake:1 \(cmake_minimum_required\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
@@ -7,8 +7,8 @@
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
-CMake Deprecation Warning at Before3_5\.cmake:2 \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+CMake Deprecation Warning at Before3_10\.cmake:2 \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
@@ -16,8 +16,8 @@ CMake Deprecation Warning at Before3_5\.cmake:2 \(cmake_policy\):
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
-CMake Deprecation Warning at Before3_5\.cmake:6 \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+CMake Deprecation Warning at Before3_10\.cmake:6 \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 2 - 2
Tests/RunCMake/cmake_minimum_required/Before3_5.cmake → Tests/RunCMake/cmake_minimum_required/Before3_10.cmake

@@ -1,6 +1,6 @@
-cmake_minimum_required(VERSION 2.8.11)
+cmake_minimum_required(VERSION 3.9)
 cmake_policy(VERSION 2.6)
 cmake_policy(PUSH)
 cmake_policy(VERSION 2.6) # simulate pre-3.18 install(EXPORT)-generated call
 cmake_policy(POP)
-cmake_policy(VERSION 2.8.11)
+cmake_policy(VERSION 3.9)

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CompatBefore24\.cmake:1 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake

@@ -4,7 +4,7 @@ run_cmake(Before24)
 run_cmake(CompatBefore24)
 run_cmake(Future)
 run_cmake(PolicyBefore24)
-run_cmake(Before3_5)
+run_cmake(Before3_10)
 run_cmake(Range)
 run_cmake(RangeBad)
 run_cmake(Unknown)

+ 1 - 1
Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt

@@ -1,6 +1,6 @@
 ^CMake Deprecation Warning at [^
 ]*/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD/test\.cmake:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/include/CMP0024-WARN-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0024-WARN\.cmake:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/install/CMP0062-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at GET-CMP0007-WARN\.cmake:1 \(cmake_policy\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/project/CMP0048-NEW-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/project/CMP0048-OLD-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 1 - 1
Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt

@@ -12,7 +12,7 @@
 This warning is for project developers.  Use -Wno-dev to suppress it\.
 +
 CMake Deprecation Warning at CMakeLists\.txt:1 \(cmake_minimum_required\):
-  Compatibility with CMake < 3\.5 will be removed from a future version of
+  Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
   Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell

+ 7 - 0
Tests/RunCMake/try_compile/CMP0066-stderr.txt

@@ -1,3 +1,10 @@
+^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
+  Compatibility with CMake < 3\.10 will be removed from a future version of
+  CMake\.
+
+  Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
+  CMake that the project does not need compatibility with older versions\.
++
 before try_compile with CMP0066 WARN-default
 after try_compile with CMP0066 WARN-default
 *