diff options
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 12 | ||||
-rw-r--r-- | Modules/FindwxWidgets.cmake | 8 | ||||
-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 | ||||
-rw-r--r-- | Tests/FunctionTest/CMakeLists.txt | 12 | ||||
-rw-r--r-- | Tests/FunctionTest/SubDirScope/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FunctionTest/Util.cmake | 3 |
10 files changed, 65 insertions, 158 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index eea8291..c831928 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -54,8 +54,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) MESSAGE(STATUS "The ${lang} compiler identification is unknown") ENDIF(CMAKE_${lang}_COMPILER_ID) - RAISE_SCOPE(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}") - RAISE_SCOPE(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}") + SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) #----------------------------------------------------------------------------- @@ -146,7 +146,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) ENDIF(CMAKE_${lang}_COMPILER_ID_RESULT) # Return the files produced by the compilation. - RAISE_SCOPE(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}") + SET(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) #----------------------------------------------------------------------------- @@ -219,7 +219,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) ENDIF(NOT CMAKE_EXECUTABLE_FORMAT) # Return the information extracted. - RAISE_SCOPE(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}") - RAISE_SCOPE(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}") - RAISE_SCOPE(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}") + SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) + SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index a41e43a..07dd29f 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -799,8 +799,8 @@ FUNCTION(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar) ENDIF("${element}" STREQUAL "${_keyword}") ENDFOREACH(element) - RAISE_SCOPE(${_leftvar}) - RAISE_SCOPE(${_rightvar}) + SET(${_leftvar} ${${_leftvar}} PARENT_SCOPE) + SET(${_rightvar} ${${_rightvar}} PARENT_SCOPE) ENDFUNCTION(WX_SPLIT_ARGUMENTS_ON) # @@ -839,7 +839,7 @@ FUNCTION(WX_GET_DEPENDENCIES_FROM_XML LIST(APPEND ${_depends} "${dep_file}") ENDFOREACH(dep_file) - RAISE_SCOPE(${_depends}) + SET(${_depends} ${${_depends}} PARENT_SCOPE) ENDFUNCTION(WX_GET_DEPENDENCIES_FROM_XML) # @@ -953,5 +953,5 @@ FUNCTION(WXWIDGETS_ADD_RESOURCES _outfiles) # Add generated file to output file list. LIST(APPEND ${_outfiles} "${outfile}") - RAISE_SCOPE(${_outfiles}) + SET(${_outfiles} ${${_outfiles}} PARENT_SCOPE) ENDFUNCTION(WXWIDGETS_ADD_RESOURCES) 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" diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt index 1efdef1..91f51b6 100644 --- a/Tests/FunctionTest/CMakeLists.txt +++ b/Tests/FunctionTest/CMakeLists.txt @@ -46,7 +46,7 @@ Test_Argn_Function(ignored 3) # test argument naming and raise scope function(track_find_variable cache_variable is_changed) - raise_scope("${is_changed}" changed) + set("${is_changed}" changed PARENT_SCOPE) endfunction(track_find_variable) track_find_variable(testvar is_changed) if ("${is_changed}" STREQUAL changed) @@ -65,7 +65,7 @@ endif (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}") -# test recursion and return via raise_scope +# test recursion and return via set(... PARENT_SCOPE) function (factorial argument result) if (argument LESS 2) set (lresult 1) @@ -74,7 +74,7 @@ function (factorial argument result) factorial (${temp} tresult) math (EXPR lresult "${argument}*${tresult}") endif (argument LESS 2) - raise_scope ("${result}" "${lresult}") + set ("${result}" "${lresult}" PARENT_SCOPE) endfunction (factorial) factorial (5 fresult) @@ -88,8 +88,9 @@ endif (fresult EQUAL 120) # case test FUNCTION(strange_function m) - RAISE_SCOPE("${m}" strange_function) + SET("${m}" strange_function PARENT_SCOPE) ENDFUNCTION(strange_function m) + STRANGE_FUNCTION(var) set(second_var "second_var") IF("${var}" STREQUAL "strange_function" AND "${second_var}" STREQUAL "second_var") @@ -105,8 +106,9 @@ ENDFUNCTION(ADD_EXECUTABLE) # var undef case FUNCTION(undef_var m) - RAISE_SCOPE("${m}") + SET("${m}" PARENT_SCOPE) ENDFUNCTION(undef_var) + SET(FUNCTION_UNDEFINED 1) undef_var(FUNCTION_UNDEFINED) IF(DEFINED FUNCTION_UNDEFINED) diff --git a/Tests/FunctionTest/SubDirScope/CMakeLists.txt b/Tests/FunctionTest/SubDirScope/CMakeLists.txt index 9241941..b67d30e 100644 --- a/Tests/FunctionTest/SubDirScope/CMakeLists.txt +++ b/Tests/FunctionTest/SubDirScope/CMakeLists.txt @@ -1,4 +1,4 @@ SET(SUBDIR_DEFINED 1) SET(SUBDIR_UNDEFINED) -RAISE_SCOPE(SUBDIR_DEFINED ${SUBDIR_DEFINED}) -RAISE_SCOPE(SUBDIR_UNDEFINED ${SUBDIR_UNDEFINED}) +SET(SUBDIR_DEFINED ${SUBDIR_DEFINED} PARENT_SCOPE) +SET(SUBDIR_UNDEFINED ${SUBDIR_UNDEFINED} PARENT_SCOPE) diff --git a/Tests/FunctionTest/Util.cmake b/Tests/FunctionTest/Util.cmake index 2b40cdf..f0c73b5 100644 --- a/Tests/FunctionTest/Util.cmake +++ b/Tests/FunctionTest/Util.cmake @@ -1,4 +1,3 @@ function(tester) - set (tester_res "${CMAKE_CURRENT_LIST_FILE}") - raise_scope(tester_res) + set (tester_res "${CMAKE_CURRENT_LIST_FILE}" PARENT_SCOPE) endfunction(tester) |