From 84e18056668491d5a7e0068c9287455151a18197 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 4 Jun 2015 23:38:51 +0200 Subject: cmMakefile: Convert recursion to loop. --- Source/cmMakefile.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ae69b24..36b42bd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4770,21 +4770,19 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const { - // Is the policy set in our stack? - for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin(); - psi != this->PolicyStack.rend(); ++psi) + cmLocalGenerator* lg = this->LocalGenerator; + while(lg) { - if(psi->IsDefined(id)) + cmMakefile const* mf = lg->GetMakefile(); + for(PolicyStackType::const_reverse_iterator psi = + mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) { - return psi->Get(id); + if(psi->IsDefined(id)) + { + return psi->Get(id); + } } - } - - // If we have a parent directory, recurse up to it. - if(this->LocalGenerator->GetParent()) - { - cmMakefile* parent = this->LocalGenerator->GetParent()->GetMakefile(); - return parent->GetPolicyStatusInternal(id); + lg = lg->GetParent(); } // The policy is not set. Use the default for this CMake version. -- cgit v0.12 From 71e69fc93b9f1a0829d04b9e44107c92458efe20 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 22 Jun 2015 03:18:55 +0200 Subject: cmPolicies: Store only state that users can set. cmPolicies::PolicyMap does not need to store the REQUIRED_ALWAYS or REQUIRED_IF_USED states as they are statically determined. --- Source/cmPolicies.cxx | 16 +--------------- Source/cmPolicies.h | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 5026893..2a5ae1c 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -356,14 +356,6 @@ cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const { status = cmPolicies::NEW; } - else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS]) - { - status = cmPolicies::REQUIRED_ALWAYS; - } - else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED]) - { - status = cmPolicies::REQUIRED_IF_USED; - } return status; } @@ -373,19 +365,13 @@ void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id, this->Status[(POLICY_STATUS_COUNT * id) + OLD] = (status == OLD); this->Status[(POLICY_STATUS_COUNT * id) + WARN] = (status == WARN); this->Status[(POLICY_STATUS_COUNT * id) + NEW] = (status == NEW); - this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS] = - (status == REQUIRED_ALWAYS); - this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED] = - (status == REQUIRED_IF_USED); } bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const { return this->Status[(POLICY_STATUS_COUNT * id) + OLD] || this->Status[(POLICY_STATUS_COUNT * id) + WARN] - || this->Status[(POLICY_STATUS_COUNT * id) + NEW] - || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS] - || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED]; + || this->Status[(POLICY_STATUS_COUNT * id) + NEW]; } bool cmPolicies::PolicyMap::IsEmpty() const diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 8a3c27d..a5aba58 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -244,7 +244,6 @@ public: REQUIRED_IF_USED, REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW. }; -#define POLICY_STATUS_COUNT 5 /// Policy identifiers enum PolicyID @@ -288,6 +287,7 @@ public: bool IsEmpty() const; private: +#define POLICY_STATUS_COUNT 3 std::bitset Status; }; }; -- cgit v0.12 From 3c45471c2d4a0c08b88f10161d4b166a27165e31 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jul 2015 01:55:29 +0200 Subject: cmPolicies: Enable RVO for internal method. --- Source/cmMakefile.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 36b42bd..cae7bbc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4770,6 +4770,7 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const { + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); cmLocalGenerator* lg = this->LocalGenerator; while(lg) { @@ -4779,14 +4780,15 @@ cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const { if(psi->IsDefined(id)) { - return psi->Get(id); + status = psi->Get(id); + return status; } } lg = lg->GetParent(); } // The policy is not set. Use the default for this CMake version. - return cmPolicies::GetPolicyStatus(id); + return status; } //---------------------------------------------------------------------------- -- cgit v0.12 From f4a25874a2cb5468e7ecce6812e5833e10943017 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jul 2015 02:00:32 +0200 Subject: cmMakefile: Inline internal policy status method. --- Source/cmMakefile.cxx | 47 ++++++++++++++++++----------------------------- Source/cmMakefile.h | 2 -- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cae7bbc..7a35a26 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4742,34 +4742,6 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - // Get the current setting of the policy. - cmPolicies::PolicyStatus cur = this->GetPolicyStatusInternal(id); - - // If the policy is required to be set to NEW but is not, ignore the - // current setting and tell the caller. - if(cur != cmPolicies::NEW) - { - if(cur == cmPolicies::REQUIRED_ALWAYS || - cur == cmPolicies::REQUIRED_IF_USED) - { - return cur; - } - cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id); - if(def == cmPolicies::REQUIRED_ALWAYS || - def == cmPolicies::REQUIRED_IF_USED) - { - return def; - } - } - - // The current setting is okay. - return cur; -} - -//---------------------------------------------------------------------------- -cmPolicies::PolicyStatus -cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const -{ cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); cmLocalGenerator* lg = this->LocalGenerator; while(lg) @@ -4787,7 +4759,24 @@ cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const lg = lg->GetParent(); } - // The policy is not set. Use the default for this CMake version. + // If the policy is required to be set to NEW but is not, ignore the + // current setting and tell the caller. + if(status != cmPolicies::NEW) + { + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id); + if(def == cmPolicies::REQUIRED_ALWAYS || + def == cmPolicies::REQUIRED_IF_USED) + { + return def; + } + } + + // The current setting is okay. return status; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 2fc4d78..6dbea89 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -938,8 +938,6 @@ private: typedef std::vector PolicyStackType; PolicyStackType PolicyStack; std::vector PolicyBarriers; - cmPolicies::PolicyStatus - GetPolicyStatusInternal(cmPolicies::PolicyID id) const; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( -- cgit v0.12 From 658bfc5c525bd21ecd68847cd19bda7102245c35 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jul 2015 02:02:02 +0200 Subject: cmMakefile: Remove redundant condition from policy status computation. --- Source/cmMakefile.cxx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7a35a26..ab8499f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4763,11 +4763,6 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const // current setting and tell the caller. if(status != cmPolicies::NEW) { - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id); if(def == cmPolicies::REQUIRED_ALWAYS || def == cmPolicies::REQUIRED_IF_USED) -- cgit v0.12 From d0dcce15f4cc4e7c100556fbd016c59f64d0d238 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jul 2015 02:04:12 +0200 Subject: cmMakefile: Simplify computation of ancient policy status. --- Source/cmMakefile.cxx | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ab8499f..d6854e7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4743,6 +4743,13 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + cmLocalGenerator* lg = this->LocalGenerator; while(lg) { @@ -4758,20 +4765,6 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const } lg = lg->GetParent(); } - - // If the policy is required to be set to NEW but is not, ignore the - // current setting and tell the caller. - if(status != cmPolicies::NEW) - { - cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id); - if(def == cmPolicies::REQUIRED_ALWAYS || - def == cmPolicies::REQUIRED_IF_USED) - { - return def; - } - } - - // The current setting is okay. return status; } -- cgit v0.12 From 5447ca1a94309fa394be3a8233090b33e81e4c9f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jul 2015 02:10:25 +0200 Subject: cmMakefile: Remove CMP0001 handling to callers. --- Source/cmCMakePolicyCommand.cxx | 16 ++++++++++++++++ Source/cmMakefile.cxx | 19 ------------------- Source/cmPolicies.cxx | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 3c878bf..3ef6d35 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -93,6 +93,22 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector const& args) this->SetError("SET failed to set policy."); return false; } + if(args[1] == "CMP0001" && + (status == cmPolicies::WARN || status == cmPolicies::OLD)) + { + if(!(this->Makefile->GetState() + ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) + { + // Set it to 2.4 because that is the last version where the + // variable had meaning. + this->Makefile->AddCacheDefinition + ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", + "For backwards compatibility, what version of CMake " + "commands and " + "syntax should this version of CMake try to support.", + cmState::STRING); + } + } return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d6854e7..c5ce2e9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4822,25 +4822,6 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, previous_was_weak = psi->Weak; } - // Special hook for presenting compatibility variable as soon as - // the user requests it. - if(id == cmPolicies::CMP0001 && - (status == cmPolicies::WARN || status == cmPolicies::OLD)) - { - if(!(this->GetState() - ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) - { - // Set it to 2.4 because that is the last version where the - // variable had meaning. - this->AddCacheDefinition - ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmState::STRING); - } - } - return true; } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 2a5ae1c..3eb19bb 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -255,6 +255,22 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, { return false; } + if(pid == cmPolicies::CMP0001 && + (status == cmPolicies::WARN || status == cmPolicies::OLD)) + { + if(!(mf->GetState() + ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) + { + // Set it to 2.4 because that is the last version where the + // variable had meaning. + mf->AddCacheDefinition + ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", + "For backwards compatibility, what version of CMake " + "commands and " + "syntax should this version of CMake try to support.", + cmState::STRING); + } + } } } else -- cgit v0.12 From 8329fc016fd0b6e82b9bc1da9e857206d11b9bbe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 14:45:45 +0200 Subject: cmPolicies: Replace unused include. --- Source/cmPolicies.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a5aba58..b783701 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -12,7 +12,7 @@ #ifndef cmPolicies_h #define cmPolicies_h -#include "cmCustomCommand.h" +#include "cmStandardIncludes.h" #include -- cgit v0.12