How to speed up CMake configure
Use wefti in native mode to reuse verified compiler checks across build directories. The synthetic warm-probe test ran 7.16x as fast as CMake 4.5.1. Across DuckDB, OpenCV, Protobuf, Qt Base, and LLVM, the geometric mean speedups were 1.25x cold, 1.72x with a warm probe cache, and 1.50x after a leaf edit.
What takes time during configure
When you create a build directory, CMake runs compiler and linker checks such as try_compile(). These checks can run in sequence and repeat for each new directory. When CMake configures an existing tree, it can reuse results in CMakeCache.txt, but it still evaluates the directory scripts.
The wefti evaluator runs in Rust. In native mode it stores eligible probe results by content and checks recorded inputs with SHA-256, including the compiler binary. It can run up to four independent literal compile probes at once. After a leaf edit, it can replay unchanged directory results. With a vcpkg toolchain or a preset, it still runs setup and checks that setup inputs and state match before using replay.
Reuse compiler probes locally and in CI
- Install wefti. Install the same wefti release on the producer and consumer. Use the same compiler and toolchain paths. See the installation guide.
- Fill the probe cache. Set WEFTI_PROBE_CACHE_DIR and configure once with wefti to record verified compiler probes.
- Reuse verified results. Configure a fresh build tree with the same probe cache. On another runner, import an archive with the SHA-256 digest from a trusted producer.
export WEFTI_PROBE_CACHE=readwrite
export WEFTI_PROBE_CACHE_DIR="$HOME/.cache/wefti-probes"
wefti -S . -B build-first -G Ninja
wefti -S . -B build-second -G Ninja
wefti cache export probes.tar.gz
In continuous integration (CI), run this Bash step once the trusted job's artifact is available. The file probes.sha256 must contain only the digest from the producer job. The complete workflow shows both jobs.
export WEFTI_PROBE_CACHE=readwrite
export WEFTI_PROBE_CACHE_DIR="$RUNNER_TEMP/wefti-probes"
wefti cache import probes.tar.gz --sha256 "$(cat probes.sha256)"
wefti -S . -B build -G Ninja
Reuse the same compiler and toolchain paths on both runners. If a recorded input changes, wefti runs the check again.
Configure benchmark results
The large projects ran 1.20x to 1.46x as fast on cold configure. The synthetic cold test with 500 targets reached 2.24x. The small-project cold results ranged from 1.17x to 1.34x. Each row compares the same workload under the conditions in the complete benchmark report.
| Project | Cold | Warm probe cache | Leaf edit |
|---|---|---|---|
| DuckDB | 1.20x | 1.52x | 1.50x |
| OpenCV | 1.46x | 1.47x | 2.07x |
| Protobuf | 1.22x | 2.08x | 1.29x |
| Qt Base | 1.21x | 1.75x | 1.44x |
| LLVM | 1.20x | 1.83x | 1.31x |
| Workload | wefti (ms) | CMake 4.5.1 (ms) | Speedup | wefti peak RSS (MiB) | CMake peak RSS (MiB) |
|---|---|---|---|---|---|
| corpus zlib 1.3.1 (cold) | 847.54 | 1129.66 | 1.33x | 46.60 | 35.90 |
| corpus fmt 11.2.0 (cold) | 805.55 | 944.92 | 1.17x | 42.60 | 38.20 |
| corpus nlohmann/json 3.12.0 (cold) | 441.89 | 591.61 | 1.34x | 38.80 | 38.00 |
| Workload | wefti (ms) | CMake 4.5.1 (ms) | Speedup | wefti peak RSS (MiB) | CMake peak RSS (MiB) |
|---|---|---|---|---|---|
| configure 100 targets (cold) | 429.25 | 518.03 | 1.21x | 38.90 | 36.00 |
| configure 100 targets (warm) | 89.47 | 171.48 | 1.92x | 24.50 | 22.70 |
| configure 500 targets (cold) | 1288.17 | 2881.54 | 2.24x | 142.20 | 116.20 |
| configure 500 targets (warm) | 933.70 | 2469.96 | 2.65x | 131.60 | 114.20 |
| synthetic (cold configure) | 2935.59 | 3917.22 | 1.33x | 40.16 | 36.36 |
| synthetic (warm probe-cache configure) | 522.36 | 3738.91 | 7.16x | 35.80 | 35.95 |
| synthetic (incremental-leaf) | 61.46 | 137.90 | 2.24x | 24.20 | 21.20 |
| Local FetchContent (cold FetchContent configure) | 332.29 | 418.90 | 1.26x | 26.86 | 26.86 |
| Local FetchContent (warm-fetch) | 180.35 | 312.62 | 1.73x | 17.34 | 16.36 |
Frequently asked questions
Why is my CMake configure slow?
A fresh build directory can repeat compiler and linker probes. Reconfiguring can also spend time re-evaluating directory scripts. The time depends on the project, compiler, and dependency setup.
How much faster is warm configure with wefti?
In v0.2.2, the synthetic warm-probe configure ran 7.16x as fast as CMake 4.5.1. The geometric mean for the five large projects was 1.72x.
Can I share the probe cache between CI runners?
Yes. Export it with wefti cache export and import it with wefti cache import --sha256. Get the digest from a trusted producer and keep compiler and toolchain paths consistent.
Does the cmake alias turn on the shared probe cache?
Use the wefti command for the native defaults. The cmake alias selects compatibility mode.