summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/module/CPackArchive.rst1
-rw-r--r--Help/release/dev/cpack-archive-per-component-filename.rst6
-rw-r--r--Modules/CPackArchive.cmake39
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx57
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.h5
-rw-r--r--Tests/RunCMake/CPack/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake3
-rw-r--r--Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake3
9 files changed, 100 insertions, 17 deletions
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 1e8342c..4a03b7a 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -54,6 +54,7 @@ All Modules
/module/CMakePrintSystemInformation
/module/CMakePushCheckState
/module/CMakeVerifyManifest
+ /module/CPackArchive
/module/CPackBundle
/module/CPackComponent
/module/CPackCygwin
diff --git a/Help/module/CPackArchive.rst b/Help/module/CPackArchive.rst
new file mode 100644
index 0000000..eb8d9d2
--- /dev/null
+++ b/Help/module/CPackArchive.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CPackArchive.cmake
diff --git a/Help/release/dev/cpack-archive-per-component-filename.rst b/Help/release/dev/cpack-archive-per-component-filename.rst
new file mode 100644
index 0000000..a7a413f
--- /dev/null
+++ b/Help/release/dev/cpack-archive-per-component-filename.rst
@@ -0,0 +1,6 @@
+cpack-rpm-debuginfo-honor-package-filename
+------------------------------------------
+
+* The :module:`CPackArchive` module learned to modify filename per component.
+ See :variable:`CPACK_ARCHIVE_FILE_NAME` variable and its per component
+ version.
diff --git a/Modules/CPackArchive.cmake b/Modules/CPackArchive.cmake
new file mode 100644
index 0000000..741fb1f
--- /dev/null
+++ b/Modules/CPackArchive.cmake
@@ -0,0 +1,39 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#.rst:
+# CPackArchive
+# ------------
+#
+# Archive CPack generator that supports packaging of sources and binaries in
+# different formats:
+#
+# - 7Z - 7zip - (.7z)
+# - TBZ2 (.tar.bz2)
+# - TGZ (.tar.gz)
+# - TXZ (.tar.xz)
+# - TZ (.tar.Z)
+# - ZIP (.zip)
+#
+# Variables specific to CPack Archive generator
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#
+# .. variable:: CPACK_ARCHIVE_FILE_NAME
+# CPACK_ARCHIVE_<component>_FILE_NAME
+#
+# Package file name without extension which is added automatically depending
+# on the archive format.
+#
+# * Mandatory : YES
+# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].<extension>`` with
+# spaces replaced by '-'
+#
+# .. variable:: CPACK_ARCHIVE_COMPONENT_INSTALL
+#
+# Enable component packaging for CPackArchive
+#
+# * Mandatory : NO
+# * Default : OFF
+#
+# If enabled (ON) multiple packages are generated. By default a single package
+# containing files of all components is generated.
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;
/**
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index 752ce8a..faf151a 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -5,7 +5,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
# run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES"
run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT")
-run_cpack_test(CUSTOM_NAMES "RPM;DEB" true "COMPONENT")
+run_cpack_test(CUSTOM_NAMES "RPM;DEB;TGZ" true "COMPONENT")
run_cpack_test(DEBUGINFO "RPM" true "COMPONENT")
run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT")
run_cpack_test(DIST "RPM" false "MONOLITHIC")
diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
index ae5f0af..5cb280c 100644
--- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
@@ -9,4 +9,7 @@ set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM")
string(TOLOWER "${GENERATOR_TYPE}" file_extension_)
set(EXPECTED_FILE_3 "pkg_3_abc.${file_extension_}")
+elseif(GENERATOR_TYPE STREQUAL "TGZ")
+ set(EXPECTED_FILE_2 "second.tar.gz")
+ set(EXPECTED_FILE_3 "pkg_3_abc.tar.gz")
endif()
diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake
index 0c2b37b..4c20e41 100644
--- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake
+++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake
@@ -7,6 +7,9 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM")
set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second")
string(TOLOWER "${GENERATOR_TYPE}" file_extension_)
set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_3_FILE_NAME "pkg_3_abc.${file_extension_}")
+elseif(GENERATOR_TYPE STREQUAL "TGZ")
+ set(CPACK_ARCHIVE_PKG_2_FILE_NAME "second")
+ set(CPACK_ARCHIVE_PKG_3_FILE_NAME "pkg_3_abc")
endif()
install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1)