diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 4b6ea5c4d..3f9c6f0ca 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -408,6 +408,36 @@ void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, this->PolicyStringMap[idString] = iD; } +//---------------------------------------------------------------------------- +static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, + cmPolicies::PolicyStatus* defaultSetting) +{ + std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; + std::string defaultValue = mf->GetSafeDefinition(defaultVar); + if(defaultValue == "NEW") + { + *defaultSetting = cmPolicies::NEW; + } + else if(defaultValue == "OLD") + { + *defaultSetting = cmPolicies::OLD; + } + else if(defaultValue == "") + { + *defaultSetting = cmPolicies::WARN; + } + else + { + std::ostringstream e; + e << defaultVar << " has value \"" << defaultValue + << "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + + return true; +} + //---------------------------------------------------------------------------- bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, const char *version) @@ -482,7 +512,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, else { cmPolicies::PolicyStatus status = cmPolicies::WARN; - if(!this->GetPolicyDefault(mf, i->second->IDString, &status) || + if(!GetPolicyDefault(mf, i->second->IDString, &status) || !mf->SetPolicy(i->second->ID, status)) { return false; @@ -510,36 +540,6 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, return true; } -//---------------------------------------------------------------------------- -bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, - cmPolicies::PolicyStatus* defaultSetting) -{ - std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; - std::string defaultValue = mf->GetSafeDefinition(defaultVar); - if(defaultValue == "NEW") - { - *defaultSetting = cmPolicies::NEW; - } - else if(defaultValue == "OLD") - { - *defaultSetting = cmPolicies::OLD; - } - else if(defaultValue == "") - { - *defaultSetting = cmPolicies::WARN; - } - else - { - std::ostringstream e; - e << defaultVar << " has value \"" << defaultValue - << "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - - return true; -} - bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) { if (!id || strlen(id) < 1) diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index ba8a1201a..9de0298d3 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -164,10 +164,6 @@ public: void DiagnoseAncientPolicies(std::vector const& ancient, unsigned int majorVer, unsigned int minorVer, unsigned int patchVer, cmMakefile* mf); - - bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, - cmPolicies::PolicyStatus* defaultStatus); - }; #endif