Add deprecation warnings for policies CMP0128 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.22 and below to encourage projects to port
away from setting policies to OLD.
This commit is contained in:
Brad King
2024-02-06 16:49:14 -05:00
parent b18165c2c6
commit 9c5e981e60
4 changed files with 34 additions and 2 deletions

View File

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