# Meson — Fast and User-Friendly Build System > A modern build system designed for speed and simplicity, used by GNOME, systemd, GStreamer, and other major open-source projects. ## Install Save in your project root: # Meson — Fast and User-Friendly Build System ## Quick Use ```bash pip install meson ninja meson setup builddir meson compile -C builddir meson test -C builddir ``` ## Introduction Meson is a build system that prioritizes speed, correctness, and developer experience. It uses a custom domain-specific language that is intentionally not Turing-complete, which makes build files easy to read and prevents the complexity that can accumulate in other build systems. Meson generates Ninja build files by default, which results in fast parallel builds across platforms. ## What Meson Does - Configures and generates build files for C, C++, Rust, Java, Fortran, and other languages - Produces Ninja build files for fast parallel compilation by default - Discovers system dependencies via pkg-config and CMake integration - Supports cross-compilation through machine files - Provides built-in subproject support for vendoring dependencies ## Architecture Overview Meson runs in two phases. The setup phase reads `meson.build` files, evaluates the build description, detects compilers and dependencies, and generates Ninja build files. The compile phase is handled by Ninja, which reads the generated `build.ninja` file and executes the actual compilation. Meson caches configuration results so reconfiguration after small changes is near-instant. The intentionally limited DSL prevents build logic from becoming an unmaintainable program. ## Self-Hosting & Configuration - Install via pip (`pip install meson`), system package manager, or Homebrew - Create a `meson.build` file at the project root with `project()` and `executable()` calls - Run `meson setup builddir` to configure and `meson compile -C builddir` to build - Declare dependencies with `dependency()` which searches pkg-config and CMake modules - Use machine files for cross-compilation: `meson setup --cross-file arm-linux.ini builddir` ## Key Features - Ninja backend delivers faster build times than Make-based systems - Clean DSL that is not Turing-complete, preventing overcomplicated build logic - Built-in support for unity builds to speed up compilation of large projects - WrapDB provides a curated collection of dependency subprojects - Automatic test discovery and integration with continuous integration systems ## Comparison with Similar Tools - **CMake** — more widespread ecosystem; Meson offers a cleaner syntax and faster builds for new projects - **Autotools** — traditional GNU build system; Meson replaces configure/make with a simpler workflow - **Bazel** — designed for massive monorepos; Meson is lighter and quicker to adopt - **SCons** — Python-based; Meson separates build description from build execution via Ninja - **xmake** — Lua-based with built-in package management; Meson focuses on build correctness and simplicity ## FAQ **Q: Why does Meson use Ninja instead of Make?** A: Ninja is designed for speed. It handles dependency tracking and parallel execution more efficiently than Make for large projects. **Q: Can Meson build Rust projects?** A: Yes. Meson has built-in Rust language support including mixed C/Rust projects. **Q: Which major projects use Meson?** A: GNOME desktop, systemd, GStreamer, Mesa graphics drivers, PipeWire, and many other Linux infrastructure projects. **Q: How do I add external dependencies?** A: Use `dependency('pkg-name')` which automatically searches pkg-config and CMake. For vendored deps, use Meson subprojects or WrapDB. ## Sources - https://github.com/mesonbuild/meson - https://mesonbuild.com/ --- Source: https://tokrepo.com/en/workflows/04663ae7-3a9b-11f1-9bc6-00163e2b0d79 Author: AI Open Source