ENH: Add pre and post install script support
This commit is contained in:
parent
451522381d
commit
db68c543ff
|
@ -130,6 +130,13 @@ void cmLocalGenerator::GenerateInstallRules()
|
||||||
const char* dest = destination.c_str();
|
const char* dest = destination.c_str();
|
||||||
int type = l->second.GetType();
|
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;
|
std::string fname;
|
||||||
const char* files;
|
const char* files;
|
||||||
// now install the target
|
// now install the target
|
||||||
|
@ -226,6 +233,10 @@ void cmLocalGenerator::GenerateInstallRules()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ( postinstall )
|
||||||
|
{
|
||||||
|
fout << "INCLUDE(" << postinstall << ")" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmMakefile* mf = this->GetMakefile();
|
cmMakefile* mf = this->GetMakefile();
|
||||||
|
|
|
@ -62,7 +62,9 @@ public:
|
||||||
"systems and libraries. CMake also knows about LINK_FLAGS, which "
|
"systems and libraries. CMake also knows about LINK_FLAGS, which "
|
||||||
"can be used to add extra flags to the link step of a target."
|
"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++ "
|
"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 "
|
"If not set here then it is set to target_EXPORTS by default "
|
||||||
"(with some substitutions if target is not a valid C identifier). "
|
"(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 "
|
"You can use and prop value pair you want and extract it later with "
|
||||||
|
|
|
@ -64,6 +64,10 @@ ELSE(STAGE2)
|
||||||
INSTALL_TARGETS(/bin SimpleInstall)
|
INSTALL_TARGETS(/bin SimpleInstall)
|
||||||
INSTALL_TARGETS(/lib test1 test2 test3)
|
INSTALL_TARGETS(/lib test1 test2 test3)
|
||||||
INSTALL_TARGETS(/include lib1.h lib2.h lib3.h)
|
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)
|
ENDIF(STAGE2)
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
|
|
|
@ -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)
|
|
@ -0,0 +1,2 @@
|
||||||
|
MESSAGE("This is in pre install")
|
||||||
|
SET(PRE_INSTALL_DID_RUN 1)
|
|
@ -64,6 +64,10 @@ ELSE(STAGE2)
|
||||||
INSTALL_TARGETS(/bin SimpleInstall)
|
INSTALL_TARGETS(/bin SimpleInstall)
|
||||||
INSTALL_TARGETS(/lib test1 test2 test3)
|
INSTALL_TARGETS(/lib test1 test2 test3)
|
||||||
INSTALL_TARGETS(/include lib1.h lib2.h lib3.h)
|
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)
|
ENDIF(STAGE2)
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
|
|
|
@ -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)
|
|
@ -0,0 +1,2 @@
|
||||||
|
MESSAGE("This is in pre install")
|
||||||
|
SET(PRE_INSTALL_DID_RUN 1)
|
Loading…
Reference in New Issue