Wefti

CMake vs Bazel, and how to get reproducible CMake builds

Bazel uses its own build files to declare the inputs of sandboxed actions. Wefti keeps your CMake files. It can check configure inputs, pin FetchContent sources, and share verified compiler probes and configure data between runners.

What hermetic means for a CMake project

A hermetic build reads only the inputs that it declares. In CMake, configure can read any environment variable, any file on disk, any program on PATH, and the network. Two machines can then configure the same source tree and get different results.

Bazel solves this by running each action in a sandbox and by asking you to declare every input in BUILD files. A move to Bazel means rewriting those build files. Wefti takes a smaller step. It audits what configure reads and pins what configure downloads.

Hermetic features in Wefti and Bazel
AreaWefti 0.4.0Bazel
Project inputCMakeLists.txt, presetsBUILD files, MODULE.bazel
Rewrite from CMakeNoneEvery build file
Undeclared configure inputs--hermetic=warn reports them and --hermetic=strict rejects themSandboxed actions
Pinned dependencieswefti.lock or wefti-fetch.lock for FetchContent archives and Git commitsModule lockfile and external repositories
Remote cacheProbe archives and remote caching for probes and configure data over HTTPS, S3, or GitHub Actions Cache v2Local and remote action cache
Remote executionNoYes
Sources

The Bazel column comes from Bazel remote caching and Bazel sandboxing. The Wefti column comes from the tooling guide and the caching guide.

Make a CMake build more reproducible

Do these steps in order. Each one narrows the inputs of your configure step.

  1. Pin FetchContent sources. Run wefti -S . -B build --fetch-lock=update once. Wefti writes archive hashes and Git commits to wefti-fetch.lock. Commit that file.
  2. Audit what configure reads. Run wefti -S . -B build --hermetic=warn. The report lists undeclared environment reads, files outside the project, child processes, and network access.
  3. Declare the inputs that you accept. Set WEFTI_HERMETIC_ALLOW_ENV, WEFTI_HERMETIC_ALLOW_PATHS, and WEFTI_HERMETIC_ALLOW_PROGRAMS for reads that you want to allow.
  4. Freeze CI. Configure with --hermetic=strict --fetch-lock=frozen and WEFTI_FETCH_OFFLINE=1. Frozen mode needs the lockfile and rejects a declaration that differs from its pin.
  5. Share verified probes. Export the probe cache from one trusted job with wefti cache export and import it elsewhere with wefti cache import --sha256.
wefti -S . -B build --fetch-lock=update
wefti -S . -B build --hermetic=warn
WEFTI_FETCH_OFFLINE=1 wefti -S . -B build --hermetic=strict --fetch-lock=frozen
wefti cache export probes.tar.gz

What stays outside Wefti

The hermetic audit covers configure. It does not sandbox the compiler, the linker, or custom build commands, and it does not run actions on remote machines. If your repository needs sandboxed actions, remote execution, or one cache for every action at scale, Bazel does that work and Wefti does not.

Hermetic and profile runs turn off incremental replay, so use them for audits and for CI checks. Use a plain native configure when you want the fastest repeat.

Use native wefti cache remote to check the connection, wefti cache pull to restore a pack, and wefti cache push to save eligible entries. On GitHub Actions, wefti/wefti/actions/setup-wefti@v0.4.0 runs on Node.js 24 and enables GitHub Actions Cache v2. The names cmake, ctest, cpack, and ccmake use CMake 4.5.1 compatibility mode. See the CI cache guide.

A reproducible archive is a smaller goal that Wefti does reach. cmake -E tar and CPack archives record user and group 0, and wefti cache export writes the same bytes for the same cache content.

Wefti v0.4.0 was faster than CMake 4.5.1 in 37 of 40 matched workloads. The peer benchmark measured Wefti, CMake, Meson, Muon, Premake5, and Xmake. See the peer results.

Frequently asked questions

Is Bazel better than CMake for reproducible builds?

Bazel sandboxes actions and tracks every declared input, so it goes further than CMake. A move needs new build files. Wefti keeps CMake and adds configure audits and lockfiles.

How do I make a CMake build hermetic?

Run --hermetic=warn to find undeclared reads, declare the ones you accept, and then use --hermetic=strict in CI. Add --fetch-lock=frozen so FetchContent downloads match pinned hashes.

Is there a lockfile for CMake FetchContent?

Wefti writes wefti-fetch.lock with --fetch-lock=update. It pins archive hashes and Git commits. The modes are off, auto, update, and frozen.

Can I run a CMake configure offline?

Yes, when a lockfile pins your sources. Configure with --fetch-lock=frozen and WEFTI_FETCH_OFFLINE=1. Wefti can download pinned sources before FetchContent_MakeAvailable() asks for them when you are online.

Does Wefti give me remote caching like Bazel?

Wefti shares verified compiler probes and some configure results. This cache covers compiler detection and toolchain checks. Bazel caches the outputs of build actions and can run those actions remotely.

Do cmake and ctest run the hermetic checks?

No. The names cmake, ctest, cpack, and ccmake select compatibility mode, which behaves like CMake 4.5.1. Run the native wefti command to use --hermetic and --fetch-lock.