A reimplementation of CMake in Rust. It reads ordinary CMakeLists.txt files, runs the real compiler checks, and writes Ninja build files that are byte-for-byte identical to the ones Kitware CMake 4.1.0 writes for the same project.
It is good enough to configure and build LLVM + Clang 20. Clang's own test suite then reports exactly the same counts as on a build configured by real CMake.
| Project | What was compared | Result |
|---|---|---|
| LLVM + Clang 20.1.8 | every configured and generated file | 619 / 619 identical (after tool-path normalization) |
ninja check-clang on the candidate's build |
4,013 / 4,013 build steps; 42,430 tests pass, 0 fail, counts identical to the Kitware-configured build | |
| Kitware CMake 4.1.0 (CMake building itself) | configured tree, build, then the upstream CTest suite | 312 / 312 files identical; 1,198 / 1,198 build steps; 683 / 683 tests pass |
| zlib 1.3.1 | configure, generate, build, install, tests | all match |
| Upstream RunCMake suite | Ninja, Ninja Multi-Config and extra-generator cases | 5,866 / 5,866 eligible cases pass |
cpack (Rust port) |
Kitware's RunCMake CPack suites scored with the Rust cpack; packaging CMake itself and zlib |
421 / 421 cases pass; the extracted packages are identical (3,995 entries for CMake 4.1.0) |
| Unix Makefiles generator | RunCMake with the Makefiles-configured reference; LLVM and Kitware configure trees; Kitware self-build; zlib; project fuzzing | 5,567 / 5,567 scored RunCMake cases pass, including the <IDE> - Unix Makefiles extra generators; the LLVM 20.1.8 + clang configure tree matches in 22,010 of 22,011 files (the other differs only in CMake-root module paths); CMake configured by the candidate builds itself with make -j6 and passes 683 / 683 tests; zlib builds, tests, installs and rebuilds identically (74/74 tree files) |
ctest (Rust port) |
ctest differential suite; Kitware's CTest RunCMake suites scored with the Rust ctest; every RunCMake suite driven by the Rust ctest |
349 / 349 differential cases; 296 / 296 scored suite cases (submit, command line, test, fixtures, environment, resource allocation, labels); with the Rust ctest installed as bin/ctest and driving every suite, 6,720 / 6,720 scored RunCMake cases pass with Ninja and 6,003 / 6,003 with Unix Makefiles (26 memcheck cases need a memory checker the oracle lane lacks) |
| Windows (in progress; x86_64 MSVC, Windows 11) | the differential harnesses run natively against Kitware CMake 4.1.0 for Windows; generated NMake / NMake JOM / MinGW / MSYS Makefiles trees | difftest 1,459 / 1,459, clitest 641 / 642 (the one failure, a preset ${hostSystemName} macro, is fixed in 71be1f9) (2 skipped: an argument Windows cannot pass, and a case where the Kitware binary itself crashes); NMake Makefiles trees match and build for 7 / 7 project cases (JOM, MinGW and MSYS trees match, not yet built with their own tools); Visual Studio 17 2022: generated .sln / .vcxproj / .vcxproj.filters trees, MSBuild builds and ctest -C results match for 27 / 27 project cases (libraries, DLL exports, object libraries, custom commands and targets, compiler flag tables, precompiled headers, unity builds, source groups, VS_* and MSVC runtime/debug-format properties, resources, imported per-config locations, ExternalProject, -A Win32, -T host=x64, install, tests); older Visual Studio versions are not ported yet |
All of these were measured at commit 4ca7cce (the LLVM configured tree was re-checked at aae8df9: 619 / 619 files identical): the LLVM tree with scripts/treediff.py, the Kitware tree by comparing scripts/kitware-configure.sh oracle and rust trees. The two headline goals were re-run end to end at 6c1bd23 (2026-12-01): LLVM + Clang configured by the candidate (scripts/llvm-configure.sh), built with Ninja (4,013 / 4,013 steps) and ninja check-clang (42,430 passed, 29 expectedly failed, 3,846 unsupported, 10 skipped, 0 failed: the same counts); Kitware CMake 4.1.0 configured by the candidate, built (1,198 / 1,198 steps) and tested with the pinned ctest (683 / 683). The LLVM configured tree is re-checked on every gate run (619 / 619). The reference is Kitware CMake 4.1.0 (2a2c2e0b) built from source with the same flags and the same Ninja.
Beyond those four, about 95 unmodified open-source projects were configured with both tools. For each one, the end-of-configure interpreter state (statediff.py) and every file in the generated build tree (treediff.py) were compared, then the candidate's tree was built and its tests run. All of them match, except as noted below:
| Group | Projects |
|---|---|
| Libraries | fmt, spdlog, nlohmann/json, abseil, protobuf, libpng, curl, SDL2, glfw, Catch2, google benchmark, yaml-cpp, tinyxml2, libjpeg-turbo, brotli, zstd, lz4, libuv, pugixml, cJSON, flatbuffers, OpenCV (core, imgproc), googletest, freetype2, xz |
| More libraries, 2026-11 batch | oneTBB, zlib-ng, libtiff, opus, c-ares, libzmq, mimalloc, glm, Imath, OpenEXR, msgpack-c, SFML, Embree (with ISPC), openal-soft, glslang, simdjson, taskflow, EnTT, meshoptimizer, libogg, libsndfile, json-c, libyaml, PCRE2 |
| More libraries | libgit2, libarchive, expat, libxml2, mbedtls, wolfssl, libssh2, jsoncpp, eigen, gflags, glog, leveldb, raylib, assimp, box2d, bullet3, llama.cpp, whisper.cpp, libwebp, openjpeg, harfbuzz, double-conversion, snappy, nghttp2, libevent, SQLiteCpp, cmocka, Unity, CUDA deviceQuery |
| Fetch at configure time | CLI11, cpr, magic_enum, a CPM.cmake project, an ExternalProject superbuild |
Install, then find_package from a consumer |
fmt, spdlog, yaml-cpp, glfw, nlohmann/json, libjpeg-turbo: the installed trees match too |
| Python extensions, KDE, presets | pybind11, nanobind, extra-cmake-modules (its 88 tests give identical per-test results), Catch2 and microsoft/GSL through their CMake presets (--preset, --build --preset, ctest --preset) |
| Configure-only, large | grpc, VTK (minimal modules), Kokkos |
Toolchain file (CMAKE_SYSROOT, CMAKE_FIND_ROOT_PATH modes) |
double-conversion, jsoncpp, snappy |
| Host packages via Find modules | SDL2, TBB, GTest, Vulkan, BLAS, OpenBLAS, LAPACK, PkgConfig, Threads, OpenSSL, ZLIB, CURL, Python3 |
| Unix Makefiles, 2026-11 sweep | 47 projects (34 above plus argparse, capnproto, cpp-httplib, crow, csv-parser, curlpp, indicators, minizip-ng, nanopb, physfs, poco, quill, rapidyaml, sdl3, tracy, websocketpp, xtensor and more), 4,548 generated files, 41 built with make -j4; CodeBlocks/Eclipse CDT4/Kate over Makefiles in Debug with shared libraries; make install DESTDIR= trees |
Twelve of the libraries were also run in Ninja Multi-Config, Debug and RelWithDebInfo with shared libraries, and the CodeBlocks generator, comparing installed trees as well. LLVM was compared in ten more configurations: more subprojects (lld, mlir, polly, bolt, flang, lldb, clang-tools-extra), the runtimes (both from the top level and standalone), Debug with assertions and shared libraries, the dylib build, all targets, Ninja Multi-Config, and the nested native tablegen build. Every one of those is identical as well.
A re-run on 2026-12-01 of the 57 locally checked-out projects (the first two library rows plus the Unix Makefiles sweep's additions), now also requesting File API replies (codemodel, cache, cmakeFiles, toolchains) and covering Ninja, Unix Makefiles and Ninja Multi-Config, found differences the earlier sweeps had not exercised. In the first pass, 21 of the 114 Ninja and Unix Makefiles runs differed. The real bugs were:
add_definitionsflags missing from File API compile fragments- a subdirectory's own
CMAKE_BUILD_TYPEbeing ignored in single-config generators (argparse) - missing backtraces on custom-command utility dependencies
- per-source compile groups (OpenCV)
- static-library PDB clean paths
- relative-path tops for sources under the build tree
All are fixed with regression tests (de1daa3). With treediff.py --same-path (both tools configure the same directory in turn), 168 of the 171 project × generator trees are byte-identical. The other three are libcbor's _CMakeLTOTest objects, whose GCC LTO section names carry a per-compile random suffix, plus, in Ninja Multi-Config, the order in which Ninja finished that check's two compiles in CMakeConfigureLog.yaml. The LTO differences appear identically when the oracle is compared with itself.
The same 57 projects were also run under five extra generators: CodeBlocks - Ninja, CodeLite - Unix Makefiles, Eclipse CDT4 - Ninja, Kate - Ninja and Sublime Text 2 - Unix Makefiles. Against the de1daa3 build, 277 of the 285 trees were identical. Two real differences were fixed with regression tests (4d5ca62):
- CodeBlocks and Kate project files now list
file(GENERATE)inputs registered during generation (SDL, tinyxml2). - CodeLite projects now use the top project's configuration name (argparse).
The other five are libcbor's LTO objects again.
The earlier sweeps found and fixed six bugs, each with a regression test. The only remaining byte differences are outside CMake's control: a Meson subbuild that cpr runs at configure time (timestamps, random directory names), and linker build IDs in libjpeg-turbo's installed executables, which embed the differing install prefix. The few remaining test failures were checked against the Kitware-configured build and are environmental (fixed ports, missing model files, Docker).
About 134,000 lines of Rust. The only dependencies are small crates for hashing, compression, tar, regex and JSON; the CMake language, generator expressions, policies, the target model, link computation and the Ninja generator are all implemented here.
cargo build --locked --release
target/release/cmake -S path/to/source -B path/to/build -G Ninja
target/release/cmake --build path/to/build
ctest --test-dir path/to/build --output-on-failureYou need Rust 1.87+ (edition 2024), Ninja, and a host C/C++ toolchain.
The project has one rule: real CMake is the oracle. Kitware CMake 4.1.0 is treated as the specification, and every change is tested by running both tools on the same input and diffing what comes out. A feature counts as done when the outputs match exactly, not when its code compiles.
CMakeLists.txt
/ \
Kitware CMake 4.1.0 cmake-rust
\ /
build.ninja, CTest files, install manifests,
file-API replies, exported targets, interpreter state
|
byte-for-byte diff
The harnesses in scripts/:
| Harness | Compares | Size |
|---|---|---|
difftest.py |
script mode (cmake -P): output, errors, exit codes |
1,459 cases |
clitest.py |
the command line: -E tools, --build, --install, presets |
644 cases |
projdiff.py |
project mode: generated files, configure logs, install-tree exports, file-API replies, builds, no-op and touch-rebuild checks; run for Ninja and Unix Makefiles | 574 projects each |
ctestdiff.py, cpackdiff.py |
the Rust ctest and cpack against Kitware's: streams, exit codes, dashboard XML, packages |
361 and 168 cases |
installcasediff.py |
producer/consumer pairs: install and export trees (incl. ELF RUNPATH/SONAME), then a second project's find_package configure and build |
36 cases |
statediff.py |
end-of-configure interpreter state: every variable, cache entry and property | LLVM: 94,998 lines, 0 differences |
treediff.py |
every file of a freshly configured build tree, for any generator (--same-path configures both tools in the same directory) |
~95 real-world projects; 2026-12-01 re-run: 168 / 171 trees identical, the rest oracle-nondeterministic (see above) |
fuzzdiff.py, fuzz_lang.py, fuzz_regex.py, fuzz_file.py, fuzz_find.py, fuzz_cli.py, fuzz_project.py |
random scripts, language-core cmake -P scripts (string/list/math/JSON, conditions, loops, functions and macros, block, argument parsing), generator expressions, regexes, file() sequences, find_*/find_package searches, cmake -E sequences and whole projects (target graphs, usage requirements, PCH, unity, custom commands, install/export), deterministic per --seed; output, errors, traces, generated build trees, builds and cmake --install results |
100,000+ cases across Ninja, Ninja Multi-Config and every extra generator: 0 differences outside one crash case and compressed-archive bytes (which depend on the linked liblzma) |
conformance/ |
Kitware's own RunCMake test suite | see docs/conformance.md |
ninjadiff.py, dapdiff.py, autogendiff.py |
build.ninja structure, the debugger protocol, Qt AUTOGEN |
statediff.py injects itself through CMAKE_PROJECT_TOP_LEVEL_INCLUDES, so it compares the full interpreter state without modifying the project under test. At daa1f60 it shows no differing lines for LLVM, Kitware CMake, zlib, or any of the 128 tests/projects cases whose configure completes, including on a second --reconfigure pass.
To reproduce the zlib check:
cargo test --locked
scripts/stage-prefix.sh # <root>/rust-prefix/bin/cmake + share/cmake-4.1
RUST_CMAKE=<root>/rust-prefix/bin/cmake scripts/verify-zlib.shverify-zlib.sh needs Git, Python 3, Ninja, a C toolchain and a reference Kitware CMake with CTest. It uses two clean copies of zlib v1.3.1 (51b7f2ab) and isolates the Rust side's executable search path. It checks the generated header, the normalized per-target compiler arguments, the upstream tests, the installed paths and exported symbols, four gzip encode/decode pairings, and that a second ninja run is a no-op. Override tool paths with RUST_CMAKE, UPSTREAM_CMAKE, CTEST or NINJA, and set ZLIB_PIN_DIR to reuse a checkout.
The candidate is staged as an installed CMake: bin/cmake, plus share/cmake-4.1 holding the pinned 4.1.0 distribution modules, which are read as data. The Kitware cmake binary is never called by the candidate. The repository also builds a Rust cpack and a Rust ctest; the pinned Kitware ctest remains the independent test runner for the cmake evidence above.
- The CMake language: lexer, interpreter, scoping,
if()conditions, lists, strings, math, regex (a port of CMake's own regex engine),file(), and the policy table up to 4.1. - Generator expressions: the full evaluator, including context checks and diagnostics.
- The target model: usage requirements, link features and strategies, link-line and runtime-path computation, imported targets,
install()andexport(), CPS and pkg-config package info. - Generators: Ninja and Ninja Multi-Config, with the CodeBlocks, CodeLite, Eclipse CDT4, Kate and Sublime Text 2 extra generators. Also C++20 module scanning, precompiled headers and unity builds, Swift, the Fortran pipeline, and CUDA (separable compilation and device linking, checked against nvcc 12; HIP is ported but untested here).
- Around the generator:
try_compile/try_run, CMake presets, the file API, the DAP debugger, Qt AUTOGEN, instrumentation, SARIF output,--system-information,--graphviz, andcmake -Eincluding the MSVC-sidevs_link_*/__create_deftools. - Byte-exact values: CMake strings are byte strings, not UTF-8. Latin-1 files, high-byte tool output and non-UTF-8 cache entries round-trip unchanged, and terminal colors match CMake 4.1.
- Cross-compiling configurations (Darwin, MSVC/clang-cl, Android, AIX, Cygwin/MSYS and others) are generated to match the reference. The build itself runs on the host toolchain.
--explain <target> <flag>prints the dependency path and the source line that put a compile definition, include directory or option on a target. The integration tests check that an explained definition really reaches the compiler.
Each of these fails with an explicit error, never silently:
- The Green Hills MULTI generator. Ninja is the default when no
-Gis given.cmake --helpstill lists every 4.1.0 generator, and picking an unimplemented one fails with a clear message. - Unix Makefiles: Kitware's own configured tree matches the reference file for file except
Makefile.cmake(CMake-root module paths, because the reference reads its modules from its source tree) and the configure log (random try-compile names). All 194tests/projectscases match in both the Ninja and Unix Makefiles lanes;Makefile2dependency lines, which upstream orders by object pointer value, are compared sorted.docs/unix-makefiles-status.mdhas the details. - XCFramework linking, which needs macOS
plutil.
Some upstream outputs are ordered by pointer or hash value and can't be reproduced exactly: the file-API dependencies order, the order of some reserved-name build-database errors, and the order of multiple linked Swift module dependencies in one target.
file(DOWNLOAD) and file(UPLOAD) load the host's libcurl.so.4 at the first transfer. Status and error strings come from the curl_easy_strerror table of the curl 8.14.1 that CMake vendors. LOG output comes from the host libcurl, so its wording can differ.
src/ the implementation (interpreter, commands/, genex/, generator/, presets/, fileapi/, debugger/ ...)
tests/ integration tests: cli/ JSON cases, projects/ end-to-end projects, scripts/ cmake -P cases
scripts/ differential harnesses and oracle runners
compatibility/ the RunCMake conformance baseline
docs/ architecture, target model, conformance notes
legacy/ the first interpreter, kept for reference
Start with docs/architecture.md.
I wrote this with AI coding agents. I designed the harness and the rule that real CMake is the oracle. I split the work into scoped tasks (one CMake subsystem, or one RunCMake suite, per task). The agents ran in parallel worktrees, and a change landed only when the diffs against Kitware came back clean. The commit history shows that loop, one subsystem at a time.
BSD-3-Clause; see LICENSE. This is not Kitware's CMake and is not affiliated with or endorsed by Kitware. "CMake" is a trademark of Kitware, Inc. Behaviour is ported from CMake 4.1.0, and some test inputs are copied verbatim from its test suite with their origin noted in each file. See NOTICE.