src/thirdparty/libspng/docs/build.md
(u)int32_tCHAR_BIT must equal 8.size_t must be unsigned.size_t and int must be at least 32-bit, 16-bit platforms are not
supported.mkdir cbuild
cd cbuild
cmake .. # Don't forget to set optimization level!
make
make install
meson build --buildtype=release # Default is debug
cd build
ninja
ninja install
The source files spng.c/spng.h can be embedded in a project without
any configuration, SSE2 intrinsics are enabled by default on x86.
| Meson | CMake | Compiler option | Default | Description |
|---|---|---|---|---|
| (auto) | (auto) | SPNG_STATIC | Controls symbol visibility on Windows | |
| enable_opt | ENABLE_OPT | SPNG_DISABLE_OPT | ON | Compile with optimizations |
SPNG_SSE=<1-4> | 1 | SSE version target for x86 (ignored on non-x86) | ||
SPNG_ARM | (auto) | Enable ARM NEON optimizations (ARM64 only) | ||
| static_zlib | OFF | Link zlib statically | ||
| use_miniz | SPNG_USE_MINIZ | OFF | Compile using miniz, disables some features | |
| (auto) | SPNG_ENABLE_TARGET_CLONES | Use target_clones() to optimize (GCC + glibc only) | ||
| dev_build | OFF | Enable the testsuite, requires libpng | ||
| benchmarks | OFF | Enable benchmarks, requires Git LFS | ||
| oss_fuzz | OFF | Enable regression tests with OSS-Fuzz corpora |
Valid values for SPNG_SSE:
Currently only SSE2 optimizations are tested.
The source code alone can be built without any compiler flags,
compiler-specific macros are used to omit the need for options
such as -msse2, -mssse3.
miniz is a single source file replacement for zlib,
linking against miniz allows libspng to be embedded into a project with just
four files: spng.c, miniz.c and their headers.
For building with miniz add the SPNG_USE_MINIZ compiler option,
this handles some minor differences in the API.
Performance is mostly identical, slightly better in some cases
compared to stock zlib.
Profile-guided optimization (PGO) improves performance by up to 10%.
# Run in root directory
git clone https://github.com/libspng/benchmark_images.git
cd build
meson configure -Dbuildtype=release --default-library both -Db_pgo=generate
ninja
./example ../benchmark_images/medium_rgb8.png
./example ../benchmark_images/medium_rgba8.png
./example ../benchmark_images/large_palette.png
meson configure -Db_pgo=use
ninja
ninja install
Documentation is built with mkdocs:
# Run in root directory
mkdocs build