Skip to main content

Build options

Pass any of these to cmake -B build -D<OPTION>=<value>. cmake -LH build lists them with their current values.

OptionDefaultEffect
LIBTERM_BUILD_STATICONbuild the static library
LIBTERM_BUILD_SHAREDON when top levelbuild the shared library
LIBTERM_BUILD_EXAMPLESON when top levelbuild the programs in examples/
LIBTERM_BUILD_TESTSON when top levelbuild the unit tests for ctest
LIBTERM_BUILD_BENCHON when top levelbuild the benchmarks
LIBTERM_INSTALLON when top levelgenerate install rules
LIBTERM_BUILD_FUZZERSOFFbuild the libFuzzer targets, Clang only
LIBTERM_WARNINGS_AS_ERRORSOFFcompile with -Werror
LIBTERM_SIMDautothe cell-scan backend, see below

"When top level" means the option defaults to ON when libterm is the project being configured and to OFF when it is pulled in as a subproject with add_subdirectory or FetchContent.

The SIMD backend​

lt_present finds changed cells with a vectorised scan. LIBTERM_SIMD selects how that scan is built.

With auto, the default, every backend the target architecture supports is compiled in and the best one is chosen at startup from the CPU's own capabilities:

ArchitectureCandidates, in order of preference
x86-64AVX-512, AVX2, scalar, chosen with cpuid
Linux AArch64SVE, NEON, chosen from hwcap
macOS arm64NEON only, so the build is static
Linux riscv64RVV, scalar

One binary is fast on capable CPUs and never executes an illegal instruction on older ones.

Pin a single backend with scalar, avx2, avx512, neon, sve or rvv. That builds only the named backend with no dispatch, which is useful for benchmarks and minimal builds. A manual build without CMake always gets scalar.

Windows​

The Windows backend is validated with MinGW. To cross-compile from a POSIX host:

cmake -B build-mingw -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \
-DLIBTERM_BUILD_TESTS=OFF -DLIBTERM_BUILD_EXAMPLES=OFF -DLIBTERM_BUILD_BENCH=OFF
cmake --build build-mingw

CI also runs the test suite natively on a Windows runner.