facebook / facebook/zstd

[Help Wanted, Questions]How to build zstd with cmake to minimize the binary size?

Open
#4,161 6 comments 0 reactions 0 assignees View on GitHub
build question
Dominant language
C
Stars
27.9k
Forks
2.6k
Avg merge
1d 3h
Merged PRs (30d)
8

Description

**Is your feature request related to a problem? Please describe.**

Hi, How to minimize the binary size of libzstd when build with cmake , I've tried both cmake and make, and it turn out when I use make command ,the binary size is smallest, so how can I use cmake command to achive the same size of make does?

_Here is my cmake cmd:_
cmake .. -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF -DCMAKE_SKIP_RPATH=ON -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_DECOMPRESSION=ON -DZSTD_BUILD_COMPRESSION=OFF -DZSTD_BUILD_DICTBUILDER=OFF -DZSTD_LEGACY_SUPPORT=OFF -DZSTD_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=./lib_install -DCMAKE_C_FLAGS=" -DHUF_FORCE_DECOMPRESS_X1 -DZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT -DZSTD_NO_INLINE -DZSTD_STRIP_ERROR_STRINGS -DZSTD_NO_UNUSED_FUNCTIONS -DZSTD_NO_INLINE -DHUF_DISABLE_FAST_DECODE -DZDICTLIB_STATIC_API"
and the binary size is **_102728_** bytes

_make cmd:_
make -j8 ZSTD_LIB_MINIFY=1 ZSTD_LIB_COMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 ZSTD_LIB_DECOMPRESSION=1
and the binary size is **_79432_** bytes

**Describe the solution you'd like**
Wonder how to build zstd with cmake to minimize the binary size,as close as possible to the size of the binary compiled with make?

Thanks a lot!

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.