mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
file(ARCHIVE_CREATE): Allow higher compression level for Zstd
This allows the Zstd compression-level to be set between 0-19. I've adjusted some of the tests, and error messages to indicates the selected algorithm, and min/max of its compression-level. Fixes: #24160
This commit is contained in:
committed by
Brad King
parent
88c4006f05
commit
ed519b1cba
@@ -1214,6 +1214,9 @@ directed to do so with the ``COMPRESSION`` option. Valid values for
|
||||
The ``<compression-level>`` should be between 0-9, with the default being 0.
|
||||
The ``COMPRESSION`` option must be present when ``COMPRESSION_LEVEL`` is given.
|
||||
|
||||
.. versionadded:: 3.26
|
||||
The ``<compression-level>`` of the ``Zstd`` algorithm can be set between 0-19.
|
||||
|
||||
.. note::
|
||||
With ``FORMAT`` set to ``raw`` only one file will be compressed with the
|
||||
compression type specified by ``COMPRESSION``.
|
||||
|
||||
@@ -3404,20 +3404,29 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
int compressionLevel = 0;
|
||||
int minCompressionLevel = 0;
|
||||
int maxCompressionLevel = 9;
|
||||
if (compress == cmSystemTools::TarCompressZstd) {
|
||||
maxCompressionLevel = 19;
|
||||
}
|
||||
|
||||
if (!parsedArgs.CompressionLevel.empty()) {
|
||||
if (parsedArgs.CompressionLevel.size() != 1 &&
|
||||
!std::isdigit(parsedArgs.CompressionLevel[0])) {
|
||||
status.SetError(cmStrCat("compression level ",
|
||||
parsedArgs.CompressionLevel,
|
||||
" should be in range 0 to 9"));
|
||||
status.SetError(
|
||||
cmStrCat("compression level ", parsedArgs.CompressionLevel, " for ",
|
||||
parsedArgs.Compression, " should be in range ",
|
||||
minCompressionLevel, " to ", maxCompressionLevel));
|
||||
cmSystemTools::SetFatalErrorOccurred();
|
||||
return false;
|
||||
}
|
||||
compressionLevel = std::stoi(parsedArgs.CompressionLevel);
|
||||
if (compressionLevel < 0 || compressionLevel > 9) {
|
||||
status.SetError(cmStrCat("compression level ",
|
||||
parsedArgs.CompressionLevel,
|
||||
" should be in range 0 to 9"));
|
||||
if (compressionLevel < minCompressionLevel ||
|
||||
compressionLevel > maxCompressionLevel) {
|
||||
status.SetError(
|
||||
cmStrCat("compression level ", parsedArgs.CompressionLevel, " for ",
|
||||
parsedArgs.Compression, " should be in range ",
|
||||
minCompressionLevel, " to ", maxCompressionLevel));
|
||||
cmSystemTools::SetFatalErrorOccurred();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CMake Error at compression-level.cmake:39 \(file\):
|
||||
file compression level 100 should be in range 0 to 9
|
||||
file compression level 100 for GZip should be in range 0 to 9
|
||||
Call Stack \(most recent call first\):
|
||||
argument-validation-compression-level-1.cmake:8 \(check_compression_level\)
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CMake Error at compression-level.cmake:39 \(file\):
|
||||
file compression level high should be in range 0 to 9
|
||||
file compression level high for GZip should be in range 0 to 9
|
||||
Call Stack \(most recent call first\):
|
||||
argument-validation-compression-level-2.cmake:8 \(check_compression_level\)
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
@@ -8,3 +8,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake)
|
||||
check_compression_level("1")
|
||||
check_compression_level("5")
|
||||
check_compression_level("9")
|
||||
check_compression_level("12")
|
||||
check_compression_level("15")
|
||||
check_compression_level("19")
|
||||
|
||||
Reference in New Issue
Block a user