summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-04-10 17:44:39 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-04-10 17:44:39 (GMT)
commitbad1215a853a24f9e8145f6157be9e27c0b83cd0 (patch)
tree4164a0426efbe7967fcd865174c09bb243e530ac /Source/CPack
parente4f3568099830233e0620c8824bb0a07376cd5a5 (diff)
downloadCMake-bad1215a853a24f9e8145f6157be9e27c0b83cd0.zip
CMake-bad1215a853a24f9e8145f6157be9e27c0b83cd0.tar.gz
CMake-bad1215a853a24f9e8145f6157be9e27c0b83cd0.tar.bz2
ENH: Add support for preinstall for cmake generated projects when packaging them
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx58
1 files changed, 56 insertions, 2 deletions
diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx
index 14f9cda..7669c5f 100644
--- a/Source/CPack/cmCPackGenericGenerator.cxx
+++ b/Source/CPack/cmCPackGenericGenerator.cxx
@@ -225,14 +225,25 @@ int cmCPackGenericGenerator::InstallProject()
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
+ return 0;
}
}
}
}
const char* cmakeProjects
= this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
+ const char* cmakeGenerator
+ = this->GetOption("CPACK_CMAKE_GENERATOR");
if ( cmakeProjects )
{
+ if ( !cmakeGenerator )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_INSTALL_CMAKE_PROJECTS is specified, but CPACK_CMAKE_GENERATOR "
+ "is not. CPACK_CMAKE_GENERATOR is required to install the project."
+ << std::endl);
+ return 0;
+ }
std::vector<std::string> cmakeProjectsVector;
cmSystemTools::ExpandListArgument(cmakeProjects,
cmakeProjectsVector);
@@ -244,9 +255,53 @@ int cmCPackGenericGenerator::InstallProject()
std::string installDirectory = it->c_str();
++it;
std::string installProjectName = it->c_str();
+ std::string installFile = installDirectory + "/cmake_install.cmake";
+
+ const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
+ cmGlobalGenerator* globalGenerator
+ = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
+ cmakeGenerator);
+
+ // Does this generator require pre-install?
+ if ( globalGenerator->GetPreinstallTargetName() )
+ {
+ globalGenerator->FindMakeProgram(this->MakefileMap);
+ const char* cmakeMakeProgram
+ = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
+ std::string buildCommand
+ = globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
+ installProjectName.c_str(), 0,
+ globalGenerator->GetPreinstallTargetName(),
+ buildConfig, false);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Install command: " << buildCommand << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Run preinstall target for: " << installProjectName << std::endl);
+ std::string output;
+ int retVal = 1;
+ bool resB = cmSystemTools::RunSingleCommand(buildCommand.c_str(), &output,
+ &retVal, installDirectory.c_str(), this->GeneratorVerbose, 0);
+ if ( !resB || retVal )
+ {
+ std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ tmpFile += "/PreinstallOutput.log";
+ cmGeneratedFileStream ofs(tmpFile.c_str());
+ ofs << "# Run command: " << buildCommand.c_str() << std::endl
+ << "# Directory: " << installDirectory.c_str() << std::endl
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running install command: " << buildCommand.c_str()
+ << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors"
+ << std::endl);
+ return 0;
+ }
+ }
+ delete globalGenerator;
+
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install project: " << installProjectName << std::endl);
- std::string installFile = installDirectory + "/cmake_install.cmake";
cmake cm;
cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm);
@@ -257,7 +312,6 @@ int cmCPackGenericGenerator::InstallProject()
{
mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
}
- const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
if ( buildConfig && *buildConfig )
{
mf->AddDefinition("BUILD_TYPE", buildConfig);