1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

cmCPackArchiveGenerator: support multithreaded compression

This commit is contained in:
Ben Boeckel
2020-03-30 21:44:29 -04:00
parent b71d385ed4
commit b3bacf0152
10 changed files with 76 additions and 1 deletions

View File

@@ -51,3 +51,25 @@ Variables specific to CPack Archive generator
Enable component packaging. If enabled (ON), then the archive generator Enable component packaging. If enabled (ON), then the archive generator
creates multiple packages. The default is OFF, which means that a single creates multiple packages. The default is OFF, which means that a single
package containing files of all components is generated. package containing files of all components is generated.
Variables used by CPack Archive generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These variables are used by the Archive generator, but are also available to
CPack generators which are essentially archives at their core. These include:
- :cpack_gen:`CPack Cygwin Generator`
- :cpack_gen:`CPack FreeBSD Generator`
.. variable:: CPACK_ARCHIVE_THREADS
The number of threads to use when performing the compression. If set to
``0``, the number of available cores on the machine will be used instead.
The default is ``1`` which limits compression to a single thread. Note that
not all compression modes support threading in all environments. Currently,
only the XZ compression may support it.
.. note::
Official CMake binaries available on ``cmake.org`` ship with a ``liblzma``
that does not support parallel compression.

View File

@@ -3,6 +3,11 @@ CPack Cygwin Generator
Cygwin CPack generator (Cygwin). Cygwin CPack generator (Cygwin).
Variables affecting the CPack Cygwin generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- :variable:`CPACK_ARCHIVE_THREADS`
Variables specific to CPack Cygwin generator Variables specific to CPack Cygwin generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -3,6 +3,11 @@ CPack FreeBSD Generator
The built in (binary) CPack FreeBSD (pkg) generator (Unix only) The built in (binary) CPack FreeBSD (pkg) generator (Unix only)
Variables affecting the CPack FreeBSD (pkg) generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- :variable:`CPACK_ARCHIVE_THREADS`
Variables specific to CPack FreeBSD (pkg) generator Variables specific to CPack FreeBSD (pkg) generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1,6 @@
parallel-lzma-compression
-------------------------
* The :cpack_gen:`CPack Archive Generator`'s ``TXZ`` format learned the
:variable:`CPACK_ARCHIVE_THREADS` variable to enable parallel compression.
Requires support in the ``liblzma`` used by CMake.

View File

@@ -8,6 +8,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "cm_libarchive.h"
#include "cmCPackComponentGroup.h" #include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h" #include "cmCPackGenerator.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
@@ -343,7 +345,22 @@ bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
return IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL"); return IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL");
} }
bool cmCPackArchiveGenerator::SetArchiveOptions(cmArchiveWrite* /*archive*/) bool cmCPackArchiveGenerator::SetArchiveOptions(cmArchiveWrite* archive)
{ {
#if ARCHIVE_VERSION_NUMBER >= 3004000
// Upstream fixed an issue with their integer parsing in 3.4.0 which would
// cause spurious errors to be raised from `strtoull`.
if (this->Compress == cmArchiveWrite::CompressXZ) {
const char* threads = "1";
if (this->IsSet("CPACK_ARCHIVE_THREADS")) {
threads = this->GetOption("CPACK_ARCHIVE_THREADS");
}
if (!archive->SetFilterOption("xz", "threads", threads)) {
return false;
}
}
#endif
return true; return true;
} }

View File

@@ -20,6 +20,8 @@ run_cpack_test(LONG_FILENAMES "DEB.LONG_FILENAMES" false "MONOLITHIC")
run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT")
run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT")
run_cpack_test_package_target(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") run_cpack_test_package_target(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT")
run_cpack_test_package_target(THREADED_ALL "TXZ" false "MONOLITHIC;COMPONENT")
run_cpack_test_package_target(THREADED "TXZ" false "MONOLITHIC;COMPONENT")
run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC")
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM.PARTIALLY_RELOCATABLE_WARNING" false "COMPONENT") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM.PARTIALLY_RELOCATABLE_WARNING" false "COMPONENT")
run_cpack_test(PER_COMPONENT_FIELDS "RPM.PER_COMPONENT_FIELDS;DEB.PER_COMPONENT_FIELDS" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM.PER_COMPONENT_FIELDS;DEB.PER_COMPONENT_FIELDS" false "COMPONENT")

View File

@@ -0,0 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")

View File

@@ -0,0 +1,7 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
set(CPACK_ARCHIVE_THREADS 2)
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(CPACK_COMPONENTS_ALL test)
endif()

View File

@@ -0,0 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")

View File

@@ -0,0 +1,7 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
set(CPACK_ARCHIVE_THREADS 0)
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(CPACK_COMPONENTS_ALL test)
endif()