summaryrefslogtreecommitdiffstats
path: root/Source/cmPolicies.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-24 14:56:26 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-24 14:56:26 (GMT)
commit1655dce2a58c6629ae4455d369c34a8b40924b22 (patch)
tree1e1d5af8c0b94609667570e4f96cb17ed67d570f /Source/cmPolicies.cxx
parenta24ff4e453701b927959555ce7dab895870e6ae8 (diff)
downloadCMake-1655dce2a58c6629ae4455d369c34a8b40924b22.zip
CMake-1655dce2a58c6629ae4455d369c34a8b40924b22.tar.gz
CMake-1655dce2a58c6629ae4455d369c34a8b40924b22.tar.bz2
ENH: Cleanup policy version interface presented to user.
- In cmake_minimum_required do not set policy version if current CMake is too old - In cmPolicies::ApplyPolicyVersion report error if version is too new or cannot be parsed
Diffstat (limited to 'Source/cmPolicies.cxx')
-rw-r--r--Source/cmPolicies.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 074bd7a..b37171b 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -301,6 +301,10 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
if(sscanf(ver.c_str(), "%u.%u.%u",
&majorVer, &minorVer, &patchVer) < 2)
{
+ cmOStringStream e;
+ e << "Invalid policy version value \"" << ver << "\". "
+ << "A numeric major.minor[.patch] must be given.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
@@ -317,6 +321,26 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
"One way to so this is to set the policy version to 2.4 exactly."
);
+ return false;
+ }
+
+ // It is an error if the policy version is greater than the running
+ // CMake.
+ if (majorVer > cmVersion::GetMajorVersion() ||
+ (majorVer == cmVersion::GetMajorVersion() &&
+ minorVer > cmVersion::GetMinorVersion()) ||
+ (majorVer == cmVersion::GetMajorVersion() &&
+ minorVer == cmVersion::GetMinorVersion() &&
+ patchVer > cmVersion::GetPatchVersion()))
+ {
+ cmOStringStream e;
+ e << "An attempt was made to set the policy version of CMake to \""
+ << version << "\" which is greater than this version of CMake. "
+ << "This is not allowed because the greater version may have new "
+ << "policies not known to this CMake. "
+ << "You may need a newer CMake version to build this project.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
}
// now loop over all the policies and set them as appropriate