diff options
author | Alexander Neundorf <neundorf@kde.org> | 2008-01-18 20:52:54 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2008-01-18 20:52:54 (GMT) |
commit | fc8ce174334c3c33141d37ff2b86ea50226b7ce4 (patch) | |
tree | 1f911b47f1b323c1c8250cd6cc89c427c87e0860 /Source | |
parent | e5a4da5b3c930bf19710db638f3d1b86ccbfb3aa (diff) | |
download | CMake-fc8ce174334c3c33141d37ff2b86ea50226b7ce4.zip CMake-fc8ce174334c3c33141d37ff2b86ea50226b7ce4.tar.gz CMake-fc8ce174334c3c33141d37ff2b86ea50226b7ce4.tar.bz2 |
ENH: remove RAISE_SCOPE() again and instead add SET(<var> <value> PARENT_SCOPE)
Alex
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmBootstrapCommands.cxx | 2 | ||||
-rw-r--r-- | Source/cmRaiseScopeCommand.cxx | 40 | ||||
-rw-r--r-- | Source/cmRaiseScopeCommand.h | 86 | ||||
-rw-r--r-- | Source/cmSetCommand.cxx | 47 | ||||
-rw-r--r-- | Source/cmSetCommand.h | 9 |
5 files changed, 45 insertions, 139 deletions
diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands.cxx index 31533f0..b713549 100644 --- a/Source/cmBootstrapCommands.cxx +++ b/Source/cmBootstrapCommands.cxx @@ -70,7 +70,6 @@ #include "cmMessageCommand.cxx" #include "cmOptionCommand.cxx" #include "cmProjectCommand.cxx" -#include "cmRaiseScopeCommand.cxx" #include "cmSetCommand.cxx" #include "cmSetPropertyCommand.cxx" #include "cmSetSourceFilesPropertiesCommand.cxx" @@ -130,7 +129,6 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands) commands.push_back(new cmMessageCommand); commands.push_back(new cmOptionCommand); commands.push_back(new cmProjectCommand); - commands.push_back(new cmRaiseScopeCommand); commands.push_back(new cmSetCommand); commands.push_back(new cmSetPropertyCommand); commands.push_back(new cmSetSourceFilesPropertiesCommand); diff --git a/Source/cmRaiseScopeCommand.cxx b/Source/cmRaiseScopeCommand.cxx deleted file mode 100644 index adf87d8..0000000 --- a/Source/cmRaiseScopeCommand.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/*========================================================================= - - Program: CMake - Cross-Platform Makefile Generator - Module: $RCSfile$ - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#include "cmRaiseScopeCommand.h" - -// cmRaiseScopeCommand -bool cmRaiseScopeCommand -::InitialPass(std::vector<std::string> const& args) -{ - if (args.size() < 1) - { - this->SetError("called with incorrect number of arguments, " - "raise scope must have at least one argument"); - return false; - } - - if (args.size() == 1) - { - this->Makefile->RaiseScope(args[0].c_str(), 0); - } - else - { - this->Makefile->RaiseScope(args[0].c_str(), args[1].c_str()); - } - return true; -} - diff --git a/Source/cmRaiseScopeCommand.h b/Source/cmRaiseScopeCommand.h deleted file mode 100644 index 0ff2e4e..0000000 --- a/Source/cmRaiseScopeCommand.h +++ /dev/null @@ -1,86 +0,0 @@ -/*========================================================================= - - Program: CMake - Cross-Platform Makefile Generator - Module: $RCSfile$ - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#ifndef cmRaiseScopeCommand_h -#define cmRaiseScopeCommand_h - -#include "cmCommand.h" - -/** \class cmRaiseScopeCommand - * \brief Raise the Scope a CMAKE variable one level up - * - * cmRaiseScopeCommand pushes the current state of a variable into - * the scope above the current scope. - */ -class cmRaiseScopeCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmRaiseScopeCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - virtual bool InitialPass(std::vector<std::string> const& args); - - /** - * The name of the command as specified in CMakeList.txt. - */ - virtual const char* GetName() {return "raise_scope";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() - { - return "Raise the scope of the variables listed."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() - { - return - " raise_scope(VAR [VALUE])\n" - "Sets the value of a variable in the scope above the " - "current scope. Each new directory or function creates a new scope. " - "This command will set the value of a variable into the " - "parent directory or calling function (whichever is applicable to " - "the case at hand) If VALUE is not specified then the variable is " - "removed from the parent scope."; - } - - /** - * This determines if the command is invoked when in script mode. - * mark_as_advanced() will have no effect in script mode, but this will - * make many of the modules usable in cmake/ctest scripts, (among them - * FindUnixMake.cmake used by the CTEST_BUILD command. - */ - virtual bool IsScriptable() { return true; } - - cmTypeMacro(cmRaiseScopeCommand, cmCommand); -}; - - - -#endif diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index ffa2ce0..082dd41 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -74,29 +74,42 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args) std::string value; // optional bool cache = false; // optional bool force = false; // optional + bool parentScope = false; cmCacheManager::CacheEntryType type = cmCacheManager::STRING; // required if cache const char* docstring = 0; // required if cache std::string::size_type cacheStart = 0; - // look for FORCE argument - if (args.size() > 4 && args[args.size()-1] == "FORCE") + unsigned int ignoreLastArgs = 0; + // look for PARENT_SCOPE argument + if (args.size() > 1 && args[args.size()-1] == "PARENT_SCOPE") { - force = true; + parentScope = true; + ignoreLastArgs++; } - - // check for cache signature - if (args.size() > 3 && args[args.size() - 3 - (force ? 1 : 0)] == "CACHE") + else { - cache = true; + // look for FORCE argument + if (args.size() > 4 && args[args.size()-1] == "FORCE") + { + force = true; + ignoreLastArgs++; + } + + // check for cache signature + if (args.size() > 3 && args[args.size() - 3 - (force ? 1 : 0)] == "CACHE") + { + cache = true; + ignoreLastArgs+=3; + } } - + // collect any values into a single semi-colon seperated value list if(static_cast<unsigned short>(args.size()) > - static_cast<unsigned short>(1 + (cache ? 3 : 0) + (force ? 1 : 0))) + static_cast<unsigned short>(1 + ignoreLastArgs)) { value = args[1]; - size_t endPos = args.size() - (cache ? 3 : 0) - (force ? 1 : 0); + size_t endPos = args.size() - ignoreLastArgs; for(size_t i = 2; i < endPos; ++i) { value += ";"; @@ -104,6 +117,20 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args) } } + if (parentScope) + { + if (value.empty()) + { + this->Makefile->RaiseScope(variable, 0); + } + else + { + this->Makefile->RaiseScope(variable, value.c_str()); + } + return true; + } + + // we should be nice and try to catch some simple screwups if the last or // next to last args are CACHE then they screwed up. If they used FORCE // without CACHE they screwed up diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 48b0642..6f6ecd2 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -65,7 +65,8 @@ public: virtual const char* GetFullDocumentation() { return - " set(<variable> <value> [CACHE <type> <docstring> [FORCE]])\n" + " set(<variable> <value> [[CACHE <type> <docstring> [FORCE]] | " + "PARENT_SCOPE])\n" "Within CMake sets <variable> to the value <value>. <value> is expanded" " before <variable> is set to it. If CACHE is present, then the " "<variable> is put in the cache. <type> and <docstring> are then " @@ -81,6 +82,12 @@ public: "cache variable, then this always writes into the current makefile. The " "FORCE option will overwrite the cache value removing any changes by " "the user.\n" + "If PARENT_SCOPE is present, the variable will be set in the scope " + "above the current scope. Each new directory or function creates a new " + "scope. This command will set the value of a variable into the parent " + "directory or calling function (whichever is applicable to the case at " + "hand) If VALUE is not specified then the variable is removed from the " + "parent scope.\n" " set(<variable> <value1> ... <valueN>)\n" "In this case <variable> is set to a semicolon separated list of " "values.\n" |