summaryrefslogtreecommitdiff
path: root/Source/CPack
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2019-07-10 00:07:55 +0300
committerBrad King <brad.king@kitware.com>2019-08-30 11:02:43 -0400
commitda5ac4bb602bafb97b4dc0e012f1d26bbab58e3a (patch)
tree52a7e3d270e57688a5aa089986b09d857f8d268c /Source/CPack
parentd4e6b2ae25659699fccf6bc5888e87179f41b23a (diff)
downloadcmake-da5ac4bb602bafb97b4dc0e012f1d26bbab58e3a.tar.gz
cpack: Add `CPACK_INSTALL_CMAKE_CONFIGURATIONS` variable
For the multi-configuration generators one can specify the list of configurations to include in the package. E.g. having a project, where debug libraries have a suffix to distinct them from the release builds, one can build the package containing both `Debug` and `Release` binaries.
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx64
1 files changed, 47 insertions, 17 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 46c602e493..065aadf6c3 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -598,8 +598,34 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
componentsVector.push_back(project.Component);
}
- const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
- std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
+ 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));
@@ -615,25 +641,29 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// on windows.
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
- if (!this->RunPreinstallTarget(project.ProjectName, project.Directory,
- globalGenerator.get(), buildConfig)) {
- return 0;
- }
-
- 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",