summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2018-06-08 14:48:25 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2018-07-02 13:51:02 (GMT)
commit4938abb6002cb60501a0da651059ca0aefeed24f (patch)
tree2e3940a524726192b864cfd7cffb6800b4153909 /Source/CPack
parent752c2721a17e95f642874562f6b406f1f05b4430 (diff)
downloadCMake-4938abb6002cb60501a0da651059ca0aefeed24f.zip
CMake-4938abb6002cb60501a0da651059ca0aefeed24f.tar.gz
CMake-4938abb6002cb60501a0da651059ca0aefeed24f.tar.bz2
cmCPackGenerator: Refactor InstallProjectViaInstallCMakeProjects()
This refactoring will allow cmCPackExtGenerator to skip the install step while still gathering up information about the CPack components and groups. Besides, this function was too long, and needed to be broken up anyway.
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx552
-rw-r--r--Source/CPack/cmCPackGenerator.h12
2 files changed, 296 insertions, 268 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index f15445b..6924873 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -548,7 +548,6 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string installComponent = *it;
++it;
std::string installSubDirectory = *it;
- std::string installFile = installDirectory + "/cmake_install.cmake";
std::vector<std::string> componentsVector;
@@ -559,7 +558,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
* - the user did not request Monolithic install
* (this works at CPack time too)
*/
- if (this->SupportsComponentInstallation() &
+ if (this->SupportsComponentInstallation() &&
!(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
// Determine the installation types for this project (if provided).
std::string installTypesVar = "CPACK_" +
@@ -606,38 +605,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// on windows.
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
- // Does this generator require pre-install?
- if (const char* preinstall =
- globalGenerator->GetPreinstallTargetName()) {
- std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
- preinstall, 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, &output, &retVal,
- installDirectory.c_str(), this->GeneratorVerbose,
- cmDuration::zero());
- if (!resB || retVal) {
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/PreinstallOutput.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << buildCommand << std::endl
- << "# Directory: " << installDirectory << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running install command: "
- << buildCommand << std::endl
- << "Please check " << tmpFile << " for errors"
- << std::endl);
- return 0;
- }
+ if (!this->RunPreinstallTarget(installProjectName, installDirectory,
+ globalGenerator, buildConfig)) {
+ return 0;
}
+
delete globalGenerator;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
@@ -645,258 +617,302 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// Run the installation for each component
for (std::string const& component : componentsVector) {
- std::string tempInstallDirectory = baseTempInstallDirectory;
- installComponent = component;
- if (componentInstall) {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install component: " << installComponent
- << std::endl);
+ if (!this->InstallCMakeProject(
+ setDestDir, installDirectory, baseTempInstallDirectory,
+ default_dir_mode, component, componentInstall,
+ installSubDirectory, buildConfig, absoluteDestFiles)) {
+ return 0;
}
+ }
+ }
+ }
+ this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
+ absoluteDestFiles.c_str());
+ return 1;
+}
- cmake cm(cmake::RoleScript);
- cm.SetHomeDirectory("");
- cm.SetHomeOutputDirectory("");
- cm.GetCurrentSnapshot().SetDefaultDefinitions();
- cm.AddCMakePaths();
- cm.SetProgressCallback(cmCPackGeneratorProgress, this);
- cm.SetTrace(this->Trace);
- cm.SetTraceExpand(this->TraceExpand);
- cmGlobalGenerator gg(&cm);
- cmMakefile mf(&gg, cm.GetCurrentSnapshot());
- if (!installSubDirectory.empty() && installSubDirectory != "/" &&
- installSubDirectory != ".") {
- tempInstallDirectory += installSubDirectory;
- }
- if (componentInstall) {
- tempInstallDirectory += "/";
- // Some CPack generators would rather chose
- // the local installation directory suffix.
- // Some (e.g. RPM) use
- // one install directory for each component **GROUP**
- // instead of the default
- // one install directory for each component.
- tempInstallDirectory +=
- GetComponentInstallDirNameSuffix(installComponent);
- if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
- tempInstallDirectory += "/";
- tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
- }
- }
+int cmCPackGenerator::RunPreinstallTarget(
+ const std::string& installProjectName, const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator, const std::string& buildConfig)
+{
+ // Does this generator require pre-install?
+ if (const char* preinstall = globalGenerator->GetPreinstallTargetName()) {
+ std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
+ preinstall, 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, &output, &retVal,
+ installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero());
+ if (!resB || retVal) {
+ std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ tmpFile += "/PreinstallOutput.log";
+ cmGeneratedFileStream ofs(tmpFile.c_str());
+ ofs << "# Run command: " << buildCommand << std::endl
+ << "# Directory: " << installDirectory << std::endl
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running install command: "
+ << buildCommand << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
+ return 0;
+ }
+ }
- const char* default_dir_inst_permissions =
- this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
- if (default_dir_inst_permissions && *default_dir_inst_permissions) {
- mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS",
- default_dir_inst_permissions);
- }
+ return 1;
+}
- if (!setDestDir) {
- tempInstallDirectory += this->GetPackagingInstallPrefix();
- }
+int cmCPackGenerator::InstallCMakeProject(
+ bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory, const mode_t* default_dir_mode,
+ const std::string& component, bool componentInstall,
+ const std::string& installSubDirectory, const std::string& buildConfig,
+ std::string& absoluteDestFiles)
+{
+ std::string tempInstallDirectory = baseTempInstallDirectory;
+ std::string installFile = installDirectory + "/cmake_install.cmake";
- if (setDestDir) {
- // For DESTDIR based packaging, use the *project*
- // CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
- // value of the project's CMAKE_INSTALL_PREFIX is sent in here as
- // the value of the CPACK_INSTALL_PREFIX variable.
- //
- // If DESTDIR has been 'internally set ON' this means that
- // the underlying CPack specific generator did ask for that
- // In this case we may override CPACK_INSTALL_PREFIX with
- // CPACK_PACKAGING_INSTALL_PREFIX
- // I know this is tricky and awkward but it's the price for
- // CPACK_SET_DESTDIR backward compatibility.
- if (cmSystemTools::IsInternallyOn(
- this->GetOption("CPACK_SET_DESTDIR"))) {
- this->SetOption("CPACK_INSTALL_PREFIX",
- this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
- }
- std::string dir;
- if (this->GetOption("CPACK_INSTALL_PREFIX")) {
- dir += this->GetOption("CPACK_INSTALL_PREFIX");
- }
- mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
+ if (componentInstall) {
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Install component: " << component << std::endl);
+ }
- cmCPackLogger(
- cmCPackLog::LOG_DEBUG,
- "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)"
- << std::endl);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
- << std::endl);
-
- // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
- // exists:
- //
- if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
- dir = tempInstallDirectory + dir;
- } else {
- dir = tempInstallDirectory + "/" + dir;
- }
- /*
- * We must re-set DESTDIR for each component
- * We must not add the CPACK_INSTALL_PREFIX part because
- * it will be added using the override of CMAKE_INSTALL_PREFIX
- * The main reason for this awkward trick is that
- * are using DESTDIR for 2 different reasons:
- * - Because it was asked by the CPack Generator or the user
- * using CPACK_SET_DESTDIR
- * - Because it was already used for component install
- * in order to put things in subdirs...
- */
- cmSystemTools::PutEnv(std::string("DESTDIR=") +
- tempInstallDirectory);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Creating directory: '" << dir << "'" << std::endl);
+ cmake cm(cmake::RoleScript);
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cm.GetCurrentSnapshot().SetDefaultDefinitions();
+ cm.AddCMakePaths();
+ cm.SetProgressCallback(cmCPackGeneratorProgress, this);
+ cm.SetTrace(this->Trace);
+ cm.SetTraceExpand(this->TraceExpand);
+ cmGlobalGenerator gg(&cm);
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!installSubDirectory.empty() && installSubDirectory != "/" &&
+ installSubDirectory != ".") {
+ tempInstallDirectory += installSubDirectory;
+ }
+ if (componentInstall) {
+ tempInstallDirectory += "/";
+ // Some CPack generators would rather chose
+ // the local installation directory suffix.
+ // Some (e.g. RPM) use
+ // one install directory for each component **GROUP**
+ // instead of the default
+ // one install directory for each component.
+ tempInstallDirectory += GetComponentInstallDirNameSuffix(component);
+ if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
+ tempInstallDirectory += "/";
+ tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ }
+ }
- if (!cmsys::SystemTools::MakeDirectory(dir, default_dir_mode)) {
- cmCPackLogger(
- cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: " << dir << std::endl);
- return 0;
- }
- } else {
- mf.AddDefinition("CMAKE_INSTALL_PREFIX",
- tempInstallDirectory.c_str());
+ const char* default_dir_inst_permissions =
+ this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
+ if (default_dir_inst_permissions && *default_dir_inst_permissions) {
+ mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS",
+ default_dir_inst_permissions);
+ }
- if (!cmsys::SystemTools::MakeDirectory(tempInstallDirectory,
- default_dir_mode)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: "
- << tempInstallDirectory << std::endl);
- return 0;
- }
+ if (!setDestDir) {
+ tempInstallDirectory += this->GetPackagingInstallPrefix();
+ }
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Using non-DESTDIR install... (mf.AddDefinition)"
- << std::endl);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '"
- << tempInstallDirectory << "'" << std::endl);
- }
+ if (setDestDir) {
+ // For DESTDIR based packaging, use the *project*
+ // CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
+ // value of the project's CMAKE_INSTALL_PREFIX is sent in here as
+ // the value of the CPACK_INSTALL_PREFIX variable.
+ //
+ // If DESTDIR has been 'internally set ON' this means that
+ // the underlying CPack specific generator did ask for that
+ // In this case we may override CPACK_INSTALL_PREFIX with
+ // CPACK_PACKAGING_INSTALL_PREFIX
+ // I know this is tricky and awkward but it's the price for
+ // CPACK_SET_DESTDIR backward compatibility.
+ if (cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"))) {
+ this->SetOption("CPACK_INSTALL_PREFIX",
+ this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
+ }
+ std::string dir;
+ if (this->GetOption("CPACK_INSTALL_PREFIX")) {
+ dir += this->GetOption("CPACK_INSTALL_PREFIX");
+ }
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
- if (!buildConfig.empty()) {
- mf.AddDefinition("BUILD_TYPE", buildConfig.c_str());
- }
- std::string installComponentLowerCase =
- cmSystemTools::LowerCase(installComponent);
- if (installComponentLowerCase != "all") {
- mf.AddDefinition("CMAKE_INSTALL_COMPONENT",
- installComponent.c_str());
- }
+ cmCPackLogger(
+ cmCPackLog::LOG_DEBUG,
+ "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)"
+ << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
+ << std::endl);
+
+ // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
+ // exists:
+ //
+ if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
+ dir = tempInstallDirectory + dir;
+ } else {
+ dir = tempInstallDirectory + "/" + dir;
+ }
+ /*
+ * We must re-set DESTDIR for each component
+ * We must not add the CPACK_INSTALL_PREFIX part because
+ * it will be added using the override of CMAKE_INSTALL_PREFIX
+ * The main reason for this awkward trick is that
+ * are using DESTDIR for 2 different reasons:
+ * - Because it was asked by the CPack Generator or the user
+ * using CPACK_SET_DESTDIR
+ * - Because it was already used for component install
+ * in order to put things in subdirs...
+ */
+ cmSystemTools::PutEnv(std::string("DESTDIR=") + tempInstallDirectory);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Creating directory: '" << dir << "'" << std::endl);
- // strip on TRUE, ON, 1, one or several file names, but not on
- // FALSE, OFF, 0 and an empty string
- if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
- mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
- }
- // Remember the list of files before installation
- // of the current component (if we are in component install)
- std::string const& InstallPrefix = tempInstallDirectory;
- std::vector<std::string> filesBefore;
- std::string findExpr = tempInstallDirectory;
- if (componentInstall) {
- cmsys::Glob glB;
- findExpr += "/*";
- glB.RecurseOn();
- glB.SetRecurseListDirs(true);
- glB.FindFiles(findExpr);
- filesBefore = glB.GetFiles();
- std::sort(filesBefore.begin(), filesBefore.end());
- }
+ if (!cmsys::SystemTools::MakeDirectory(dir, default_dir_mode)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: " << dir
+ << std::endl);
+ return 0;
+ }
+ } else {
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
- // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
- // then forward request to cmake_install.cmake script
- if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf.AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
- }
- // If current CPack generator does support
- // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
- // then ask cmake_install.cmake script to error out
- // as soon as it occurs (before installing file)
- if (!SupportsAbsoluteDestination() ||
- this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
- }
- // do installation
- int res = mf.ReadListFile(installFile.c_str());
- // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
- // to CPack (may be used by generators like CPack RPM or DEB)
- // in order to transparently handle ABSOLUTE PATH
- if (mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
- mf.AddDefinition(
- "CPACK_ABSOLUTE_DESTINATION_FILES",
- mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
- }
+ if (!cmsys::SystemTools::MakeDirectory(tempInstallDirectory,
+ default_dir_mode)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: "
+ << tempInstallDirectory << std::endl);
+ return 0;
+ }
- // Now rebuild the list of files after installation
- // of the current component (if we are in component install)
- if (componentInstall) {
- cmsys::Glob glA;
- glA.RecurseOn();
- glA.SetRecurseListDirs(true);
- glA.SetRecurseThroughSymlinks(false);
- glA.FindFiles(findExpr);
- std::vector<std::string> filesAfter = glA.GetFiles();
- std::sort(filesAfter.begin(), filesAfter.end());
- std::vector<std::string>::iterator diff;
- std::vector<std::string> result(filesAfter.size());
- diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
- filesBefore.begin(), filesBefore.end(),
- result.begin());
-
- std::vector<std::string>::iterator fit;
- std::string localFileName;
- // Populate the File field of each component
- for (fit = result.begin(); fit != diff; ++fit) {
- localFileName = cmSystemTools::RelativePath(InstallPrefix, *fit);
- localFileName =
- localFileName.substr(localFileName.find_first_not_of('/'));
- Components[installComponent].Files.push_back(localFileName);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Adding file <"
- << localFileName << "> to component <"
- << installComponent << ">" << std::endl);
- }
- }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Using non-DESTDIR install... (mf.AddDefinition)"
+ << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory
+ << "'" << std::endl);
+ }
- if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
- if (!absoluteDestFiles.empty()) {
- absoluteDestFiles += ";";
- }
- absoluteDestFiles +=
- mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Got some ABSOLUTE DESTINATION FILES: "
- << absoluteDestFiles << std::endl);
- // define component specific var
- if (componentInstall) {
- std::string absoluteDestFileComponent =
- std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
- GetComponentInstallDirNameSuffix(installComponent);
- if (nullptr != this->GetOption(absoluteDestFileComponent)) {
- std::string absoluteDestFilesListComponent =
- this->GetOption(absoluteDestFileComponent);
- absoluteDestFilesListComponent += ";";
- absoluteDestFilesListComponent +=
- mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- this->SetOption(absoluteDestFileComponent,
- absoluteDestFilesListComponent.c_str());
- } else {
- this->SetOption(
- absoluteDestFileComponent,
- mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
- }
- }
- }
- if (cmSystemTools::GetErrorOccuredFlag() || !res) {
- return 0;
- }
+ if (!buildConfig.empty()) {
+ mf.AddDefinition("BUILD_TYPE", buildConfig.c_str());
+ }
+ std::string installComponentLowerCase = cmSystemTools::LowerCase(component);
+ if (installComponentLowerCase != "all") {
+ mf.AddDefinition("CMAKE_INSTALL_COMPONENT", component.c_str());
+ }
+
+ // strip on TRUE, ON, 1, one or several file names, but not on
+ // FALSE, OFF, 0 and an empty string
+ if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
+ mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
+ }
+ // Remember the list of files before installation
+ // of the current component (if we are in component install)
+ std::string const& InstallPrefix = tempInstallDirectory;
+ std::vector<std::string> filesBefore;
+ std::string findExpr = tempInstallDirectory;
+ if (componentInstall) {
+ cmsys::Glob glB;
+ findExpr += "/*";
+ glB.RecurseOn();
+ glB.SetRecurseListDirs(true);
+ glB.FindFiles(findExpr);
+ filesBefore = glB.GetFiles();
+ std::sort(filesBefore.begin(), filesBefore.end());
+ }
+
+ // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
+ // then forward request to cmake_install.cmake script
+ if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf.AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ }
+ // If current CPack generator does support
+ // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
+ // then ask cmake_install.cmake script to error out
+ // as soon as it occurs (before installing file)
+ if (!SupportsAbsoluteDestination() ||
+ this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ }
+ // do installation
+ int res = mf.ReadListFile(installFile.c_str());
+ // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
+ // to CPack (may be used by generators like CPack RPM or DEB)
+ // in order to transparently handle ABSOLUTE PATH
+ if (mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+ mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES",
+ mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
+ }
+
+ // Now rebuild the list of files after installation
+ // of the current component (if we are in component install)
+ if (componentInstall) {
+ cmsys::Glob glA;
+ glA.RecurseOn();
+ glA.SetRecurseListDirs(true);
+ glA.SetRecurseThroughSymlinks(false);
+ glA.FindFiles(findExpr);
+ std::vector<std::string> filesAfter = glA.GetFiles();
+ std::sort(filesAfter.begin(), filesAfter.end());
+ std::vector<std::string>::iterator diff;
+ std::vector<std::string> result(filesAfter.size());
+ diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
+ filesBefore.begin(), filesBefore.end(),
+ result.begin());
+
+ std::vector<std::string>::iterator fit;
+ std::string localFileName;
+ // Populate the File field of each component
+ for (fit = result.begin(); fit != diff; ++fit) {
+ localFileName = cmSystemTools::RelativePath(InstallPrefix, *fit);
+ localFileName =
+ localFileName.substr(localFileName.find_first_not_of('/'));
+ Components[component].Files.push_back(localFileName);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Adding file <" << localFileName << "> to component <"
+ << component << ">" << std::endl);
+ }
+ }
+
+ if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (!absoluteDestFiles.empty()) {
+ absoluteDestFiles += ";";
+ }
+ absoluteDestFiles += mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles
+ << std::endl);
+ // define component specific var
+ if (componentInstall) {
+ std::string absoluteDestFileComponent =
+ std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
+ GetComponentInstallDirNameSuffix(component);
+ if (nullptr != this->GetOption(absoluteDestFileComponent)) {
+ std::string absoluteDestFilesListComponent =
+ this->GetOption(absoluteDestFileComponent);
+ absoluteDestFilesListComponent += ";";
+ absoluteDestFilesListComponent +=
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ this->SetOption(absoluteDestFileComponent,
+ absoluteDestFilesListComponent.c_str());
+ } else {
+ this->SetOption(absoluteDestFileComponent,
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
}
}
- this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
- absoluteDestFiles.c_str());
+ if (cmSystemTools::GetErrorOccuredFlag() || !res) {
+ return 0;
+ }
return 1;
}
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index c22f36b..9128f36 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -15,6 +15,7 @@
#include "cm_sys_stat.h"
class cmCPackLog;
+class cmGlobalGenerator;
class cmInstalledFile;
class cmMakefile;
@@ -185,6 +186,17 @@ protected:
bool setDestDir, const std::string& tempInstallDirectory,
const mode_t* default_dir_mode);
+ virtual int RunPreinstallTarget(const std::string& installProjectName,
+ const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator,
+ const std::string& buildConfig);
+ virtual int InstallCMakeProject(
+ bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory,
+ const mode_t* default_dir_mode, const std::string& component,
+ bool componentInstall, const std::string& installSubDirectory,
+ const std::string& buildConfig, std::string& absoluteDestFiles);
+
/**
* The various level of support of
* CPACK_SET_DESTDIR used by the generator.