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).
This commit is contained in:
Brad King 2024-10-03 11:16:42 -04:00
parent 9e3b559b6a
commit 84db8506ff
35 changed files with 82 additions and 37 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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