diff options
author | Brad King <brad.king@kitware.com> | 2011-01-04 13:04:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-01-04 13:04:29 (GMT) |
commit | 1e69c6f37fa4a3a1a0c2f8fa665ad07a78fed580 (patch) | |
tree | 603dd3dae8a1a56497a22979f7236be01e5a7d10 /Source/cmPolicies.cxx | |
parent | 65a0a2a5f94cf23413937ba9178abeb3c0f057e4 (diff) | |
parent | a364daf1fd1fd9079fdc13bec4fe8ea2a56efe04 (diff) | |
download | CMake-1e69c6f37fa4a3a1a0c2f8fa665ad07a78fed580.zip CMake-1e69c6f37fa4a3a1a0c2f8fa665ad07a78fed580.tar.gz CMake-1e69c6f37fa4a3a1a0c2f8fa665ad07a78fed580.tar.bz2 |
Merge branch 'user-policy-defaults' into policy-CMP0017
Diffstat (limited to 'Source/cmPolicies.cxx')
-rw-r--r-- | Source/cmPolicies.cxx | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 3fe92de..fccf0cc 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -495,9 +495,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, std::string ver = "2.4.0"; if (version && strlen(version) > 0) - { + { ver = version; - } + } unsigned int majorVer = 2; unsigned int minorVer = 0; @@ -556,29 +556,33 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, // now loop over all the policies and set them as appropriate std::vector<cmPolicies::PolicyID> ancientPolicies; - std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i - = this->Policies.begin(); - for (;i != this->Policies.end(); ++i) - { - if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer,tweakVer)) + for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i + = this->Policies.begin(); i != this->Policies.end(); ++i) { - if(i->second->Status == cmPolicies::REQUIRED_ALWAYS) + if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer,tweakVer)) { + if(i->second->Status == cmPolicies::REQUIRED_ALWAYS) + { ancientPolicies.push_back(i->first); + } + else + { + cmPolicies::PolicyStatus status = cmPolicies::WARN; + if(!this->GetPolicyDefault(mf, i->second->IDString, &status) || + !mf->SetPolicy(i->second->ID, status)) + { + return false; + } + } } - else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN)) - { - return false; - } - } else - { - if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW)) { + if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW)) + { return false; + } } } - } // Make sure the project does not use any ancient policies. if(!ancientPolicies.empty()) @@ -592,6 +596,36 @@ 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.c_str()); + if(defaultValue == "NEW") + { + *defaultSetting = cmPolicies::NEW; + } + else if(defaultValue == "OLD") + { + *defaultSetting = cmPolicies::OLD; + } + else if(defaultValue == "") + { + *defaultSetting = cmPolicies::WARN; + } + else + { + cmOStringStream e; + e << defaultVar << " has value \"" << defaultValue + << "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return false; + } + + return true; +} + bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) { if (!id || strlen(id) < 1) |