summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackArchiveGenerator.cxx
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2017-05-16 21:52:58 (GMT)
committerDomen Vrankar <domen.vrankar@gmail.com>2017-05-16 22:47:15 (GMT)
commit9e06e97d30faf0916bec404c81922334139cf177 (patch)
tree8ce7afb124e06d68174fca0b3e3509463e023ab8 /Source/CPack/cmCPackArchiveGenerator.cxx
parent6b05e028f1a3afc7906908bd48d58993da02a9d9 (diff)
downloadCMake-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/cmCPackArchiveGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx57
1 files changed, 41 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)"