CMake has been growing for 20 years, and many major projects have switched to CMake from legacy build systems. Meson can replace CMake or be used alongside CMake. CMake’s long lifetime leaves legacy CMake 2.x scripts with difficult to understand behavior and variable scope. CMake 3.x made considerable modernization, and proposed auxiliary declarative CMake language is being discussed by Kitware.
Meson’s syntax is more declarative than CMake and is non-Turing complete without user functions. Key Meson goals include making meson.build script easier to understand while speeding up the build process itself. Meson vs. CMake is not an either-or choice. For most of our projects we provide both CMake and Meson scripts so that it’s easy for both build systems to be independently used.
pip install meson
Meson most commonly uses the Ninja build backend, which we also recommend for CMake. Ninja can be downloaded or:
pip install ninja
A typical new Meson build starts like:
meson build # from top meson.build directory
meson compile -C build
By default, Ninja builds in parallel.
Convert CMakeLists.txt to meson.build using
which makes a first pass at recursively converting
The developer will need to manually complete this conversion process, but this script helps eliminate some of the tedious parts.