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:
@@ -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));
|
||||
}
|
||||
|
@@ -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 ""
|
||||
|
@@ -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\.)+$
|
||||
|
10
Tests/RunCMake/project/CMP0096-OLD-stderr.txt
Normal file
10
Tests/RunCMake/project/CMP0096-OLD-stderr.txt
Normal 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\)$
|
10
Tests/RunCMake/project/VersionMax-stderr.txt
Normal file
10
Tests/RunCMake/project/VersionMax-stderr.txt
Normal 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\)$
|
Reference in New Issue
Block a user