diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2017-05-16 21:52:58 (GMT) |
---|---|---|
committer | Domen Vrankar <domen.vrankar@gmail.com> | 2017-05-16 22:47:15 (GMT) |
commit | 9e06e97d30faf0916bec404c81922334139cf177 (patch) | |
tree | 8ce7afb124e06d68174fca0b3e3509463e023ab8 /Source/CPack | |
parent | 6b05e028f1a3afc7906908bd48d58993da02a9d9 (diff) | |
download | CMake-9e06e97d30faf0916bec404c81922334139cf177.zip CMake-9e06e97d30faf0916bec404c81922334139cf177.tar.gz CMake-9e06e97d30faf0916bec404c81922334139cf177.tar.bz2 |
CPack/Archive: per component filenames support
Support for setting archive packager specific
per component filenames and monolithic package
filenames.
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.cxx | 57 | ||||
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.h | 5 |
2 files changed, 46 insertions, 16 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index cc01b0c..575c949 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -25,6 +25,28 @@ cmCPackArchiveGenerator::~cmCPackArchiveGenerator() { } +std::string cmCPackArchiveGenerator::GetArchiveComponentFileName( + const std::string& component, bool isGroupName) +{ + std::string componentUpper(cmSystemTools::UpperCase(component)); + std::string packageFileName; + + if (this->IsSet("CPACK_ARCHIVE_" + componentUpper + "_FILE_NAME")) { + packageFileName += + this->GetOption("CPACK_ARCHIVE_" + componentUpper + "_FILE_NAME"); + } else if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) { + packageFileName += GetComponentPackageFileName( + this->GetOption("CPACK_ARCHIVE_FILE_NAME"), component, isGroupName); + } else { + packageFileName += GetComponentPackageFileName( + this->GetOption("CPACK_PACKAGE_FILE_NAME"), component, isGroupName); + } + + packageFileName += this->GetOutputExtension(); + + return packageFileName; +} + int cmCPackArchiveGenerator::InitializeInternal() { this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); @@ -101,11 +123,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " << compGIt->first << std::endl); // Begin the archive for this group - std::string packageFileName = std::string(toplevel); - packageFileName += "/" + - GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), - compGIt->first, true) + - this->GetOutputExtension(); + std::string packageFileName = std::string(toplevel) + "/" + + this->GetArchiveComponentFileName(compGIt->first, true); + // open a block in order to automatically close archive // at the end of the block { @@ -137,10 +157,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) std::string packageFileName = std::string(toplevel); localToplevel += "/" + compIt->first; - packageFileName += "/" + GetComponentPackageFileName( - this->GetOption("CPACK_PACKAGE_FILE_NAME"), - compIt->first, false) + - this->GetOutputExtension(); + packageFileName += + "/" + this->GetArchiveComponentFileName(compIt->first, false); + { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); // Add the files of this component to the archive @@ -161,10 +180,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) std::string packageFileName = std::string(toplevel); localToplevel += "/" + compIt->first; - packageFileName += "/" + - GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), - compIt->first, false) + - this->GetOutputExtension(); + packageFileName += + "/" + this->GetArchiveComponentFileName(compIt->first, false); + { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); // Add the files of this component to the archive @@ -182,9 +200,16 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne() // reset the package file names packageFileNames.clear(); packageFileNames.push_back(std::string(toplevel)); - packageFileNames[0] += "/" + - std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + - this->GetOutputExtension(); + packageFileNames[0] += "/"; + + if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) { + packageFileNames[0] += this->GetOption("CPACK_ARCHIVE_FILE_NAME"); + } else { + packageFileNames[0] += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + } + + packageFileNames[0] += this->GetOutputExtension(); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging all groups in one package..." "(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)" diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 58d67e3..e7116c4 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -34,6 +34,11 @@ public: // component support bool SupportsComponentInstallation() const CM_OVERRIDE; +private: + // get archive component filename + std::string GetArchiveComponentFileName(const std::string& component, + bool isGroupName); + protected: int InitializeInternal() CM_OVERRIDE; /** |