From db68c543ff7ee0a59ec5fa463f59255193a9a479 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Sat, 27 Mar 2004 20:59:44 -0500 Subject: [PATCH] ENH: Add pre and post install script support --- Source/cmLocalGenerator.cxx | 11 +++++++++++ Source/cmSetTargetPropertiesCommand.h | 4 +++- Tests/SimpleInstall/CMakeLists.txt | 4 ++++ Tests/SimpleInstall/PostInstall.cmake | 6 ++++++ Tests/SimpleInstall/PreInstall.cmake | 2 ++ Tests/SimpleInstallS2/CMakeLists.txt | 4 ++++ Tests/SimpleInstallS2/PostInstall.cmake | 6 ++++++ Tests/SimpleInstallS2/PreInstall.cmake | 2 ++ 8 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Tests/SimpleInstall/PostInstall.cmake create mode 100644 Tests/SimpleInstall/PreInstall.cmake create mode 100644 Tests/SimpleInstallS2/PostInstall.cmake create mode 100644 Tests/SimpleInstallS2/PreInstall.cmake diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eea1b17e3..bac89cccf 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -130,6 +130,13 @@ void cmLocalGenerator::GenerateInstallRules() const char* dest = destination.c_str(); int type = l->second.GetType(); + const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT"); + const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT"); + if ( preinstall ) + { + fout << "INCLUDE(" << preinstall << ")" << std::endl; + } + std::string fname; const char* files; // now install the target @@ -226,6 +233,10 @@ void cmLocalGenerator::GenerateInstallRules() default: break; } + if ( postinstall ) + { + fout << "INCLUDE(" << postinstall << ")" << std::endl; + } } } cmMakefile* mf = this->GetMakefile(); diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index a6dacf0cf..726e4348d 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -62,7 +62,9 @@ public: "systems and libraries. CMake also knows about LINK_FLAGS, which " "can be used to add extra flags to the link step of a target." "DEFINE_SYMBOL is a symbol that is defined when compiling C or C++ " - "sources. " + "sources. PRE_INSTALL_SCRIPT specifies CMake script that is run " + "prior to installing the target. POST_INSTALL_SCRIPT specifies " + "CMake script that is run after target is installed. " "If not set here then it is set to target_EXPORTS by default " "(with some substitutions if target is not a valid C identifier). " "You can use and prop value pair you want and extract it later with " diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index ed46a0f64..46689df8e 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -64,6 +64,10 @@ ELSE(STAGE2) INSTALL_TARGETS(/bin SimpleInstall) INSTALL_TARGETS(/lib test1 test2 test3) INSTALL_TARGETS(/include lib1.h lib2.h lib3.h) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) ENDIF(STAGE2) ADD_CUSTOM_COMMAND( diff --git a/Tests/SimpleInstall/PostInstall.cmake b/Tests/SimpleInstall/PostInstall.cmake new file mode 100644 index 000000000..52ea140a5 --- /dev/null +++ b/Tests/SimpleInstall/PostInstall.cmake @@ -0,0 +1,6 @@ +MESSAGE("In post install") +IF(PRE_INSTALL_DID_RUN) + MESSAGE("Pre and post install work fine") +ELSE(PRE_INSTALL_DID_RUN) + MESSAGE(FATAL_ERROR "Pre install did not run before post install") +ENDIF(PRE_INSTALL_DID_RUN) diff --git a/Tests/SimpleInstall/PreInstall.cmake b/Tests/SimpleInstall/PreInstall.cmake new file mode 100644 index 000000000..2ea2f7716 --- /dev/null +++ b/Tests/SimpleInstall/PreInstall.cmake @@ -0,0 +1,2 @@ +MESSAGE("This is in pre install") +SET(PRE_INSTALL_DID_RUN 1) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index ed46a0f64..46689df8e 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -64,6 +64,10 @@ ELSE(STAGE2) INSTALL_TARGETS(/bin SimpleInstall) INSTALL_TARGETS(/lib test1 test2 test3) INSTALL_TARGETS(/include lib1.h lib2.h lib3.h) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) ENDIF(STAGE2) ADD_CUSTOM_COMMAND( diff --git a/Tests/SimpleInstallS2/PostInstall.cmake b/Tests/SimpleInstallS2/PostInstall.cmake new file mode 100644 index 000000000..52ea140a5 --- /dev/null +++ b/Tests/SimpleInstallS2/PostInstall.cmake @@ -0,0 +1,6 @@ +MESSAGE("In post install") +IF(PRE_INSTALL_DID_RUN) + MESSAGE("Pre and post install work fine") +ELSE(PRE_INSTALL_DID_RUN) + MESSAGE(FATAL_ERROR "Pre install did not run before post install") +ENDIF(PRE_INSTALL_DID_RUN) diff --git a/Tests/SimpleInstallS2/PreInstall.cmake b/Tests/SimpleInstallS2/PreInstall.cmake new file mode 100644 index 000000000..2ea2f7716 --- /dev/null +++ b/Tests/SimpleInstallS2/PreInstall.cmake @@ -0,0 +1,2 @@ +MESSAGE("This is in pre install") +SET(PRE_INSTALL_DID_RUN 1)