CMP0011: Remove support for OLD behavior
This commit is contained in:
parent
cf832e75bc
commit
3c0dbb66f5
@ -1,6 +1,9 @@
|
||||
CMP0011
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
Included scripts do automatic :command:`cmake_policy` PUSH and POP.
|
||||
|
||||
In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by
|
||||
@ -19,7 +22,5 @@ The ``NEW`` behavior for this policy is to allow the commands to do
|
||||
their default cmake_policy ``PUSH`` and ``POP``.
|
||||
|
||||
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.3
|
||||
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
|
||||
.. include:: STANDARD_ADVICE.txt
|
||||
|
||||
.. include:: DEPRECATED.txt
|
||||
.. |WARNED_OR_DID_NOT_WARN| replace:: warned
|
||||
.. include:: REMOVED_EPILOGUE.txt
|
||||
|
@ -2789,8 +2789,8 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
|
||||
this->VersionRangeMax);
|
||||
}
|
||||
|
||||
// Load the version check file. Pass NoPolicyScope because we do
|
||||
// our own policy push/pop independent of CMP0011.
|
||||
// Load the version check file.
|
||||
// Pass NoPolicyScope because we do our own policy push/pop.
|
||||
bool suitable = false;
|
||||
if (this->ReadListFile(version_file, NoPolicyScope)) {
|
||||
// Check the output variables.
|
||||
|
@ -601,9 +601,7 @@ public:
|
||||
private:
|
||||
cmMakefile* Makefile;
|
||||
bool NoPolicyScope;
|
||||
bool CheckCMP0011 = false;
|
||||
bool ReportError = true;
|
||||
void EnforceCMP0011();
|
||||
};
|
||||
|
||||
cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
|
||||
@ -621,48 +619,15 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
|
||||
this->Makefile->GetState()->CreateIncludeFileSnapshot(
|
||||
this->Makefile->StateSnapshot, filenametoread);
|
||||
if (!this->NoPolicyScope) {
|
||||
// Check CMP0011 to determine the policy scope type.
|
||||
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
|
||||
case cmPolicies::WARN:
|
||||
// We need to push a scope to detect whether the script sets
|
||||
// any policies that would affect the includer and therefore
|
||||
// requires a warning. We use a weak scope to simulate OLD
|
||||
// behavior by allowing policy changes to affect the includer.
|
||||
this->Makefile->PushPolicy(true);
|
||||
this->CheckCMP0011 = true;
|
||||
break;
|
||||
case cmPolicies::OLD:
|
||||
// OLD behavior is to not push a scope at all.
|
||||
this->NoPolicyScope = true;
|
||||
break;
|
||||
case cmPolicies::NEW:
|
||||
// NEW behavior is to push a (strong) scope.
|
||||
this->Makefile->PushPolicy();
|
||||
break;
|
||||
}
|
||||
this->Makefile->PushPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
cmMakefile::IncludeScope::~IncludeScope()
|
||||
{
|
||||
if (!this->NoPolicyScope) {
|
||||
// If we need to enforce policy CMP0011 then the top entry is the
|
||||
// one we pushed above. If the entry is empty, then the included
|
||||
// script did not set any policies that might affect the includer so
|
||||
// we do not need to enforce the policy.
|
||||
if (this->CheckCMP0011 &&
|
||||
!this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) {
|
||||
this->CheckCMP0011 = false;
|
||||
}
|
||||
|
||||
// Pop the scope we pushed for the script.
|
||||
this->Makefile->PopPolicy();
|
||||
|
||||
// We enforce the policy after the script's policy stack entry has
|
||||
// been removed.
|
||||
if (this->CheckCMP0011) {
|
||||
this->EnforceCMP0011();
|
||||
}
|
||||
}
|
||||
this->Makefile->PopSnapshot(this->ReportError);
|
||||
|
||||
@ -671,36 +636,6 @@ cmMakefile::IncludeScope::~IncludeScope()
|
||||
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
|
||||
}
|
||||
|
||||
void cmMakefile::IncludeScope::EnforceCMP0011()
|
||||
{
|
||||
// We check the setting of this policy again because the included
|
||||
// script might actually set this policy for its includer.
|
||||
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
|
||||
case cmPolicies::WARN:
|
||||
// Warn because the user did not set this policy.
|
||||
{
|
||||
auto e = cmStrCat(
|
||||
cmPolicies::GetPolicyWarning(cmPolicies::CMP0011),
|
||||
"\n"
|
||||
"The included script\n"
|
||||
" ",
|
||||
this->Makefile->GetBacktrace().Top().FilePath,
|
||||
"\n"
|
||||
"affects policy settings. "
|
||||
"CMake is implying the NO_POLICY_SCOPE option for compatibility, "
|
||||
"so the effects are applied to the including context.");
|
||||
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e);
|
||||
}
|
||||
break;
|
||||
case cmPolicies::OLD:
|
||||
case cmPolicies::NEW:
|
||||
// The script set this policy. We assume the purpose of the
|
||||
// script is to initialize policies for its includer, and since
|
||||
// the policy is now set for later scripts, we do not warn.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool cmMakefile::ReadDependentFile(const std::string& filename,
|
||||
bool noPolicyScope)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ class cmMakefile;
|
||||
3, NEW) \
|
||||
SELECT(POLICY, CMP0011, \
|
||||
"Included scripts do automatic cmake_policy PUSH and POP.", 2, 6, 3, \
|
||||
WARN) \
|
||||
NEW) \
|
||||
SELECT(POLICY, CMP0012, "if() recognizes numbers and boolean constants.", \
|
||||
2, 8, 0, WARN) \
|
||||
SELECT(POLICY, CMP0013, "Duplicate binary directories are not allowed.", 2, \
|
||||
|
@ -200,11 +200,6 @@ cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id,
|
||||
return status;
|
||||
}
|
||||
|
||||
bool cmStateSnapshot::HasDefinedPolicyCMP0011()
|
||||
{
|
||||
return !this->Position->Policies->IsEmpty();
|
||||
}
|
||||
|
||||
cmValue cmStateSnapshot::GetDefinition(std::string const& name) const
|
||||
{
|
||||
assert(this->Position->Vars.IsValid());
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
|
||||
cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id,
|
||||
bool parent_scope = false) const;
|
||||
bool HasDefinedPolicyCMP0011();
|
||||
void PushPolicy(cmPolicies::PolicyMap const& entry, bool weak);
|
||||
bool PopPolicy();
|
||||
bool CanPopPolicyScope();
|
||||
|
@ -10,28 +10,13 @@ function(check msg lhs rhs)
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Test using a development framework that sets policies for us.
|
||||
|
||||
cmake_policy(SET CMP0011 OLD)
|
||||
|
||||
# Put the test modules in the search path.
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# The included file should set policies for us.
|
||||
find_package(Foo)
|
||||
|
||||
# Check policies set by the package.
|
||||
cmake_policy(GET CMP0180 cmp)
|
||||
check(CMP0180 "OLD" "${cmp}")
|
||||
cmake_policy(GET CMP0179 cmp)
|
||||
check(CMP0179 "NEW" "${cmp}")
|
||||
cmake_policy(GET CMP0011 cmp)
|
||||
check(CMP0011 "NEW" "${cmp}")
|
||||
|
||||
# Make sure an included file cannot change policies.
|
||||
include(Bar)
|
||||
cmake_policy(GET CMP0180 cmp)
|
||||
check(CMP0180 "OLD" "${cmp}")
|
||||
check(CMP0180 "" "${cmp}")
|
||||
|
||||
# Allow the included file to change policies.
|
||||
include(Bar NO_POLICY_SCOPE)
|
||||
|
@ -1,2 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.31)
|
||||
cmake_policy(SET CMP0180 OLD)
|
@ -25,7 +25,6 @@ set (GENERATE_CONTENT "if (\"${CMAKE_TAPI}\")
|
||||
endif()\n\n")
|
||||
|
||||
string (APPEND GENERATE_CONTENT [[
|
||||
cmake_policy (SET CMP0011 NEW)
|
||||
cmake_policy (SET CMP0057 NEW)
|
||||
|
||||
macro (CHECK_FILE test_msg path)
|
||||
|
@ -1,5 +1,3 @@
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
|
||||
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupFileSet.vcxproj.filters")
|
||||
if(NOT EXISTS "${vcFiltersFile}")
|
||||
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
|
||||
|
@ -1,5 +1,3 @@
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
|
||||
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupTree.vcxproj.filters")
|
||||
if(NOT EXISTS "${vcFiltersFile}")
|
||||
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
|
||||
|
Loading…
Reference in New Issue
Block a user