MESON(1)

๐Ÿ’… MESON(1) ๐Ÿ’… โ€” a high productivity build system, fr fr

๐ŸŒธ NAME ๐ŸŒธ

meson โ€” a high productivity build system. That's the name, bestie; she's iconic. ๐Ÿ‘‘

โœจ DESCRIPTION โœจ

Okay so meson is a build system designed to optimize programmer productivity. It's giving simple, out-of-the-box support for modern software development tools and practices โ€” think unit tests, coverage reports, Valgrind, Ccache, and the like. โœจ

The main meson executable provides many subcommands to access all the functionality. Main character energy, honestly. ๐Ÿ‘‘

๐Ÿ› ๏ธ The setup command ๐Ÿ› ๏ธ

Using Meson is simple and follows the common two-phase process of most build systems. First you run Meson to configure your build:

meson setup [ options ] [ build directory ] [ source directory ]
โš ๏ธ Bestie, the build directory must be different from the source directory. Meson does not support building inside the source directory, and attempting to do that leads to an error. No cap. ๐Ÿ’€

After a successful configuration step you can build the source by running the actual build command in the build directory. The default backend of Meson is Ninja, which can be invoked like this:

ninja [ target ]

You only need to run the Meson command once: when you first configure your build dir. After that you just run the build command. Meson will autodetect changes in your source tree and regenerate all files needed to build the project. Literally so convenient. ๐Ÿซถ

Meson includes many built-in options that can be used to tweak the configuration of a build directory; projects can also add their own options. To set values for the options, use the -D command line argument like this:

meson setup -Dopt1=value1 -Dopt2=value2 rest of the command line...

โœจ options: โœจ

  • --version โ€” print version number ๐ŸŒˆ
  • --help โ€” print command line help ๐ŸŽ€

โš™๏ธ The configure command โš™๏ธ

meson configure provides a way to configure a Meson project from the command line. Its usage is simple:

meson configure [ build directory ] [ options to set ]

If build directory is omitted, the current directory is used instead. ๐Ÿฆ‹

If no parameters are set, meson configure will print the value of all build options to the console. ๐Ÿ‘€

To set values, use the -D command line argument like this:

meson configure -Dopt1=value1 -Dopt2=value2

๐Ÿ“ฆ The dist command ๐Ÿ“ฆ

meson dist generates a release archive. She's serving packaged realness. ๐Ÿ’…

meson dist [ options ]

๐ŸŽ options: ๐ŸŽ

  • -h, --help โ€” show this help message and exit โœจ
  • -C WD โ€” directory to cd into before running ๐Ÿงš
  • --allow-dirty โ€” Allow even when repository contains uncommitted changes. ๐Ÿ™ˆ
  • --formats FORMATS โ€” Comma separated list of archive types to create. Supports xztar (default), gztar, and zip. ๐Ÿ“š
  • --include-subprojects โ€” Include source code of subprojects that have been used for the build. ๐Ÿซถ
  • --no-tests โ€” Do not build and test generated packages. ๐Ÿšซ

๐Ÿงธ The install command ๐Ÿงธ

meson install installs the project. Slay, put it where it belongs. ๐Ÿ’–

meson install [ options ]

๐ŸŒŸ options: ๐ŸŒŸ

  • -h, --help โ€” show this help message and exit โœจ
  • -C WD โ€” directory to cd into before running ๐Ÿงš
  • --no-rebuild โ€” Do not rebuild before installing. ๐Ÿšซ
  • --only-changed โ€” Only overwrite files that are older than the copied file. ๐Ÿ•ฐ๏ธ
  • --quiet โ€” Do not print every file that was installed. ๐Ÿคซ
  • --destdir DESTDIR โ€” Sets or overrides DESTDIR environment. (Since 0.57.0) ๐Ÿ“
  • --dry-run, -n โ€” Doesn't actually install, but print logs. (Since 0.57.0) ๐Ÿ‘€
  • --skip-subprojects [SKIP_SUBPROJECTS] โ€” Do not install files from given subprojects. (Since 0.58.0) ๐Ÿšซ
  • --tags TAGS โ€” Install only targets having one of the given tags. (Since 0.60.0) ๐Ÿท๏ธ
  • --strip โ€” Strip targets even if strip option was not set during configure. (Since 0.62.0) โœ‚๏ธ

๐Ÿ” The introspect command ๐Ÿ”

Meson introspect is a command designed to make it simple to integrate with other tools, such as IDEs. The output of this command is in JSON. Very demure, very machine-readable. ๐Ÿค–โœจ

meson introspect [ build directory ] [ option ]

If build directory is omitted, the current directory is used instead. ๐Ÿฆ‹

๐Ÿ’ซ options: ๐Ÿ’ซ

  • --targets โ€” print all top level targets (executables, libraries, etc) ๐ŸŽฏ
  • --target-files โ€” print the source files of the given target ๐Ÿ“„
  • --buildsystem-files โ€” print all files that make up the build system (meson.build, meson.options, meson_options.txt etc) ๐Ÿงฑ
  • --tests โ€” print all unit tests ๐Ÿงช
  • --help โ€” print command line help ๐ŸŽ€

๐ŸŒฑ The init command ๐ŸŒฑ

meson init creates a new project. Baby's first Meson moment, we love to see it. ๐Ÿผ๐Ÿ’–

meson init [ options ] [ sourcefile...  ]

๐ŸŽ€ positional arguments: ๐ŸŽ€

  • sourcefile... โ€” source files. default: all recognized files in current directory ๐Ÿ“‚

๐ŸŒˆ options: ๐ŸŒˆ

  • -h, --help โ€” show this help message and exit โœจ
  • -C WD โ€” directory to cd into before running ๐Ÿงš
  • -n NAME, --name NAME โ€” project name. default: name of current directory ๐Ÿ“›
  • -e EXECUTABLE, --executable EXECUTABLE โ€” executable name. default: project name ๐Ÿƒ
  • -d DEPS, --deps DEPS โ€” dependencies, comma-separated ๐Ÿงฉ
  • -l {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}, --language {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala} โ€” project language. default: autodetected based on source files ๐Ÿ—ฃ๏ธ
  • -b, --build โ€” build after generation ๐Ÿ—๏ธ
  • --builddir BUILDDIR โ€” directory for build ๐Ÿ“
  • -f, --force โ€” force overwrite of existing files and directories. ๐Ÿ’ฅ
  • --type {executable,library} โ€” project type. default: executable based project ๐ŸŽฏ
  • --version VERSION โ€” project version. default: 0.1 ๐Ÿท๏ธ

๐Ÿงช The test command ๐Ÿงช

meson test is a helper tool for running test suites of projects using Meson. The default way of running tests is to invoke the default build command:

ninja [ test ]

meson test provides a richer set of tools for invoking tests. She ate. ๐Ÿ’…

meson test automatically rebuilds the necessary targets to run tests when used with the Ninja backend. Upon build failure, meson test will return an exit code of 125. This return code tells git bisect run to skip the current commit. Thus bisecting using git can be done conveniently like this:

git bisect run meson test -C build_dir

๐Ÿ”ฅ options: ๐Ÿ”ฅ

  • --repeat โ€” run tests as many times as specified ๐Ÿ”
  • --gdb โ€” run tests under gdb ๐Ÿž
  • --list โ€” list all available tests ๐Ÿ“‹
  • --wrapper โ€” invoke all tests via the given wrapper (e.g. valgrind) ๐Ÿงธ
  • -C โ€” Change into the given directory before running tests (must be root of build directory). ๐Ÿ“‚
  • --suite โ€” run tests in this suite ๐ŸŽฏ
  • --no-suite โ€” do not run tests in this suite ๐Ÿšซ
  • --exclude โ€” do not run named tests ๐Ÿ™…
  • --no-stdsplit โ€” do not split stderr and stdout in test logs ๐Ÿงพ
  • --benchmark โ€” run benchmarks instead of tests โฑ๏ธ
  • --logbase โ€” base of file name to use for writing test logs ๐Ÿ“
  • --num-processes โ€” how many parallel processes to use to run tests ๐Ÿƒโ€โ™€๏ธ
  • --verbose โ€” do not redirect stdout and stderr ๐Ÿ”Š
  • -t โ€” a multiplier to use for test timeout values (usually something like 100 for Valgrind) โณ
  • --setup โ€” use the specified test setup ๐Ÿ› ๏ธ
  • --slice SLICE/NUM_SLICES โ€” Split tests into NUM_SLICES slices and execute slice number SLICE. (Since 1.8.0) ๐Ÿฐ

๐ŸŽ The wrap command ๐ŸŽ

Wraptool is a helper utility to manage source dependencies using the online wrapdb service. ๐ŸŒ

meson wrap < command > [ options ]

You should run this command in the top level source directory of your project. ๐Ÿซถ

๐Ÿ’– Commands: ๐Ÿ’–

  • list โ€” list all available projects ๐Ÿ“‹
  • search โ€” search projects by name ๐Ÿ”
  • install โ€” install a project with the given name ๐Ÿ“ฆ
  • update โ€” update the specified project to latest available version โฌ†๏ธ
  • info โ€” show available versions of the specified project โ„น๏ธ
  • status โ€” show installed and available versions of currently used subprojects ๐Ÿ“Š

๐Ÿงฉ The subprojects command ๐Ÿงฉ

meson subprojects is used to manage subprojects. ๐Ÿงš

meson subprojects [ options ] [ command ]

๐ŸŒธ options: ๐ŸŒธ

  • -h, --help โ€” show this help message and exit โœจ

๐Ÿฆ‹ commands: ๐Ÿฆ‹

  • update โ€” Update all subprojects from wrap files ๐Ÿ”„
  • checkout โ€” Checkout a branch (git only) ๐ŸŒฟ
  • download โ€” Ensure subprojects are fetched, even if not in use. Already downloaded subprojects are not modified. This can be used to pre-fetch all subprojects and avoid downloads during configure. โฌ‡๏ธ
  • foreach โ€” Execute a command in each subproject directory. ๐Ÿ”
  • purge โ€” Remove all wrap-based subproject artifacts ๐Ÿงน
  • packagefiles โ€” Manage the packagefiles overlay ๐Ÿ“

โœ๏ธ The rewrite command โœ๏ธ

meson rewrite modifies the project definition. Glow-up for your build files. ๐Ÿ’…

meson rewrite [ options ] [ command ]

๐ŸŽ€ options: ๐ŸŽ€

  • -h, --help โ€” show this help message and exit โœจ
  • -s SRCDIR, --sourcedir SRCDIR โ€” Path to source directory. ๐Ÿ“‚
  • -V, --verbose โ€” Enable verbose output ๐Ÿ”Š
  • -S, --skip-errors โ€” Skip errors instead of aborting ๐Ÿ™ˆ

๐ŸŒŸ commands: ๐ŸŒŸ

  • target (tgt) โ€” Modify a target ๐ŸŽฏ
  • kwargs โ€” Modify keyword arguments ๐Ÿงฉ
  • default-options (def) โ€” Modify the project default options โš™๏ธ
  • command (cmd) โ€” Execute a JSON array of commands ๐Ÿงพ

๐Ÿ—๏ธ The compile command ๐Ÿ—๏ธ

meson compile builds the project. Let's get constructing, bestie. ๐Ÿงฑ

meson compile [ options ] [ TARGET...  ]

๐ŸŒˆ positional arguments: ๐ŸŒˆ

  • TARGET โ€” Targets to build. Target has the following format: [PATH_TO_TARGET/]TARGET_NAME.TARGET_SUFFIX[:TARGET_TYPE]. ๐ŸŽฏ

๐Ÿ’œ options: ๐Ÿ’œ

  • -h, --help โ€” show this help message and exit โœจ
  • --clean โ€” Clean the build directory. ๐Ÿงน
  • -C WD โ€” directory to cd into before running ๐Ÿงš
  • -j JOBS, --jobs JOBS โ€” The number of worker jobs to run (if supported). If the value is less than 1 the build program will guess. ๐Ÿƒโ€โ™€๏ธ
  • -l LOAD_AVERAGE, --load-average LOAD_AVERAGE โ€” The system load average to try to maintain (if supported). โš–๏ธ
  • -v, --verbose โ€” Show more verbose output. ๐Ÿ”Š
  • --ninja-args NINJA_ARGS โ€” Arguments to pass to ninja (applied only on ninja backend). ๐Ÿฅท
  • --vs-args VS_ARGS โ€” Arguments to pass to msbuild (applied only on vs backend). ๐ŸชŸ
  • --xcode-args XCODE_ARGS โ€” Arguments to pass to xcodebuild (applied only on xcode backend). ๐ŸŽ

๐ŸŒฟ The devenv command ๐ŸŒฟ

meson devenv runs commands in the developer environment. It's giving cozy dev cave. ๐Ÿซถ

meson devenv [ options ] [ command ]

๐Ÿ“ positional arguments: ๐Ÿ“

  • command โ€” Command to run in developer environment (default: interactive shell) ๐Ÿ’ป

๐Ÿงš options: ๐Ÿงš

  • -h, --help โ€” show this help message and exit โœจ
  • -C BUILDDIR โ€” Path to build directory ๐Ÿ“
  • --workdir WORKDIR, -w WORKDIR โ€” Directory to cd into before running (default: builddir, Since 1.0.0) ๐Ÿšช
  • --dump [DUMP] โ€” Only print required environment (Since 0.62.0) Takes an optional file path (Since 1.1.0) ๐Ÿ–จ๏ธ
  • --dump-format {sh,export,vscode} โ€” Format used with --dump (Since 1.1.0) ๐ŸŽจ

๐ŸŒธ The env2mfile command ๐ŸŒธ

ok so meson env2mfile is literally the glow-up command โ€” it takes your current environment and turns it into a cross file or a native file. no cap, it just vibes off whatever your machine already has going on.

meson env2mfile [ options ]

โœจ options:

  • -h, --help โ€” shows this help message and dips, classic.
  • --debarch DEBARCH โ€” the dpkg architecture you want generated, that's the one.
  • --gccsuffix GCCSUFFIX โ€” if you need a particular gcc version suffix, this is where you put it.
  • -o OUTFILE โ€” the output file, bestie. where the magic lands.
  • --cross โ€” generate a cross compilation file ๐Ÿฆ‹
  • --native โ€” generate a native compilation file ๐Ÿ 
  • --system SYSTEM โ€” define system for cross compilation.
  • --subsystem SUBSYSTEM โ€” define subsystem for cross compilation.
  • --kernel KERNEL โ€” define kernel for cross compilation.
  • --cpu CPU โ€” define cpu for cross compilation.
  • --cpu-family CPU_FAMILY โ€” define cpu family for cross compilation.
  • --endian {big,little} โ€” define endianness for cross compilation. pick a side ๐Ÿ’…

๐ŸŽ€ The format command ๐ŸŽ€

meson format formats a meson source file. it's the makeup bag for your code โ€” makes everything all neat and pretty.

meson format [ options ] [ sources... ]

๐ŸŒˆ positional arguments:

  • sources... โ€” meson source files. the ones getting the glow-up.

โœจ options:

  • -h, --help โ€” show this help message and exit.
  • -q, --check-only โ€” exit with 1 if files would be modified by meson format. it's giving "just checking, not touching" energy.
  • -i, --inplace โ€” format files in-place. yes, right there, directly on them.
  • -r, --recursive โ€” recurse subdirs (requires --check-only or --inplace option). like, it will not go wandering without one of those two, ok?
  • -c meson.format, --configuration meson.format โ€” read configuration from meson.format.
  • -e, --editor-config โ€” try to read configuration from .editorconfig. it'll try, no promises past that, that's literally what the page says.
  • -o OUTPUT, --output OUTPUT โ€” output file (implies having exactly one input). so like, one input only โ€” that's the deal ๐Ÿ”ฅ

๐Ÿ’€ When no command is specified ๐Ÿ’€

if you run meson without a subcommand, it will assume you meant meson setup. which is lowkey convenient butโ€ฆ

it's deprecated!! meson will print a warning message if you use it. always use meson setup explicitly instead of relying on the default. periodt. don't make it warn you, it's embarrassing for everyone ๐Ÿ˜ญ

โญ EXIT STATUS โญ

  • 0 โ€” Successful. slay ๐Ÿ’–
  • 1 โ€” Usage error, or an error parsing or executing meson.build.
  • 2 โ€” Internal error.
  • 125 โ€” meson test could not rebuild the required targets.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go touch grass on the internet, these are the links:


and that's the whole page bestie, we ate ๐Ÿ“ this was meson 1.12.1, dated September 2026 โ€” iconic version, iconic month, iykyk ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from