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.
This commit is contained in:
Brad King
2009-01-22 13:18:40 -05:00
parent 3028ca756c
commit c332e0bf3c
12 changed files with 210 additions and 19 deletions
+7 -3
View File
@@ -69,8 +69,8 @@ public:
virtual const char* GetFullDocumentation()
{
return
" include(file1 [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
" include(module [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
" include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n"
" [NO_POLICY_SCOPE])\n"
"Reads CMake listfile code from the given file. Commands in the file "
"are processed immediately as if they were written in place of the "
"include command. If OPTIONAL is present, then no error "
@@ -78,7 +78,11 @@ public:
"the variable will be set to the full filename which "
"has been included or NOTFOUND if it failed.\n"
"If a module is specified instead of a file, the file with name "
"<modulename>.cmake is searched in the CMAKE_MODULE_PATH.";
"<modulename>.cmake is searched in the CMAKE_MODULE_PATH."
"\n"
"See the cmake_policy() command documentation for discussion of the "
"NO_POLICY_SCOPE option."
;
}
cmTypeMacro(cmIncludeCommand, cmCommand);