浏览代码

CPack: Add parallel zstd compression

Russell Greene 3 年之前
父节点
当前提交
525faec4e9
共有 3 个文件被更改,包括 21 次插入0 次删除
  1. 6 0
      Help/release/dev/cpack-zstd-parallel.rst
  2. 6 0
      Modules/CPack.cmake
  3. 9 0
      Source/cmArchiveWrite.cxx

+ 6 - 0
Help/release/dev/cpack-zstd-parallel.rst

@@ -0,0 +1,6 @@
+cpack-zstd-parallel
+-------------------
+
+* CPack now supports the :variable:`CPACK_THREADS` option for ``zstd``
+  compression when compiled with libarchive 3.6 or higher.  It is
+  supported by official CMake binaries available on ``cmake.org``.

+ 6 - 0
Modules/CPack.cmake

@@ -316,6 +316,12 @@ installers.  The most commonly-used variables are:
       with a ``liblzma`` that supports parallel compression.
       with a ``liblzma`` that supports parallel compression.
       Older versions did not.
       Older versions did not.
 
 
+  ``zstd``
+    .. versionadded:: 3.24
+
+    Supported if CMake is built with libarchive 3.6 or higher.
+    Official CMake binaries available on ``cmake.org`` support it.
+
   Other compression methods ignore this value and use only one thread.
   Other compression methods ignore this value and use only one thread.
 
 
 Variables for Source Package Generators
 Variables for Source Package Generators

+ 9 - 0
Source/cmArchiveWrite.cxx

@@ -188,6 +188,15 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
                                cm_archive_error_string(this->Archive));
                                cm_archive_error_string(this->Archive));
         return;
         return;
       }
       }
+
+#if ARCHIVE_VERSION_NUMBER >= 3006000
+      if (archive_write_set_filter_option(this->Archive, "zstd", "threads",
+                                          sNumThreads.c_str()) != ARCHIVE_OK) {
+        this->Error = cmStrCat("archive_compressor_zstd_options: ",
+                               cm_archive_error_string(this->Archive));
+        return;
+      }
+#endif
       break;
       break;
   }
   }