diff options
author | Rodolfo Lima <rlima@nvidia.com> | 2021-01-18 18:28:46 (GMT) |
---|---|---|
committer | Rodolfo Lima <rlima@nvidia.com> | 2021-01-26 15:23:37 (GMT) |
commit | bdf30bdad8dfad258bbc8d387a91f66bee3d0c0f (patch) | |
tree | 7b818b22b22c9e35bd04e68a851b3d39cd70bf6f /Source/cmArchiveWrite.cxx | |
parent | bcdb5b52a06cb98bd09da7410488ff9d5617b27f (diff) | |
download | CMake-bdf30bdad8dfad258bbc8d387a91f66bee3d0c0f.zip CMake-bdf30bdad8dfad258bbc8d387a91f66bee3d0c0f.tar.gz CMake-bdf30bdad8dfad258bbc8d387a91f66bee3d0c0f.tar.bz2 |
CPack: add CPACK_THREADS variable to control compression threads
This allows setting how many threads the compressor will use.
Currently only implemented for XZ when using system's lzma library.
Fixes: #21715
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 356089b..b685b73 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmArchiveWrite.h" +#include <cstdio> #include <cstring> #include <ctime> #include <iostream> @@ -81,7 +82,8 @@ struct cmArchiveWrite::Callback }; cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, - std::string const& format, int compressionLevel) + std::string const& format, int compressionLevel, + int numThreads) : Stream(os) , Archive(archive_write_new()) , Disk(archive_read_disk_new()) @@ -142,6 +144,18 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, cm_archive_error_string(this->Archive)); return; } + { + char sNumThreads[8]; + snprintf(sNumThreads, sizeof(sNumThreads), "%d", numThreads); + sNumThreads[7] = '\0'; // for safety + if (archive_write_set_filter_option(this->Archive, "xz", "threads", + sNumThreads) != ARCHIVE_OK) { + this->Error = cmStrCat("archive_compressor_xz_options: ", + cm_archive_error_string(this->Archive)); + return; + } + } + break; case CompressZstd: if (archive_write_add_filter_zstd(this->Archive) != ARCHIVE_OK) { |