CMake Zstd compression
Zstd is an open file compression standard. Zstd has become widely used and is incorporated in the Linux kernel and GCC. We use Zstd for data archiving particularly for large files where size and speed are a concern. CMake supports Zstd compression throughout, including file(ARCHIVE_CREATE) and file(ARCHIVE_EXTRACT). Zstd is vendored into CMake, so there is no need to worry about system shared libraries for Zstd.
file(ARCHIVE_CREATE ... WORKING_DIRECTORY ...)
is necessary to avoid system-specific relative path issues.
set(archive "my.zst")
set(in_dir "data/")
file(ARCHIVE_CREATE
OUTPUT ${archive}
PATHS ${in_dir}
COMPRESSION Zstd
COMPRESSION_LEVEL 3
WORKING_DIRECTORY ${in_dir}
)
COMPRESSION_LEVEL
- arbitrary, bigger value is more compressed.
FORMAT
- not used for Zstd.