Add deprecation warnings for policies CMP0088 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.14 and below to encourage projects to port
away from setting policies to OLD.
This commit is contained in:
Brad King
2021-06-30 09:40:23 -04:00
parent 1a2c8407a7
commit d76cb12905
6 changed files with 47 additions and 4 deletions

View File

@@ -4426,13 +4426,12 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
return false; return false;
} }
// Deprecate old policies, especially those that require a lot // Deprecate old policies.
// of code to maintain the old behavior. if (status == cmPolicies::OLD && id <= cmPolicies::CMP0088 &&
if (status == cmPolicies::OLD && id <= cmPolicies::CMP0081 &&
!(this->GetCMakeInstance()->GetIsInTryCompile() && !(this->GetCMakeInstance()->GetIsInTryCompile() &&
( (
// Policies set by cmCoreTryCompile::TryCompileCode. // Policies set by cmCoreTryCompile::TryCompileCode.
id == cmPolicies::CMP0065))) { id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083))) {
this->IssueMessage(MessageType::DEPRECATION_WARNING, this->IssueMessage(MessageType::DEPRECATION_WARNING,
cmPolicies::GetPolicyDeprecatedWarning(id)); cmPolicies::GetPolicyDeprecatedWarning(id));
} }

View File

@@ -0,0 +1,8 @@
^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\):
The OLD behavior for policy CMP0085 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.$

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at CMP0086-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0086 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,8 @@
^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0082 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.$

View File

@@ -0,0 +1,10 @@
^CMake Deprecation Warning at CMP0084-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0084 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,8 @@
^CMake Deprecation Warning at CMP0087-OLD/CMakeLists.txt:5 \(cmake_policy\):
The OLD behavior for policy CMP0087 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.$