From 3ced881db63a97eb402bd68be5e45298371f4519 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 8 Jun 2018 15:08:36 -0400 Subject: cmCPackGenerator: Store CPACK_INSTALL_CMAKE_PROJECTS in an internal field By storing this information in an internal field in the class, it can be used later on by generators that need it. --- Source/CPack/cmCPackComponentGroup.h | 25 +++++++++++++++++++++++++ Source/CPack/cmCPackGenerator.cxx | 30 +++++++++++++++++++----------- Source/CPack/cmCPackGenerator.h | 1 + 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index f2907db..bb980d7 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -143,4 +143,29 @@ public: std::vector Subgroups; }; +/** \class cmCPackInstallCMakeProject + * \brief A single quadruplet from the CPACK_INSTALL_CMAKE_PROJECTS variable. + */ +class cmCPackInstallCMakeProject +{ +public: + /// The directory of the CMake project. + std::string Directory; + + /// The name of the CMake project. + std::string ProjectName; + + /// The name of the component (or component set) to install. + std::string Component; + + /// The subdirectory to install into. + std::string SubDirectory; + + /// The list of installation types. + std::vector InstallationTypes; + + /// The list of components. + std::vector Components; +}; + #endif diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 6924873..7014676 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -545,9 +545,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ++it; std::string installProjectName = *it; ++it; - std::string installComponent = *it; + cmCPackInstallCMakeProject project; + + project.Directory = installDirectory; + project.ProjectName = installProjectName; + project.Component = *it; ++it; - std::string installSubDirectory = *it; + project.SubDirectory = *it; std::vector componentsVector; @@ -562,30 +566,32 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) { // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" + - cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES"; + cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; const char* installTypes = this->GetOption(installTypesVar); if (installTypes && *installTypes) { std::vector installTypesVector; cmSystemTools::ExpandListArgument(installTypes, installTypesVector); for (std::string const& installType : installTypesVector) { - this->GetInstallationType(installProjectName, installType); + project.InstallationTypes.push_back( + this->GetInstallationType(project.ProjectName, installType)); } } // Determine the set of components that will be used in this project std::string componentsVar = - "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent); + "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); const char* components = this->GetOption(componentsVar); if (components && *components) { cmSystemTools::ExpandListArgument(components, componentsVector); for (std::string const& comp : componentsVector) { - GetComponent(installProjectName, comp); + project.Components.push_back( + this->GetComponent(project.ProjectName, comp)); } componentInstall = true; } } if (componentsVector.empty()) { - componentsVector.push_back(installComponent); + componentsVector.push_back(project.Component); } const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); @@ -605,7 +611,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // on windows. cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths()); - if (!this->RunPreinstallTarget(installProjectName, installDirectory, + if (!this->RunPreinstallTarget(project.ProjectName, project.Directory, globalGenerator, buildConfig)) { return 0; } @@ -613,17 +619,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( delete globalGenerator; cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Install project: " << installProjectName << std::endl); + "- Install project: " << project.ProjectName << std::endl); // Run the installation for each component for (std::string const& component : componentsVector) { if (!this->InstallCMakeProject( - setDestDir, installDirectory, baseTempInstallDirectory, + setDestDir, project.Directory, baseTempInstallDirectory, default_dir_mode, component, componentInstall, - installSubDirectory, buildConfig, absoluteDestFiles)) { + project.SubDirectory, buildConfig, absoluteDestFiles)) { return 0; } } + + this->CMakeProjects.push_back(project); } } this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES", diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 9128f36..c13c649 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -283,6 +283,7 @@ protected: */ std::vector files; + std::vector CMakeProjects; std::map InstallationTypes; /** * The set of components. -- cgit v0.12