diff options
author | Brad King <brad.king@kitware.com> | 2013-10-08 12:37:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-08 12:37:50 (GMT) |
commit | 261c248254faf2fc09d71f456f018b7f8bc9a7f1 (patch) | |
tree | a23655839e6c669b682f6fff74d78a8a17dfc821 /Source | |
parent | 1d9af198a8ea4e9329839c2e1f101106d8bdf505 (diff) | |
download | CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.zip CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.tar.gz CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.tar.bz2 |
unset: Add PARENT_SCOPE option
Add an unset() command option to remove a variable from the calling
scope, just like the set() command's PARENT_SCOPE option. Teach the
Unset test to cover such cases.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmUnsetCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmUnsetCommand.h | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 5c0cfaa..84f3029 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -49,7 +49,13 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->RemoveCacheDefinition(variable); return true; } - // ERROR: second argument isn't CACHE + // unset(VAR PARENT_SCOPE) + else if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) + { + this->Makefile->RaiseScope(variable, 0); + return true; + } + // ERROR: second argument isn't CACHE or PARENT_SCOPE else { this->SetError("called with an invalid second argument"); diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 9cf95d9..a477f19 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -61,10 +61,13 @@ public: virtual const char* GetFullDocumentation() const { return - " unset(<variable> [CACHE])\n" + " unset(<variable> [CACHE | PARENT_SCOPE])\n" "Removes the specified variable causing it to become undefined. " "If CACHE is present then the variable is removed from the cache " "instead of the current scope.\n" + "If PARENT_SCOPE is present then the variable is removed from the " + "scope above the current scope. See the same option in the set() " + "command for further details.\n" "<variable> can be an environment variable such as:\n" " unset(ENV{LD_LIBRARY_PATH})\n" "in which case the variable will be removed from the current " |