diff options
author | Ken Martin <ken.martin@kitware.com> | 2008-03-06 15:57:59 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2008-03-06 15:57:59 (GMT) |
commit | adddcea5d7e52d4ef0522a2dbefa3d952f1da333 (patch) | |
tree | 922dceb2f4c400e2d0a1dfed6c799f828a553f10 /Source/cmListFileCache.cxx | |
parent | ea525a4fb4d04dcaaf074544126db9b700e38457 (diff) | |
download | CMake-adddcea5d7e52d4ef0522a2dbefa3d952f1da333.zip CMake-adddcea5d7e52d4ef0522a2dbefa3d952f1da333.tar.gz CMake-adddcea5d7e52d4ef0522a2dbefa3d952f1da333.tar.bz2 |
BUG: change the handling of CMAKE_MINIMUM_REQUIRED and BACKWARDS_COMPATIBILITY and extend the documentaiton quite a bit
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r-- | Source/cmListFileCache.cxx | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 768db32..24ca7a4 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -18,6 +18,7 @@ #include "cmListFileLexer.h" #include "cmSystemTools.h" +#include "cmMakefile.h" #include <cmsys/RegularExpression.hxx> @@ -29,7 +30,9 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer, cmListFileFunction& function, const char* filename); -bool cmListFile::ParseFile(const char* filename, bool requireProjectCommand) +bool cmListFile::ParseFile(const char* filename, + bool topLevel, + cmMakefile *mf) { if(!cmSystemTools::FileExists(filename)) { @@ -115,7 +118,60 @@ bool cmListFile::ParseFile(const char* filename, bool requireProjectCommand) cmListFileLexer_Delete(lexer); - if(requireProjectCommand) + // do we need a cmake_policy(VERSION call? + if(topLevel) + { + bool hasPolicy = false; + // search for the right policy command + for(std::vector<cmListFileFunction>::iterator i + = this->Functions.begin(); + i != this->Functions.end(); ++i) + { + if (cmSystemTools::LowerCase(i->Name) == "cmake_policy" && + i->Arguments.size() && + cmSystemTools::LowerCase(i->Arguments[0].Value) == "version") + { + 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.6", + "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: + cmSystemTools::Message( + mf->GetPolicies()->GetPolicyWarning + (cmPolicies::CMP_0000).c_str(),"Warning"); + case cmPolicies::OLD: + break; + default: + cmSystemTools::Error( + mf->GetPolicies()->GetRequiredPolicyError + (cmPolicies::CMP_0000).c_str()); + return false; + } + } + } + + if(topLevel) { bool hasProject = false; // search for a project command |