summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-05 23:20:20 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-05 23:20:20 (GMT)
commit7c01167666077453b01846f47227e27be165b659 (patch)
treeb3cccda4b5f1bdb3157bc247a216ec0b34e88076
parent95512a4c0230986c52951102909dac00dcfe4bf4 (diff)
downloadCMake-7c01167666077453b01846f47227e27be165b659.zip
CMake-7c01167666077453b01846f47227e27be165b659.tar.gz
CMake-7c01167666077453b01846f47227e27be165b659.tar.bz2
BUG: Require policy version to specify at least major.minor. Do not store CMAKE_BACKWARDS_COMPATIBILITY with an invalid version value.
-rw-r--r--Source/cmPolicies.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index a60fc1c..44714a1 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -177,8 +177,11 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
unsigned int patchVer = 0;
// parse the string
- sscanf(ver.c_str(), "%u.%u.%u",
- &majorVer, &minorVer, &patchVer);
+ if(sscanf(ver.c_str(), "%u.%u.%u",
+ &majorVer, &minorVer, &patchVer) < 2)
+ {
+ return false;
+ }
// add in the old CMAKE_BACKWARDS_COMPATIBILITY var for old CMake compatibility
if ((majorVer == 2 && minorVer <= 4) || majorVer < 2)
@@ -186,8 +189,10 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
if (!mf->GetCacheManager()->
GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
{
+ cmOStringStream v;
+ v << majorVer << "." << minorVer << "." << patchVer;
mf->AddCacheDefinition
- ("CMAKE_BACKWARDS_COMPATIBILITY",version,
+ ("CMAKE_BACKWARDS_COMPATIBILITY", v.str().c_str(),
"For backwards compatibility, what version of CMake commands and "
"syntax should this version of CMake try to support.",
cmCacheManager::STRING);