Add deprecation warnings for policies CMP0126 and below

The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for policies
introduced in CMake 3.21 and below to encourage projects to port
away from setting policies to OLD.
This commit is contained in:
Brad King
2023-10-03 12:09:23 -04:00
parent 4459d25c4a
commit 86d910ab73
12 changed files with 97 additions and 5 deletions

View File

@@ -4630,12 +4630,13 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
}
// Deprecate old policies.
if (status == cmPolicies::OLD && id <= cmPolicies::CMP0120 &&
if (status == cmPolicies::OLD && id <= cmPolicies::CMP0126 &&
!(this->GetCMakeInstance()->GetIsInTryCompile() &&
(
// Policies set by cmCoreTryCompile::TryCompileCode.
id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 ||
id == cmPolicies::CMP0091 || id == cmPolicies::CMP0104)) &&
id == cmPolicies::CMP0091 || id == cmPolicies::CMP0104 ||
id == cmPolicies::CMP0123 || id == cmPolicies::CMP0126)) &&
(!this->IsSet("CMAKE_WARN_DEPRECATED") ||
this->IsOn("CMAKE_WARN_DEPRECATED"))) {
this->IssueMessage(MessageType::DEPRECATION_WARNING,

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at CMP0126-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0126 will be removed from a future version
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\)$

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at CMP0126-OLD_CL\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0126 will be removed from a future version
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\)$

View File

@@ -1 +1,12 @@
^try_compile CMP0126='OLD' VAR='2'
^CMake Deprecation Warning at CMP0126-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0126 will be removed from a future version
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\)
+
try_compile CMP0126='OLD' VAR='2'

View File

@@ -1,5 +1,5 @@
cmake_policy(VERSION 3.1)
cmake_policy(VERSION 3.5)
file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CMP0122-library-name.txt" prefixes)

View File

@@ -1,5 +1,5 @@
cmake_policy(VERSION 3.1)
cmake_policy(VERSION 3.5)
file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CMP0122-library-name.txt" prefixes)

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at CMP0122-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0122 will be removed from a future version
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\)$

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at NO_CACHE\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0125 will be removed from a future version
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\)

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at NO_CACHE\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0125 will be removed from a future version
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\)

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at NO_CACHE\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0125 will be removed from a future version
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\)

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at NO_CACHE\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0125 will be removed from a future version
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\)

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at foreach-var-scope-CMP0124-OLD\.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0124 will be removed from a future version
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\)$