summaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx58
-rw-r--r--Source/cmGlobalGenerator.h16
-rw-r--r--Source/ctest.cxx3
3 files changed, 65 insertions, 12 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);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 3911d9e..bd21de0 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -175,6 +175,14 @@ public:
configuration. This is valid during generation only. */
cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; }
+ virtual const char* GetAllTargetName() { return "ALL_BUILD"; }
+ virtual const char* GetInstallTargetName() { return "INSTALL"; }
+ virtual const char* GetPreinstallTargetName() { return 0; }
+ virtual const char* GetTestTargetName() { return "RUN_TESTS"; }
+ virtual const char* GetPackageTargetName() { return "PACKAGE"; }
+ virtual const char* GetEditCacheTargetName() { return 0; }
+ virtual const char* GetRebuildCacheTargetName() { return 0; }
+
protected:
// Fill the ProjectMap, this must be called after LocalGenerators
// has been populated.
@@ -189,14 +197,6 @@ protected:
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, bool depends_on_all = false);
- virtual const char* GetAllTargetName() { return "ALL_BUILD"; }
- virtual const char* GetInstallTargetName() { return "INSTALL"; }
- virtual const char* GetPreinstallTargetName() { return 0; }
- virtual const char* GetTestTargetName() { return "RUN_TESTS"; }
- virtual const char* GetPackageTargetName() { return "PACKAGE"; }
- virtual const char* GetEditCacheTargetName() { return 0; }
- virtual const char* GetRebuildCacheTargetName() { return 0; }
-
bool ForceUnixPaths;
bool ToolSupportsColorVT100;
cmStdString FindMakeProgramFile;
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 6a8c90c..ce6235d 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -21,6 +21,7 @@
#include "cmake.h"
#include "cmDocumentation.h"
+
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationName[] =
{
@@ -207,8 +208,6 @@ int main (int argc, char *argv[])
nocwd = 1;
}
-
-
// If there is a testing input file, check for documentation options
// only if there are actually arguments. We want running without
// arguments to run tests.