Wefti

Why is CMake configure so slow?

A slow configure usually comes from the same few causes. Wefti removes some of them and gives you tools to find the rest.

CMake configure is slow when it repeats compiler checks in every new build tree, evaluates the whole project after a small edit, or regenerates Ninja files that did not change. The native wefti command shares a verified probe cache, replays unchanged directories, and skips unchanged Ninja generation. In v0.3.0, the geometric mean for five large projects was 1.35x cold, 2.17x with a warm probe cache, and 2.54x after a leaf edit.

The common causes

Wefti has a feature for each of the first three. It runs independent literal compile probes in parallel, saves each result with the SHA-256 digest of its inputs, and reuses it in later build trees. It replays directories that did not change from CMakeFiles/wefti/configure.v1.bin. It skips Ninja generation when all recorded inputs match. The skip first happens on the third configure of a new build tree.

Speed on LLVM, Qt, OpenCV, DuckDB, and Protobuf

These are the v0.3.0 results against CMake 4.5.1 on an Apple M1. Each number is the speedup of the median time.

Wefti speedup over CMake 4.5.1 on five large projects
ProjectColdWarm probe cacheLeaf edit
DuckDB v1.3.21.60x2.29x5.66x
OpenCV 4.12.01.91x4.38x3.35x
Protobuf v36.21.09x1.88x1.90x
Qt Base v6.8.31.15x1.51x2.51x
LLVM llvmorg-20.1.81.19x1.70x1.17x
Geometric mean1.35x2.17x2.54x

Across all 40 workloads, Wefti was faster than CMake, from 1.09x to 39.81x. A synthetic project with 500 targets and a warm cache reached 39.81x. The full tables are on the benchmarks page.

Find and fix the slow part

Use these steps on a project that configures slowly. Each step adds one tool.

  1. Profile one configure. Run wefti -S . -B build --profile. Open build/wefti-profile/flamegraph.html to see which commands take the time.
  2. Run the same configure again. Repeat in the same build directory and in a new one. The probe cache and replay act on the repeats.
  3. Compare two build trees. Run wefti diff-config build-before build-after to see which flags, definitions, or packages changed.
  4. Check for a stale cache. Run wefti doctor -B build to find a compiler, toolchain file, or prefix path that changed under the build tree.
wefti -S . -B build --profile
wefti unused -B build
wefti graph -B build --highlight-public-bloat
wefti diff-config build-before build-after --only compile,link
wefti doctor -B build

--profile writes trace.json, stacks.folded, and an interactive flamegraph.html into <build>/wefti-profile. Profile runs turn off incremental replay, so they measure a full configure.

Why did CMake rebuild?

Ninja prints the reason for each rebuild when you run ninja -d explain. If the reason is a changed command line, wefti diff-config shows which flag, definition, or include directory changed between two build trees. It reads the CMake File API replies, CMakeCache.txt, and compile_commands.json, and it never runs cmake.

wefti explain app -B build --flag -O2 then shows where one flag comes from, through PRIVATE, PUBLIC, and INTERFACE links. wefti graph --target app --reverse lists the targets that depend on a library, which shows how far one change spreads. To find dependencies that nothing needs, run wefti unused.

wefti diff-config build-main build-pr
wefti explain app -B build --flag -O2
wefti graph -B build --target zlib --reverse

Frequently asked questions

Why is CMake configure so slow?

The usual causes are repeated compiler probes, full re-evaluation after a small edit, repeated Ninja generation, and repeated downloads. Run wefti -S . -B build --profile to see which commands take the time.

Why is try_compile slow, and can I cache it?

Each try_compile builds a small program. Native Wefti runs independent probes in parallel and saves each result with the SHA-256 digest of its inputs, so later configures reuse it. Use wefti cache export and wefti cache import --sha256 to share results between runners.

How do I speed up CMake for LLVM, Qt, or OpenCV?

Configure with the native wefti command. In v0.3.0, the warm probe cache gave 1.70x on LLVM, 1.51x on Qt Base, and 4.38x on OpenCV. A leaf edit gave 1.17x, 2.51x, and 3.35x.

How do I find which dependencies my CMake project does not use?

Run wefti unused -B build. It reports packages that find_package() found and nothing uses, duplicate links, empty INTERFACE links, and unused variables. Use --deny to fail CI on findings.

How do I see the CMake target dependency graph?

Run wefti graph -B build. It prints a tree, or DOT, Mermaid, or JSON with --format. It finds cycles and marks PUBLIC links that can be PRIVATE.

Why did my CMake build rebuild everything?

Run ninja -d explain to see the reason. If a command line changed, run wefti diff-config on the two build trees to see the changed flags, definitions, and include directories.