meson: Usage, Options & Common CI Errors
meson configures a project from meson.build and builds it via ninja.
meson is the modern alternative to autotools/CMake for C/C++ and others. The CI flow is setup then compile; the recurring errors are re-running setup on an existing build dir and missing pkg-config dependencies during configure.
What it does
meson reads a meson.build description, configures a build directory (resolving dependencies, often via pkg-config), and then builds through ninja. It emphasizes fast, reproducible, out-of-source builds with a simple DSL.
Common usage
meson setup build # configure
meson setup build --buildtype=release
meson compile -C build # build (wraps ninja)
meson test -C build # run the test suite
meson setup --reconfigure build # re-run on existing dirOptions
| Command / flag | What it does |
|---|---|
| setup <dir> | Configure a build directory |
| compile -C <dir> | Build (portable wrapper over ninja) |
| test -C <dir> | Run the project tests |
| --buildtype=release|debug | Set optimization/debug profile |
| --reconfigure / --wipe | Reconfigure / wipe + reconfigure |
| -D<opt>=<val> | Set a project or built-in option |
Common errors in CI
"Directory already configured" / "Build directory already exists" - meson setup refuses to overwrite; use meson setup --reconfigure build (or --wipe) on cache restore. "Dependency ‘foo’ not found, tried pkgconfig" means the .pc file is missing - install the -dev package or set PKG_CONFIG_PATH. "Program ‘ninja’ not found" - install ninja-build. Pin meson via pip in CI; distro meson is often too old for newer meson.build syntax.