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. Supportsxztar(default),gztar, andzip. ๐--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 overridesDESTDIRenvironment. (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.txtetc) ๐งฑ--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 like100for Valgrind) โณ--setupโ use the specified test setup ๐ ๏ธ--slice SLICE/NUM_SLICESโ Split tests intoNUM_SLICESslices and execute slice numberSLICE. (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 than1the 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 toninja(applied only onninjabackend). ๐ฅท--vs-args VS_ARGSโ Arguments to pass tomsbuild(applied only onvsbackend). ๐ช--xcode-args XCODE_ARGSโ Arguments to pass toxcodebuild(applied only onxcodebackend). ๐
๐ฟ 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 with1if files would be modified bymeson 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-onlyor--inplaceoption). like, it will not go wandering without one of those two, ok?-c meson.format,--configuration meson.formatโ read configuration frommeson.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 executingmeson.build.2โ Internal error.125โmeson testcould 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
- arch rolling: meson 1.12.1-2 ยท Apache-2.0
- nixpkgs unstable: meson 1.12.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms