1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-20 12:53:55 +08:00

Add deprecation warnings for policies CMP0097 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.16 and below to encourage projects to port
away from setting policies to OLD.
This commit is contained in:
Brad King
2022-02-03 10:36:37 -05:00
parent 40107d308f
commit a9ffded98c
5 changed files with 41 additions and 5 deletions

View File

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

View File

@@ -444,7 +444,9 @@ if(do_git_tests)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
set(proj TS1-GIT-all-GIT_SUBMODULES-via-CMP0097-OLD)
set(CMAKE_WARN_DEPRECATED FALSE) # we are testing CMP0097 OLD behavior
cmake_policy(SET CMP0097 OLD)
unset(CMAKE_WARN_DEPRECATED)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_SUBMODULES ""

View File

@@ -1,3 +1,15 @@
^CMake Deprecation Warning at TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0095 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\):
TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(A_CMP0095\)
CMakeLists.txt:[0-9]+ \(include\)(
+
CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
Policy CMP0095 is not set: RPATH entries are properly escaped in the
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
@@ -8,8 +20,8 @@ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(ins
intermediary cmake_install\.cmake script\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.
This warning is for project developers\. Use -Wno-dev to suppress it\.)+(
+
CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
Policy CMP0095 is not set: RPATH entries are properly escaped in the
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
@@ -20,4 +32,4 @@ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(ins
intermediary cmake_install\.cmake script\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.
This warning is for project developers\. Use -Wno-dev to suppress it\.)+$

View File

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