summaryrefslogtreecommitdiffstats
path: root/Source/cmIncludeCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-22 18:18:40 (GMT)
committerBrad King <brad.king@kitware.com>2009-01-22 18:18:40 (GMT)
commitc332e0bf3c4e619358322bd0d0961af45653eb5b (patch)
tree3e31da4052687557169b0e8da2cf897f42cbcb63 /Source/cmIncludeCommand.cxx
parent3028ca756c8621b3cc37032987eb01fbe61da248 (diff)
downloadCMake-c332e0bf3c4e619358322bd0d0961af45653eb5b.zip
CMake-c332e0bf3c4e619358322bd0d0961af45653eb5b.tar.gz
CMake-c332e0bf3c4e619358322bd0d0961af45653eb5b.tar.bz2
ENH: Isolate policy changes in included scripts
Isolation of policy changes inside scripts is important for protecting the including context. This teaches include() and find_package() to imply a cmake_policy(PUSH) and cmake_policy(POP) around the scripts they load, with a NO_POLICY_SCOPE option to disable the behavior. This also creates CMake Policy CMP0011 to provide compatibility. See issue #8192.
Diffstat (limited to 'Source/cmIncludeCommand.cxx')
-rw-r--r--Source/cmIncludeCommand.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index f8d6dc2..d1a51ef 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -28,6 +28,7 @@ bool cmIncludeCommand
return false;
}
bool optional = false;
+ bool noPolicyScope = false;
std::string fname = args[0];
std::string resultVarName;
@@ -60,6 +61,10 @@ bool cmIncludeCommand
return false;
}
}
+ else if(args[i] == "NO_POLICY_SCOPE")
+ {
+ noPolicyScope = true;
+ }
else if(i > 1) // compat.: in previous cmake versions the second
// parameter was ignore if it wasn't "OPTIONAL"
{
@@ -84,7 +89,8 @@ bool cmIncludeCommand
std::string fullFilePath;
bool readit =
this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
- fname.c_str(), &fullFilePath );
+ fname.c_str(), &fullFilePath,
+ noPolicyScope);
// add the location of the included file if a result variable was given
if (resultVarName.size())