diff options
-rw-r--r-- | Source/cmInstallCommand.cxx | 23 | ||||
-rw-r--r-- | Source/cmInstallCommand.h | 12 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.h | 3 | ||||
-rw-r--r-- | Tests/SimpleInstall/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/SimpleInstall/InstallScript1.cmake | 3 | ||||
-rw-r--r-- | Tests/SimpleInstall/InstallScript2.cmake | 5 | ||||
-rw-r--r-- | Tests/SimpleInstallS2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/SimpleInstallS2/InstallScript1.cmake | 3 | ||||
-rw-r--r-- | Tests/SimpleInstallS2/InstallScript2.cmake | 5 |
10 files changed, 61 insertions, 7 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index f51fb28..0669b7f 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -35,6 +35,10 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args) { return this->HandleScriptMode(args); } + else if(args[0] == "CODE") + { + return this->HandleScriptMode(args); + } else if(args[0] == "TARGETS") { return this->HandleTargetsMode(args); @@ -59,11 +63,18 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args) bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) { bool doing_script = false; + bool doing_code = false; for(size_t i=0; i < args.size(); ++i) { if(args[i] == "SCRIPT") { doing_script = true; + doing_code = false; + } + else if(args[i] == "CODE") + { + doing_script = false; + doing_code = true; } else if(doing_script) { @@ -83,12 +94,24 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) this->Makefile->AddInstallGenerator( new cmInstallScriptGenerator(script.c_str())); } + else if(doing_code) + { + doing_code = false; + std::string code = args[i]; + this->Makefile->AddInstallGenerator( + new cmInstallScriptGenerator(code.c_str(), true)); + } } if(doing_script) { this->SetError("given no value for SCRIPT argument."); return false; } + if(doing_code) + { + this->SetError("given no value for CODE argument."); + return false; + } return true; } diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index ea5e201..4907b91 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -156,12 +156,16 @@ public: "such as shell scripts. Use the TARGETS form to install targets " "built within the project." "\n" - "The SCRIPT signature:\n" - " INSTALL(SCRIPT <file1> [SCRIPT <file2> [...]])\n" + "The SCRIPT and CODE signature:\n" + " INSTALL([[SCRIPT <file>] [CODE <code>]] [...])\n" "The SCRIPT form will invoke the given CMake script files during " "installation. If the script file name is a relative path " - "it will be interpreted with respect to the current source directory." - "\n" + "it will be interpreted with respect to the current source directory. " + "The CODE form will invoke the given CMake code during installation. " + "Code is specified as a single argument inside a double-quoted string. " + "For example, the code\n" + " INSTALL(CODE \"MESSAGE(\\\"Sample install message.\\\")\")\n" + "will print a message during installation.\n" "NOTE: This command supercedes the INSTALL_TARGETS command and the " "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. " "It also replaces the FILES forms of the INSTALL_FILES and " diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 1322f72..8bcfbc3 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -18,7 +18,8 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator -::cmInstallScriptGenerator(const char* script): Script(script) +::cmInstallScriptGenerator(const char* script, bool code): + Script(script), Code(code) { } @@ -31,5 +32,12 @@ cmInstallScriptGenerator //---------------------------------------------------------------------------- void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { - os << "INCLUDE(\"" << this->Script << "\")\n"; + if(this->Code) + { + os << this->Script << "\n"; + } + else + { + os << "INCLUDE(\"" << this->Script << "\")\n"; + } } diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 6b3cdfc..2e9461a 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -25,12 +25,13 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: - cmInstallScriptGenerator(const char* script); + cmInstallScriptGenerator(const char* script, bool code = false); virtual ~cmInstallScriptGenerator(); protected: virtual void GenerateScript(std::ostream& os); std::string Script; + bool Code; }; #endif diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 0ba9fe4..ac8f12e 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -122,6 +122,7 @@ ELSE(STAGE2) # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake + CODE "SET(INSTALL_CODE_DID_RUN 1)" SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake ) SET_DIRECTORY_PROPERTIES(PROPERTIES diff --git a/Tests/SimpleInstall/InstallScript1.cmake b/Tests/SimpleInstall/InstallScript1.cmake index 7ce8551..27b7725 100644 --- a/Tests/SimpleInstall/InstallScript1.cmake +++ b/Tests/SimpleInstall/InstallScript1.cmake @@ -1,2 +1,5 @@ MESSAGE("This is install script 1.") SET(INSTALL_SCRIPT_1_DID_RUN 1) +IF(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install code.") +ENDIF(INSTALL_CODE_DID_RUN) diff --git a/Tests/SimpleInstall/InstallScript2.cmake b/Tests/SimpleInstall/InstallScript2.cmake index acc4f73..927cae8 100644 --- a/Tests/SimpleInstall/InstallScript2.cmake +++ b/Tests/SimpleInstall/InstallScript2.cmake @@ -4,6 +4,11 @@ IF(INSTALL_SCRIPT_1_DID_RUN) ELSE(INSTALL_SCRIPT_1_DID_RUN) MESSAGE(FATAL_ERROR "Install script 1 did not run before install script 2.") ENDIF(INSTALL_SCRIPT_1_DID_RUN) +IF(INSTALL_CODE_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 2 did not run after install code.") +ENDIF(INSTALL_CODE_DID_RUN) FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" "SET(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" ) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 0ba9fe4..ac8f12e 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -122,6 +122,7 @@ ELSE(STAGE2) # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake + CODE "SET(INSTALL_CODE_DID_RUN 1)" SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake ) SET_DIRECTORY_PROPERTIES(PROPERTIES diff --git a/Tests/SimpleInstallS2/InstallScript1.cmake b/Tests/SimpleInstallS2/InstallScript1.cmake index 7ce8551..27b7725 100644 --- a/Tests/SimpleInstallS2/InstallScript1.cmake +++ b/Tests/SimpleInstallS2/InstallScript1.cmake @@ -1,2 +1,5 @@ MESSAGE("This is install script 1.") SET(INSTALL_SCRIPT_1_DID_RUN 1) +IF(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install code.") +ENDIF(INSTALL_CODE_DID_RUN) diff --git a/Tests/SimpleInstallS2/InstallScript2.cmake b/Tests/SimpleInstallS2/InstallScript2.cmake index acc4f73..927cae8 100644 --- a/Tests/SimpleInstallS2/InstallScript2.cmake +++ b/Tests/SimpleInstallS2/InstallScript2.cmake @@ -4,6 +4,11 @@ IF(INSTALL_SCRIPT_1_DID_RUN) ELSE(INSTALL_SCRIPT_1_DID_RUN) MESSAGE(FATAL_ERROR "Install script 1 did not run before install script 2.") ENDIF(INSTALL_SCRIPT_1_DID_RUN) +IF(INSTALL_CODE_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 2 did not run after install code.") +ENDIF(INSTALL_CODE_DID_RUN) FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" "SET(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" ) |