Convert CMake to Meson

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 script easier to understand while speeding up the build process itself. Meson vs. CMake is not an either-or choice. Projects can 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 directory

meson compile -C build

By default, Ninja builds in parallel.

Convert CMakeLists.txt to using tools/, which makes a first pass at recursively converting CMakeLists.txt to The developer will need to manually complete this conversion process, but this script helps eliminate some of the tedious parts.