Deprecate compatibility with CMake versions older than 3.5

Issue a deprecation warning on calls to `cmake_minimum_required` or
`cmake_policy` that set policies based on versions older than 3.5.
Note that the effective policy version includes `...<max>` treatment.
Update the check from commit 5845c218d7 (Deprecate compatibility with
CMake versions older than 2.8.12, 2020-06-12, v3.19.0-rc1~629^2).
This commit is contained in:
Brad King
2023-02-09 09:35:22 -05:00
parent 1edf138506
commit 3a4791548d
52 changed files with 207 additions and 69 deletions

View File

@@ -0,0 +1,7 @@
deprecate-policy-old
--------------------
* Compatibility with versions of CMake older than 3.5 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

@@ -259,8 +259,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
{
// Warn about policy versions for which support will be removed.
if (warnCompat == WarnCompat::On &&
(majorVer < 2 || (majorVer == 2 && minorVer < 8) ||
(majorVer == 2 && minorVer == 8 && patchVer < 12)) &&
(majorVer < 3 || (majorVer == 3 && minorVer < 5)) &&
// Avoid warning on calls generated by install(EXPORT)
// in CMake versions prior to 3.18.
!(majorVer == 2 && minorVer == 6 && patchVer == 0 &&
@@ -269,7 +268,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
"cmake_policy") == 0)) {
mf->IssueMessage(
MessageType::DEPRECATION_WARNING,
"Compatibility with CMake < 2.8.12 will be removed from "
"Compatibility with CMake < 3.5 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(CMP0026-WARN)
run_cmake(CMP0026-OLD)

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
if(RunCMake_GENERATOR MATCHES "^Ninja")
# Detect ninja version so we know what tests can be supported.

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
# Protect tests from running inside the default install prefix.
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefaultPrefix")

View File

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

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(CMP0055-OLD-Out-of-Scope)
run_cmake(CMP0055-NEW-Out-of-Scope)

View File

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

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
function(run_cmake_CMP0060 CASE)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0060-${CASE}-build)

View File

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

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(OLDBad1)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX")

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
foreach(p
CMP0029

View File

@@ -1,3 +1,10 @@
^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(BadIF)
run_cmake(BadCONFIG)

View File

@@ -1,6 +1,13 @@
^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\):
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMakeLists.txt:[0-9]+ \(cmake_minimum_required\):
The OLD behavior for policy CMP0052 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,6 +1,13 @@
^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\):
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
The OLD behavior for policy CMP0052 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,6 +1,13 @@
^CMake Deprecation Warning at CMP0028-OLD-iface.cmake:[0-9]+ \(cmake_policy\):
^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMP0028-OLD-iface\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0028 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,6 +1,13 @@
^CMake Deprecation Warning at CMP0028-OLD.cmake:[0-9]+ \(cmake_policy\):
^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMP0028-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0028 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,6 +1,15 @@
^CMake Deprecation Warning at CMP0058-OLD-by.cmake:[0-9]+ \(cmake_policy\):
^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
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\.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9] \(include\)
+
CMake Deprecation Warning at CMP0058-OLD-by\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0058 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,6 +1,15 @@
^CMake Deprecation Warning at CMP0058-OLD-no.cmake:[0-9]+ \(cmake_policy\):
^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
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\.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9] \(include\)
+
CMake Deprecation Warning at CMP0058-OLD-no\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0058 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -0,0 +1,8 @@
^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
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\.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9] \(include\)$

View File

@@ -1,4 +1,13 @@
^CMake Warning \(dev\):
^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
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\.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9] \(include\)
+
CMake Warning \(dev\):
Policy CMP0058 is not set: Ninja requires custom command byproducts to be
explicit. Run "cmake --help-policy CMP0058" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(NotClosed)
run_cmake(NotOpened)

View File

@@ -190,7 +190,7 @@ function(run_cmake test)
string(REGEX REPLACE [[
^CMake Deprecation Warning at [^
]*CMakeLists.txt:1 \(cmake_minimum_required\):
Compatibility with CMake < 2\.8\.12 will be removed from a future version of
Compatibility with CMake < 3\.5 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,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(BOM-UTF-8)
run_cmake(BOM-UTF-16-LE)

View File

@@ -1,3 +1,3 @@
^
^'
1 \${var} 4
$
'$

View File

@@ -1,3 +1,3 @@
message("
message("'
1 \${var} 4
")
'")

View File

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

View File

@@ -1,26 +0,0 @@
^CMake Deprecation Warning at Before2812.cmake:1 \(cmake_minimum_required\):
Compatibility with CMake < 2.8.12 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.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Deprecation Warning at Before2812.cmake:2 \(cmake_policy\):
Compatibility with CMake < 2.8.12 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.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Deprecation Warning at Before2812.cmake:6 \(cmake_policy\):
Compatibility with CMake < 2.8.12 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.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@@ -0,0 +1,26 @@
^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\.
Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
CMake that the project does not need compatibility with older versions\.
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\.
Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
CMake that the project does not need compatibility with older versions\.
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\.
Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
CMake that the project does not need compatibility with older versions\.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$

View File

@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.5)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)

View File

@@ -1,9 +1,9 @@
^CMake Deprecation Warning at CompatBefore24.cmake:1 \(cmake_minimum_required\):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
^CMake Deprecation Warning at CompatBefore24\.cmake:1 \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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.
Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
CMake that the project does not need compatibility with older versions\.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+

View File

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

View File

@@ -1,2 +1,9 @@
^(Error\(s\) when building project
^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
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\.
+(Error\(s\) when building project
)?ctest_build returned zero$

View File

@@ -1,10 +1,19 @@
^CMake Deprecation Warning at CMP0062-OLD.cmake:[0-9]+ \(cmake_policy\):
^CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\):
Compatibility with CMake < 3\.5 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\.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Deprecation Warning at CMP0062-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0062 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$
CMakeLists.txt:[0-9]+ \(include\)

View File

@@ -1,13 +1,13 @@
^CMake Deprecation Warning at GET-CMP0007-WARN.cmake:1 \(cmake_policy\):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
^CMake Deprecation Warning at GET-CMP0007-WARN\.cmake:1 \(cmake_policy\):
Compatibility with CMake < 3\.5 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.
Update the VERSION argument <min> value or use a \.\.\.<max> suffix to tell
CMake that the project does not need compatibility with older versions\.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Warning \(dev\) at GET-CMP0007-WARN.cmake:4 \(list\):
CMake Warning \(dev\) at GET-CMP0007-WARN\.cmake:4 \(list\):
Policy CMP0007 is not set: list command no longer ignores empty elements.
Run "cmake --help-policy CMP0007" for policy details. Use the cmake_policy
command to set the policy and suppress this warning. List has value =

View File

@@ -0,0 +1,6 @@
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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\.$

View File

@@ -1,6 +1,13 @@
^CMake Deprecation Warning at CMP0048-OLD.cmake:1 \(cmake_policy\):
^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\):
Compatibility with CMake < 3\.5 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 CMP0048-OLD\.cmake:1 \(cmake_policy\):
The OLD behavior for policy CMP0048 will be removed from a future version
of CMake.
of CMake\.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under

View File

@@ -1,4 +1,4 @@
^CMake Warning \(dev\) in CMakeLists.txt:
^CMake Warning \(dev\) in CMakeLists\.txt:
No project\(\) command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project\(\) command. Add a line of
code such as
@@ -8,5 +8,12 @@
near the top of the file, but after cmake_minimum_required\(\).
CMake is pretending there is a "project\(Project\)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.$
line\.
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
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\.$

View File

@@ -1,4 +1,5 @@
include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)