summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-15 19:37:14 (GMT)
committerBrad King <brad.king@kitware.com>2009-01-15 19:37:14 (GMT)
commitd602a3db8581271ca130ac8fa10f8b4c1cc1dac3 (patch)
treebbda23831e8d454f3df42f57fdab77f2fa51ba82
parent40366f6ced5619ab86f97dba9eb66dbfb2d08149 (diff)
downloadCMake-d602a3db8581271ca130ac8fa10f8b4c1cc1dac3.zip
CMake-d602a3db8581271ca130ac8fa10f8b4c1cc1dac3.tar.gz
CMake-d602a3db8581271ca130ac8fa10f8b4c1cc1dac3.tar.bz2
BUG: Enforce matching policy PUSH/POP in all files
The documentation of cmake_policy PUSH and POP states that they must always match. Previously we enforced this only for the top scope of each CMakeLists.txt file. This enforces the requirement for all files.
-rw-r--r--Source/cmMakefile.cxx31
-rw-r--r--Source/cmMakefile.h2
2 files changed, 19 insertions, 14 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 645de37..c9a9238 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -562,6 +562,11 @@ bool cmMakefile::ReadListFile(const char* filename_in,
// add this list file to the list of dependencies
this->ListFiles.push_back( filenametoread);
bool endScopeNicely = true;
+
+ // Save the current policy stack depth.
+ size_t const policy_depth = this->PolicyStack.size();
+
+ // Run the parsed commands.
const size_t numberFunctions = cacheFile.Functions.size();
for(size_t i =0; i < numberFunctions; ++i)
{
@@ -576,6 +581,17 @@ bool cmMakefile::ReadListFile(const char* filename_in,
}
}
+ // Restore policy stack depth.
+ while(this->PolicyStack.size() > policy_depth)
+ {
+ if(endScopeNicely)
+ {
+ this->IssueMessage(cmake::FATAL_ERROR,
+ "cmake_policy PUSH without matching POP");
+ }
+ this->PopPolicy(false);
+ }
+
// send scope ended to and function blockers
if (endScopeNicely)
{
@@ -597,7 +613,7 @@ bool cmMakefile::ReadListFile(const char* filename_in,
// some extra checks.
if(this->ListFileStack.size() == 1)
{
- this->EnforceDirectoryLevelRules(endScopeNicely);
+ this->EnforceDirectoryLevelRules();
}
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
@@ -610,19 +626,8 @@ bool cmMakefile::ReadListFile(const char* filename_in,
}
//----------------------------------------------------------------------------
-void cmMakefile::EnforceDirectoryLevelRules(bool endScopeNicely)
+void cmMakefile::EnforceDirectoryLevelRules()
{
- // Enforce policy stack depth.
- while(this->PolicyStack.size() > 1)
- {
- if(endScopeNicely)
- {
- this->IssueMessage(cmake::FATAL_ERROR,
- "cmake_policy PUSH without matching POP");
- }
- this->PopPolicy(false);
- }
-
// Diagnose a violation of CMP0000 if necessary.
if(this->CheckCMP0000)
{
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index c77fcdb..77843e8 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -918,7 +918,7 @@ private:
bool CheckCMP0000;
// Enforce rules about CMakeLists.txt files.
- void EnforceDirectoryLevelRules(bool endScopeNicely);
+ void EnforceDirectoryLevelRules();
};