diff options
author | Amir Masoud Abdol <amirmasoudabdol@icloud.com> | 2022-11-16 13:03:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-16 14:15:01 (GMT) |
commit | ed519b1cba24cddb8669a5d29c45ee2e1aa372c9 (patch) | |
tree | 220e41200319132bbba2a8dfdc0e60fdee322f97 /Source | |
parent | 88c4006f054bd3a2233ce607e22d961f106c3512 (diff) | |
download | CMake-ed519b1cba24cddb8669a5d29c45ee2e1aa372c9.zip CMake-ed519b1cba24cddb8669a5d29c45ee2e1aa372c9.tar.gz CMake-ed519b1cba24cddb8669a5d29c45ee2e1aa372c9.tar.bz2 |
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
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b1d238c..85f528d 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -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; } |