1
0
Эх сурвалжийг харах

Add deprecation warnings for policies CMP0094 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.15 and below to encourage projects to port
away from setting policies to OLD.
Brad King 4 жил өмнө
parent
commit
0f31463c37

+ 3 - 2
Source/cmMakefile.cxx

@@ -4427,11 +4427,12 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
   }
 
   // Deprecate old policies.
-  if (status == cmPolicies::OLD && id <= cmPolicies::CMP0088 &&
+  if (status == cmPolicies::OLD && id <= cmPolicies::CMP0094 &&
       !(this->GetCMakeInstance()->GetIsInTryCompile() &&
         (
           // Policies set by cmCoreTryCompile::TryCompileCode.
-          id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083))) {
+          id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 ||
+          id == cmPolicies::CMP0091))) {
     this->IssueMessage(MessageType::DEPRECATION_WARNING,
                        cmPolicies::GetPolicyDeprecatedWarning(id));
   }

+ 10 - 0
Tests/RunCMake/FindBoost/CMP0093-OLD-stderr.txt

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

+ 10 - 0
Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD-stderr.txt

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

+ 10 - 0
Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD-stderr.txt

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