summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-03 13:29:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-03 13:30:15 (GMT)
commit2e6effd2e0d8e60ede4aa528e771430071c546b4 (patch)
tree89203a42d0ed66fc8785b669446b1962ecbd8005 /Source
parentd615ce4386f98cfac4d90e136cb272ec2d635e15 (diff)
parentda5ac4bb602bafb97b4dc0e012f1d26bbab58e3a (diff)
downloadCMake-2e6effd2e0d8e60ede4aa528e771430071c546b4.zip
CMake-2e6effd2e0d8e60ede4aa528e771430071c546b4.tar.gz
CMake-2e6effd2e0d8e60ede4aa528e771430071c546b4.tar.bz2
Merge topic 'cpack-install-multiple-configurations'
da5ac4bb60 cpack: Add `CPACK_INSTALL_CMAKE_CONFIGURATIONS` variable d4e6b2ae25 Refactor: Use `unique_ptr` instead of raw pointer Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3533
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx70
1 files changed, 49 insertions, 21 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 288d5d8..a96c1c8 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -594,11 +594,37 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
componentsVector.push_back(project.Component);
}
- const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
- std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
- cmGlobalGenerator* globalGenerator =
+ std::vector<std::string> buildConfigs;
+
+ // Try get configuration names given via `-C` CLI option
+ {
+ const char* const buildConfigCstr =
+ this->GetOption("CPACK_BUILD_CONFIG");
+ auto buildConfig = buildConfigCstr ? buildConfigCstr : std::string{};
+ cmExpandList(buildConfig, buildConfigs);
+ }
+
+ // Try get configurations requested by the user explicitly
+ {
+ const char* const configsCstr =
+ this->GetOption("CPACK_INSTALL_CMAKE_CONFIGURATIONS");
+ auto configs = configsCstr ? configsCstr : std::string{};
+ cmExpandList(configs, buildConfigs);
+ }
+
+ // Remove duplicates
+ std::sort(buildConfigs.begin(), buildConfigs.end());
+ buildConfigs.erase(std::unique(buildConfigs.begin(), buildConfigs.end()),
+ buildConfigs.end());
+
+ // Ensure we have at least one configuration.
+ if (buildConfigs.empty()) {
+ buildConfigs.emplace_back();
+ }
+
+ std::unique_ptr<cmGlobalGenerator> globalGenerator(
this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
- cmakeGenerator);
+ cmakeGenerator));
if (!globalGenerator) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Specified package generator not found. "
@@ -611,27 +637,29 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// on windows.
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
- if (!this->RunPreinstallTarget(project.ProjectName, project.Directory,
- globalGenerator, buildConfig)) {
- return 0;
- }
-
- delete globalGenerator;
-
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install project: " << project.ProjectName << std::endl);
-
- // Run the installation for each component
- for (std::string const& component : componentsVector) {
- if (!this->InstallCMakeProject(
- setDestDir, project.Directory, baseTempInstallDirectory,
- default_dir_mode, component, componentInstall,
- project.SubDirectory, buildConfig, absoluteDestFiles)) {
+ // Run the installation for the selected build configurations
+ for (auto const& buildConfig : buildConfigs) {
+ if (!this->RunPreinstallTarget(project.ProjectName, project.Directory,
+ globalGenerator.get(), buildConfig)) {
return 0;
}
+
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Install project: " << project.ProjectName << " ["
+ << buildConfig << ']'
+ << std::endl);
+ // Run the installation for each component
+ for (std::string const& component : componentsVector) {
+ if (!this->InstallCMakeProject(
+ setDestDir, project.Directory, baseTempInstallDirectory,
+ default_dir_mode, component, componentInstall,
+ project.SubDirectory, buildConfig, absoluteDestFiles)) {
+ return 0;
+ }
+ }
}
- this->CMakeProjects.push_back(project);
+ this->CMakeProjects.emplace_back(std::move(project));
}
}
this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",