From 43944645019a8241485950384e3e9dba48a27347 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Jun 2024 13:19:07 -0400 Subject: Add deprecation warnings for policies CMP0129 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.23 and below to encourage projects to port away from setting policies to OLD. --- Source/cmMakefile.cxx | 2 +- Tests/RunCMake/CMP0129/C-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt | 10 ++++++++++ Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt | 10 ++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CMP0129/C-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ba9fab5..b8a59a3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4657,7 +4657,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, } // Deprecate old policies. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0128 && + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0129 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. diff --git a/Tests/RunCMake/CMP0129/C-OLD-stderr.txt b/Tests/RunCMake/CMP0129/C-OLD-stderr.txt new file mode 100644 index 0000000..5c622d2 --- /dev/null +++ b/Tests/RunCMake/CMP0129/C-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at C-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 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\)$ diff --git a/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt b/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt new file mode 100644 index 0000000..71a1ecf --- /dev/null +++ b/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CXX-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 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\)$ diff --git a/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt b/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt new file mode 100644 index 0000000..01260c0 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Fortran-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 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\)$ -- cgit v0.12