diff options
author | Brad King <brad.king@kitware.com> | 2008-03-10 19:41:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-03-10 19:41:07 (GMT) |
commit | 7f2bf831322dd7f78f93d3db4a597ac94b053dc3 (patch) | |
tree | 444ca5e5bd08479fcaa362eadfc1a1d50f2104af /Source/cmMakefile.cxx | |
parent | eb6b300978abf63c3770ada4ffce0304231b5a91 (diff) | |
download | CMake-7f2bf831322dd7f78f93d3db4a597ac94b053dc3.zip CMake-7f2bf831322dd7f78f93d3db4a597ac94b053dc3.tar.gz CMake-7f2bf831322dd7f78f93d3db4a597ac94b053dc3.tar.bz2 |
ENH: Enforce matching PUSH/POP calls for cmake_policy.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 12ff1b6..238e92a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -579,6 +579,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, } // add this list file to the list of dependencies this->ListFiles.push_back( filenametoread); + bool endScopeNicely = filename? true: false; const size_t numberFunctions = cacheFile.Functions.size(); for(size_t i =0; i < numberFunctions; ++i) { @@ -587,17 +588,14 @@ bool cmMakefile::ReadListFile(const char* filename_in, if (status.GetReturnInvoked() || cmSystemTools::GetFatalErrorOccured() ) { - // pop the listfile off the stack - this->ListFileStack.pop_back(); - this->AddDefinition("CMAKE_PARENT_LIST_FILE", - currentParentFile.c_str()); - this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); - return true; + // Exit early from processing this file. + endScopeNicely = false; + break; } } // send scope ended to and function blockers - if (filename) + if (endScopeNicely) { // loop over all function blockers to see if any block this command std::list<cmFunctionBlocker *>::iterator pos; @@ -613,6 +611,20 @@ bool cmMakefile::ReadListFile(const char* filename_in, } } + // If this is the directory-level CMakeLists.txt file then enforce + // policy stack depth. + if(this->ListFileStack.size() == 1) + { + while(this->PolicyStack.size() > 1) + { + if(endScopeNicely) + { + this->IssueError("cmake_policy PUSH without matching POP"); + } + this->PopPolicy(false); + } + } + this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); |