Meson Build System
Meson is a high-performance, cross-platform build system designed to be both extremely fast and user-friendly. It supports numerous programming languages (C, C++, Rust, Fortran, Java, Python, etc.) and compilers, using a simple, non-Turing complete domain-specific language (DSL) for defining builds. The project aims for a major release approximately every 3-4 months, with bugfix releases in between.
Warnings
- deprecated The `meson.build_root()` and `meson.source_root()` functions are deprecated as they often cause issues in subprojects by pointing to the parent project's root.
- deprecated Coercing string values (e.g., `'false'`) to boolean types in the `option()` function is deprecated and will result in a warning.
- breaking Using a colon (':') in test names is deprecated and will be replaced with an underscore ('_') internally, to avoid conflicts with the `subproject:testname` syntax for running subproject-specific tests.
- gotcha The `meson dist` command will error if the Git repository contains uncommitted changes. This is a stricter behavior to prevent accidental releases of non-committed code.
- breaking Meson 1.10.0 introduced a 'platform' naming scheme for libraries, which will eventually become the default, potentially altering library filenames (e.g., on Windows, static libraries might change from `.a` to `.lib`, and import libraries from `.lib` to `.dll.lib`).
- gotcha Performance regression in `pkg-config` dependency lookup in Meson 1.10.0, potentially making `meson setup` significantly slower for projects with many `pkg-config` dependencies due to new linkability checks.
Install
-
pip install meson -
sudo apt-get install python3 ninja-build meson
Imports
- Meson DSL
Meson is primarily used via its command-line interface and build definition files (e.g., meson.build), not typically through direct Python imports for general build orchestration. Python modules within Meson's DSL are imported using the `import()` function (e.g., `python = import('python')`).
Quickstart
mkdir myproject
cd myproject
echo '#include <stdio.h>\nint main() { printf("Hello from Meson!\n"); return 0; }' > main.c
echo "project('hello_meson', 'c')\nexecutable('hello', 'main.c', install: true)" > meson.build
meson setup builddir
meson compile -C builddir
./builddir/hello
meson install -C builddir