diff options
author | Ken Martin <ken.martin@kitware.com> | 2008-03-07 16:43:47 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2008-03-07 16:43:47 (GMT) |
commit | 55eede4b131e39cc341832cd99d3b339f040af75 (patch) | |
tree | 7a36fdcf05163e4a35e2c0ecc3b91d017afe7236 /Source | |
parent | 497779d4b3be8ac387690bc95fdadab122fa5a3c (diff) | |
download | CMake-55eede4b131e39cc341832cd99d3b339f040af75.zip CMake-55eede4b131e39cc341832cd99d3b339f040af75.tar.gz CMake-55eede4b131e39cc341832cd99d3b339f040af75.tar.bz2 |
ENH: clean up some policy stuff and interactions with CMAKE_BACKWARDS_COMPATIBILITY and CMAKE_MINIMUM_REQUIRED
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCMakeMinimumRequired.cxx | 9 | ||||
-rw-r--r-- | Source/cmCacheManager.h | 1 | ||||
-rw-r--r-- | Source/cmListFileCache.cxx | 31 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 24 | ||||
-rw-r--r-- | Source/cmake.cxx | 26 |
5 files changed, 65 insertions, 26 deletions
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 54acb89..bb5bdb0 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -108,6 +108,15 @@ bool cmCMakeMinimumRequired cmSystemTools::SetFatalErrorOccured(); } + if (required_major < 2 || required_major == 2 && required_minor < 4) + { + this->Makefile->SetPolicyVersion("2.4"); + } + else + { + this->Makefile->SetPolicyVersion(version_string.c_str()); + } + return true; } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 50cc873..f1e2298 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -66,6 +66,7 @@ public: bool GetValueAsBool() const; void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().Type; } + void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; } bool Initialized() { return this->GetEntry().Initialized; } cmCacheManager &Container; std::map<cmStdString, CacheEntry>::iterator Position; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 34798f5..234c8e5 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -134,22 +134,15 @@ bool cmListFile::ParseFile(const char* filename, hasPolicy = true; break; } + if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") + { + hasPolicy = true; + break; + } } // if no policy command is found this is an error if(!hasPolicy) { - // add in the old CMAKE_BACKWARDS_COMPATIBILITY var for old CMake compatibility - if (!mf->GetCacheManager()-> - GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) - { - mf->AddCacheDefinition - ("CMAKE_BACKWARDS_COMPATIBILITY", "2.5", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmCacheManager::STRING); - } - switch (mf->GetPolicyStatus(cmPolicies::CMP_0000)) { case cmPolicies::WARN: @@ -165,20 +158,6 @@ bool cmListFile::ParseFile(const char* filename, return false; } } - else - { - // add in the old CMAKE_BACKWARDS_COMPATIBILITY var for old CMake compatibility - if (!mf->GetCacheManager()-> - GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) - { - mf->AddCacheDefinition - ("CMAKE_BACKWARDS_COMPATIBILITY", "2.5", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmCacheManager::INTERNAL); - } - } } if(topLevel) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 382507b..79fecc3 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -184,6 +184,30 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, return false; } + // it is an error if the policy version is less than 2.4 + if (majorVer < 2 || majorVer == 2 && minorVer < 4) + { + mf->IssueError("An attempt was made to set the policy version of " + "CMake to something earlier than 2.4, this is an error!"); + } + + // if the version is 2.4 then make sure the backwards compatibility variable is visible + if (majorVer == 2 && minorVer == 4) + { + // set the default BACKWARDS compatibility to be visible + mf->GetCacheManager()->GetCacheIterator( + "CMAKE_BACKWARDS_COMPATIBILITY").SetType + (cmCacheManager::STRING); + // const char *cbcValue = + // mf->GetCacheManager()-> + // GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"); + // mf->AddCacheDefinition + // ("CMAKE_BACKWARDS_COMPATIBILITY",cbcValue, + // "For backwards compatibility, what version of CMake commands and " + // "syntax should this version of CMake allow.", + // cmCacheManager::STRING); + } + // now loop over all the policies and set them as appropriate std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i = this->Policies.begin(); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 31693d2..e9d92b3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1899,6 +1899,19 @@ int cmake::ActualConfigure() cmCacheManager::INTERNAL); } + // set the default BACKWARDS compatibility to the current version + if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + { + char ver[256]; + sprintf(ver,"%i.%i",cmVersion::GetMajorVersion(), + cmVersion::GetMinorVersion()); + this->CacheManager->AddCacheEntry + ("CMAKE_BACKWARDS_COMPATIBILITY",ver, + "For backwards compatibility, what version of CMake commands and " + "syntax should this version of CMake allow.", + cmCacheManager::INTERNAL); + } + // no generator specified on the command line if(!this->GlobalGenerator) { @@ -2380,6 +2393,19 @@ int cmake::LoadCache() return -3; } + // set the default BACKWARDS compatibility to the current version + if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + { + char ver[256]; + sprintf(ver,"%i.%i",cmVersion::GetMajorVersion(), + cmVersion::GetMinorVersion()); + this->CacheManager->AddCacheEntry + ("CMAKE_BACKWARDS_COMPATIBILITY",ver, + "For backwards compatibility, what version of CMake commands and " + "syntax should this version of CMake allow.", + cmCacheManager::INTERNAL); + } + return 0; } |