Use Rust with CMake or replace CMake with Wefti
A Rust CMake is a build tool that reads your CMakeLists.txt and runs without upstream CMake. Wefti is one. This page lists what is Rust, what is not, and what you can check yourself.
Three ways to use Rust and CMake
| Your task | Tool | Files or commands to change | Who configures the project |
|---|---|---|---|
| Build C or C++ from Cargo | cmake-rs | Add the cmake crate to Cargo.toml and call it in build.rs. Keep the native project files. | The CMake executable that Cargo finds |
| Build Rust from CMake | Corrosion | Add corrosion_import_crate to CMakeLists.txt. Keep the Rust crate and its Cargo.toml. | CMake configures the project. Cargo builds the Rust crate. |
| Replace the CMake executable | Wefti | Keep CMakeLists.txt and presets. Run wefti or use its cmake alias. | Wefti configures the project and generates native build files. |
Follow the replacement guide if you want to keep your CMake inputs. Check the compatibility report before you switch.
What a native Rust CMake is
Wefti is a new implementation of CMake 4.5.1. It is not a wrapper and it is not a set of bindings. It has its own lexer, parser, evaluator, generator expression engine, and generators for Ninja, Makefiles, Xcode, and Visual Studio. The project contains no copied or translated CMake C++ source, and the engine never starts an upstream cmake at run time.
The bundled CMake 4.5.1 modules and templates are written in the CMake language, so the Rust evaluator runs them as they are. They keep their BSD-3-Clause license and notices. The engine and tools use MIT OR Apache-2.0.
| Area | CMake 4.5.1 | Wefti v0.4.0 |
|---|---|---|
| Written in | C++ | 43 Rust crates |
| Programs | Separate cmake, ctest, cpack, and ccmake programs | One multi-call program |
| Project input | CMakeLists.txt, presets | CMakeLists.txt, presets |
| Unsafe code in the project | Not applicable | Forbidden except in one audited Windows file |
| Measured install size on macOS arm64 | 250.6 MiB | 25.7 MiB |
| Benchmark speed | Baseline | Faster in 37 of 40 matched workloads |
| License | BSD-3-Clause | MIT OR Apache-2.0, with BSD-3-Clause for the bundled modules |
Sources
The Wefti column comes from the full technical reference and the v0.4.0 benchmarks. The architecture records are in docs/ADR.md.
Where memory safety stops
Workspace lints forbid unsafe code in 42 of 43 Rust crates. ADR-056 permits unsafe code in one audited file, crates/wefti-winproc/src/ffi.rs, for the Windows process interface. The license scan checks this restriction. Engine lints also reject unwrap, expect, and panic. The engine limits recursion, expansion, and file size for inputs.
Some dependencies, such as rustix and memchr, use unsafe Rust. The native program also links the zstd and liblzma C libraries for archive support.
In v0.4.0, the seeded fuzz tests ran 14,000,000 inputs across 14 formats and found 0 failures.
One program, several names
The program looks at the name you call it by. Called as cmake, ctest, cpack, or ccmake, it behaves like CMake 4.5.1. Called as wefti, it adds the probe cache, replay, and tools such as wefti explain and wefti lint --fix. The install script takes --alias-cmake to link the CMake names to the one program, and wefti-lsp is a link to it too.
The standalone v0.4.0 executable for macOS arm64 is 17.50 MiB (18,352,560 bytes). It is 0.89 MiB smaller than the 18.39 MiB executable in v0.3.1. It includes the CMake 4.5.1 data (ADR-063). Run wefti build to build with the built-in Ninja 1.13.2 executor.
Check a Rust CMake on your project
Run these steps on a copy of your project. Your files stay unchanged, so you can go back to CMake at any time.
- Install Wefti. Use the release installer, Homebrew, Scoop, or Nix.
- Compare with your own CMake. Run
wefti verifywith a CMake 4.5.1 binary. It compares the configure result, codemodel, cache,compile_commands.json, and the Ninja dry run. It uses your binary only to compare. - Configure with the native command. Run
wefti -S . -B build -G Ninja. - Build with the built-in Ninja executor. Run
wefti build build.
wefti verify --oracle /path/to/cmake-4.5.1 -- -S . -G Ninja
wefti -S . -B build -G Ninja
wefti build build
Use the engine from Rust or the browser
The wefti-api crate gives a Rust program configure and explain as a Git dependency. With default-features = false, it compiles to wasm32-unknown-unknown and wasm32-wasip1 with no C dependencies. The browser playground runs that build on an in-memory host. It uploads no files and compiles no code.
When to keep upstream CMake
Wefti v0.4.0 passed 27,953 of 27,953 targeted RunCMake cases (100.00%) across 1,099 of 1,099 suites, with zero failures. On macOS, it passed 9,706 of 9,706 cases across 371 of 371 suites. On Linux, it passed 9,373 of 9,373 cases across 362 of 362 suites. On Windows, it passed 8,874 of 8,874 cases across 366 of 366 suites.
The sealed blind holdout included 240 repositories. Of the 77 eligible repositories, 72 (93.51%) matched CMake under the strict L1 configure checks. Configure succeeded for 76 of 78 eligible repositories (97.44%). There were zero find-module failures.
Keep upstream CMake if you need cmake-gui, an omitted legacy generator, or Visual Studio 14 to 16. Run wefti verify on a copy of your project to check parity.
Frequently asked questions
Is there a CMake written in Rust?
Yes. Wefti is a new implementation of CMake 4.5.1 in Rust. It reads your existing CMakeLists.txt files and presets and runs as cmake, ctest, cpack, and ccmake.
Is Wefti memory safe?
Wefti's own code forbids unsafe Rust except in one audited Windows file. Some libraries that it uses contain unsafe code, and the native program links the zstd and liblzma C libraries, so the process is not free of C code.
Does Wefti use the real CMake underneath?
No. The engine contains no CMake C++ code and never starts an upstream cmake. The wefti verify command runs a CMake 4.5.1 binary that you supply, and it does so only to compare results.
Can I use Wefti as a single binary in CI?
Yes. One program provides cmake, ctest, cpack, ccmake, and wefti-lsp. The wefti/wefti/actions/setup-wefti@v0.4.0 action installs a verified release on Linux, macOS, and Windows runners. The binary includes the CMake data.
Can I embed CMake in a Rust program or run it in WebAssembly?
Yes. The wefti-api crate gives Rust programs configure and explain as a Git dependency. It builds for wasm32-unknown-unknown and wasm32-wasip1, and the browser playground uses that build.
Is a Rust CMake faster?
On an Apple M1, Wefti v0.4.0 was faster than CMake 4.5.1 in 37 of 40 matched workloads. The speed ratios ranged from 0.97x to 138.17x. Across five large C++ projects, the geometric mean speedups were 1.31x for cold configure, 2.21x with a warm probe cache, and 2.24x after a leaf edit. Reconfiguring after an edit in one directory of the synthetic project took 58.26 ms at the median and 58.60 ms at the 95th percentile.