Debian Codegraph @

man/meson.1

raw
1 .TH MESON "1" "August 2026" "meson 1.12.0" "User Commands"
2 .SH NAME
3 meson - a high productivity build system
4 .SH DESCRIPTION
5
6 Meson is a build system designed to optimize programmer
7 productivity. It aims to do this by providing simple, out-of-the-box
8 support for modern software development tools and practices, such as
9 unit tests, coverage reports, Valgrind, Ccache and the like.
10
11 The main Meson executable provides many subcommands to access all
12 the functionality.
13
14 .SH The setup command
15
16 Using Meson is simple and follows the common two-phase
17 process of most build systems. First you run Meson to
18 configure your build:
19
20 .B meson setup [
21 .I options
22 .B ] [
23 .I build directory
24 .B ] [
25 .I source directory
26 .B ]
27
28 Note that the build directory must be different from the source
29 directory. Meson does not support building inside the source directory
30 and attempting to do that leads to an error.
31
32 After a successful configuration step you can build the source by
33 running the actual build command in the build directory. The default
34 backend of Meson is Ninja, which can be invoked like this.
35
36 \fBninja [\fR \fItarget\fR \fB]\fR
37
38 You only need to run the Meson command once: when you first configure
39 your build dir. After that you just run the build command. Meson will
40 autodetect changes in your source tree and regenerate all files
41 needed to build the project.
42
43 Meson includes many built-in options that can be used to tweak the
44 configuration of a build directory; projects can also add their
45 own options. To set values for the options, use the \-D command
46 line argument like this:
47
48 .B meson setup \-Dopt1=value1 \-Dopt2=value2
49 .I rest of the command line...
50
51 .SS "options:"
52 .TP
53 \fB\-\-version\fR
54 print version number
55 .TP
56 \fB\-\-help\fR
57 print command line help
58
59 .SH The configure command
60
61 .B meson configure
62 provides a way to configure a Meson project from the command line.
63 Its usage is simple:
64
65 .B meson configure [
66 .I build directory
67 .B ] [
68 .I options to set
69 .B ]
70
71 If build directory is omitted, the current directory is used instead.
72
73 If no parameters are set,
74 .B meson configure
75 will print the value of all build options to the console.
76
77 To set values, use the \-D command line argument like this.
78
79 .B meson configure \-Dopt1=value1 \-Dopt2=value2
80
81 .SH The dist command
82
83 .B meson dist
84 generates a release archive.
85
86 .B meson dist [
87 .I options
88 .B ]
89
90 .SS "options:"
91 .TP
92 \fB\-h, \-\-help\fR
93 show this help message and exit
94
95 .TP
96 \fB\-C WD\fR
97 directory to cd into before running
98
99 .TP
100 \fB\-\-allow-dirty\fR
101 Allow even when repository contains uncommitted changes.
102
103 .TP
104 \fB\-\-formats FORMATS\fR
105 Comma separated list of archive types to create. Supports xztar
106 (default), gztar, and zip.
107
108 .TP
109 \fB\-\-include\-subprojects\fR
110 Include source code of subprojects that have been used for the build.
111
112 .TP
113 \fB\-\-no\-tests\fR
114 Do not build and test generated packages.
115
116 .SH The install command
117
118 .B meson install
119 installs the project.
120
121 .B meson install [
122 .I options
123 .B ]
124
125 .SS "options:"
126
127 .TP
128 \fB\-h, \-\-help\fR
129 show this help message and exit
130
131 .TP
132 \fB\-C WD\fR
133 directory to cd into before running
134
135 .TP
136 \fB\-\-no-rebuild\fR
137 Do not rebuild before installing.
138
139 .TP
140 \fB\-\-only\-changed\fR
141 Only overwrite files that are older than the copied file.
142
143 .TP
144 \fB\-\-quiet\fR
145 Do not print every file that was installed.
146
147 .TP
148 \fB\-\-destdir DESTDIR\fR
149 Sets or overrides DESTDIR environment. (Since 0.57.0)
150
151 .TP
152 \fB\-\-dry\-run, \-n\fR
153 Doesn't actually install, but print logs. (Since 0.57.0)
154
155 .TP
156 \fB\-\-skip\-subprojects [SKIP_SUBPROJECTS]\fR
157 Do not install files from given subprojects. (Since 0.58.0)
158
159 .TP
160 \fB\-\-tags TAGS\fR
161 Install only targets having one of the given tags. (Since 0.60.0)
162
163 .TP
164 \fB\-\-strip\fR
165 Strip targets even if strip option was not set during
166 configure. (Since 0.62.0)
167
168 .SH The introspect command
169
170 Meson introspect is a command designed to make it simple to integrate with
171 other tools, such as IDEs. The output of this command is in JSON.
172
173 .B meson introspect [
174 .I build directory
175 .B ] [
176 .I option
177 .B ]
178
179 If build directory is omitted, the current directory is used instead.
180
181 .SS "options:"
182 .TP
183 \fB\-\-targets\fR
184 print all top level targets (executables, libraries, etc)
185 .TP
186 \fB\-\-target\-files\fR
187 print the source files of the given target
188 .TP
189 \fB\-\-buildsystem\-files\fR
190 print all files that make up the build system (meson.build, meson.options, meson_options.txt etc)
191 .TP
192 \fB\-\-tests\fR
193 print all unit tests
194 .TP
195 \fB\-\-help\fR
196 print command line help
197
198 .SH The init command
199
200 .B meson init
201 creates a new project
202
203 .B meson init [
204 .I options
205 .B ] [
206 .I sourcefile...
207 .B ]
208
209 .SS "positional arguments:"
210 .TP
211 sourcefile...
212 source files. default: all recognized files in current directory
213
214 .SS "options:"
215 .TP
216 \fB\-h, \-\-help\fR
217 show this help message and exit
218
219 .TP
220 \fB\-C WD\fR
221 directory to cd into before running
222
223 .TP
224 \fB\-n NAME, \-\-name NAME\fR
225 project name. default: name of current directory
226
227 .TP
228 \fB\-e EXECUTABLE, \-\-executable EXECUTABLE\fR
229 executable name. default: project name
230
231 .TP
232 \fB\-d DEPS, \-\-deps DEPS\fR
233 dependencies, comma-separated
234
235 .TP
236 \fB\-l {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}, \
237 \-\-language {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}\fR
238 project language. default: autodetected based on source files
239
240 .TP
241 \fB\-b, \-\-build
242 build after generation
243
244 .TP
245 \fB\-\-builddir BUILDDIR\fR
246 directory for build
247
248 .TP
249 \fB\-f, \-\-force\fR
250 force overwrite of existing files and directories.
251
252 .TP
253 \fB\-\-type {executable,library}\fR
254 project type. default: executable based project
255
256 .TP
257 \fB\-\-version VERSION\fR
258 project version. default: 0.1
259
260 .SH The test command
261
262 .B meson test
263 is a helper tool for running test suites of projects using Meson.
264 The default way of running tests is to invoke the default build command:
265
266 \fBninja [\fR \fItest\fR \fB]\fR
267
268 .B meson test
269 provides a richer set of tools for invoking tests.
270
271 .B meson test
272 automatically rebuilds the necessary targets to run tests when used with the Ninja backend.
273 Upon build failure,
274 .B meson test
275 will return an exit code of 125.
276 This return code tells
277 .B git bisect run
278 to skip the current commit.
279 Thus bisecting using git can be done conveniently like this.
280
281 .B git bisect run meson test -C build_dir
282
283 .SS "options:"
284 .TP
285 \fB\-\-repeat\fR
286 run tests as many times as specified
287 .TP
288 \fB\-\-gdb\fR
289 run tests under gdb
290 .TP
291 \fB\-\-list\fR
292 list all available tests
293 .TP
294 \fB\-\-wrapper\fR
295 invoke all tests via the given wrapper (e.g. valgrind)
296 .TP
297 \fB\-C\fR
298 Change into the given directory before running tests (must be root of build directory).
299 .TP
300 \fB\-\-suite\fR
301 run tests in this suite
302 .TP
303 \fB\-\-no\-suite\fR
304 do not run tests in this suite
305 .TP
306 \fB\-\-exclude\fR
307 do not run named tests
308 .TP
309 \fB\-\-no\-stdsplit\fR
310 do not split stderr and stdout in test logs
311 .TP
312 \fB\-\-benchmark\fR
313 run benchmarks instead of tests
314 .TP
315 \fB\-\-logbase\fR
316 base of file name to use for writing test logs
317 .TP
318 \fB\-\-num-processes\fR
319 how many parallel processes to use to run tests
320 .TP
321 \fB\-\-verbose\fR
322 do not redirect stdout and stderr
323 .TP
324 \fB\-t\fR
325 a multiplier to use for test timeout values (usually something like 100 for Valgrind)
326 .TP
327 \fB\-\-setup\fR
328 use the specified test setup
329 .TP
330 \fB\-\-slice SLICE/NUM_SLICES\fR
331 Split tests into NUM_SLICES slices and execute slice number SLICE. (Since 1.8.0)
332
333 .SH The wrap command
334
335 Wraptool is a helper utility to manage source dependencies
336 using the online wrapdb service.
337
338 .B meson wrap <
339 .I command
340 .B > [
341 .I options
342 .B ]
343
344 You should run this command in the top level source directory
345 of your project.
346
347 .SS "Commands:"
348 .TP
349 \fBlist\fR
350 list all available projects
351 .TP
352 \fBsearch\fR
353 search projects by name
354 .TP
355 \fBinstall\fR
356 install a project with the given name
357 .TP
358 \fBupdate\fR
359 update the specified project to latest available version
360 .TP
361 \fBinfo\fR
362 show available versions of the specified project
363 .TP
364 \fBstatus\fR
365 show installed and available versions of currently used subprojects
366
367 .SH The subprojects command
368
369 .B meson subprojects
370 is used to manage subprojects.
371
372 .B meson subprojects [
373 .I options
374 .B ] [
375 .I command
376 .B ]
377
378 .SS "options:"
379 .TP
380 \fB\-h, \-\-help\fR
381 show this help message and exit
382
383 .SS "commands:"
384 .TP
385 \fBupdate\fR
386 Update all subprojects from wrap files
387
388 .TP
389 \fBcheckout\fR
390 Checkout a branch (git only)
391
392 .TP
393 \fBdownload\fR
394 Ensure subprojects are fetched, even if not in use. Already downloaded
395 subprojects are not modified. This can be used to pre-fetch all
396 subprojects and avoid downloads during configure.
397
398 .TP
399 \fBforeach\fR
400 Execute a command in each subproject directory.
401
402 .TP
403 \fBpurge\fR
404 Remove all wrap-based subproject artifacts
405
406 .TP
407 \fBpackagefiles\fR
408 Manage the packagefiles overlay
409
410 .SH The rewrite command
411
412 .B meson rewrite
413 modifies the project definition.
414
415 .B meson rewrite [
416 .I options
417 .B ] [
418 .I command
419 .B ]
420
421 .SS "options:"
422
423 .TP
424 \fB\-h, \-\-help\fR
425 show this help message and exit
426
427 .TP
428 \fB\-s SRCDIR, \-\-sourcedir SRCDIR\fR
429 Path to source directory.
430
431 .TP
432 \fB\-V, \-\-verbose\fR
433 Enable verbose output
434
435 .TP
436 \fB\-S, \-\-skip\-errors\fR
437 Skip errors instead of aborting
438
439 .SS "commands:"
440
441 .TP
442 \fBtarget (tgt)\fR
443 Modify a target
444
445 .TP
446 \fBkwargs\fR
447 Modify keyword arguments
448
449 .TP
450 \fBdefault-options (def)\fR
451 Modify the project default options
452
453 .TP
454 \fBcommand (cmd)\fR
455 Execute a JSON array of commands
456
457 .SH The compile command
458
459 .B meson compile
460 builds the project.
461
462 .B meson compile [
463 .I options
464 .B ] [
465 .I TARGET...
466 .B ]
467
468 .SS "positional arguments:"
469 .TP
470 \fBTARGET\fR
471 Targets to build. Target has the following format:
472 [PATH_TO_TARGET/]TARGET_NAME.TARGET_SUFFIX[:TARGET_TYPE].
473
474 .SS "options:"
475
476 .TP
477 \fB\-h, \-\-help\fR
478 show this help message and exit
479
480 .TP
481 \fB\-\-clean\fR
482 Clean the build directory.
483
484 .TP
485 \fB\-C WD\fR
486 directory to cd into before running
487
488 .TP
489 \fB\-j JOBS, \-\-jobs JOBS\fR
490 The number of worker jobs to run (if supported). If the value is less
491 than 1 the build program will guess.
492
493 .TP
494 \fB\-l LOAD_AVERAGE, \-\-load-average LOAD_AVERAGE\fR
495 The system load average to try to maintain (if supported).
496
497 .TP
498 \fB\-v, \-\-verbose\fR
499 Show more verbose output.
500
501 .TP
502 \fB\-\-ninja\-args NINJA_ARGS\fR
503 Arguments to pass to `ninja` (applied only on `ninja` backend).
504
505 .TP
506 \fB\-\-vs\-args VS_ARGS\fR
507 Arguments to pass to `msbuild` (applied only on `vs` backend).
508
509 .TP
510 \fB\-\-xcode\-args XCODE_ARGS\fR
511 Arguments to pass to `xcodebuild` (applied only on `xcode` backend).
512
513 .SH The devenv command
514
515 .B meson devenv
516 runs commands in the developer environment.
517
518 .B meson devenv [
519 .I options
520 .B ] [
521 .I command
522 .B ]
523
524 .SS "positional arguments:"
525
526 .TP
527 \fBcommand\fR
528 Command to run in developer environment (default: interactive shell)
529
530 .SS "options:"
531
532 .TP
533 \fB\-h, \-\-help\fR
534 show this help message and exit
535
536 .TP
537 \fB\-C BUILDDIR\fR
538 Path to build directory
539
540 .TP
541 \fB\-\-workdir WORKDIR, \-w WORKDIR\fR
542 Directory to cd into before running (default: builddir, Since 1.0.0)
543
544 .TP
545 \fB\-\-dump [DUMP]\fR
546 Only print required environment (Since 0.62.0) Takes an optional file
547 path (Since 1.1.0)
548
549 .TP
550 \fB\-\-dump-format {sh,export,vscode}\fR
551 Format used with --dump (Since 1.1.0)
552
553 .SH The env2mfile command
554
555 .B meson env2mfile
556 converts the current environment to a cross or native file.
557
558 .B meson env2mfile [
559 .I options
560 .B ]
561
562 .SS "options:"
563
564 .TP
565 \fB\-h, \-\-help\fR
566 show this help message and exit
567
568 .TP
569 \fB\-\-debarch DEBARCH\fR
570 The dpkg architecture to generate.
571
572 .TP
573 \fB\-\-gccsuffix GCCSUFFIX\fR
574 A particular gcc version suffix if necessary.
575
576 .TP
577 \fB\-o OUTFILE\fR
578 The output file.
579
580 .TP
581 \fB\-\-cross\fR
582 Generate a cross compilation file.
583
584 .TP
585 \fB\-\-native\fR
586 Generate a native compilation file.
587
588 .TP
589 \fB\-\-system SYSTEM\fR
590 Define system for cross compilation.
591
592 .TP
593 \fB\-\-subsystem SUBSYSTEM\fR
594 Define subsystem for cross compilation.
595
596 .TP
597 \fB\-\-kernel KERNEL\fR
598 Define kernel for cross compilation.
599
600 .TP
601 \fB\-\-cpu CPU\fR
602 Define cpu for cross compilation.
603
604 .TP
605 \fB\-\-cpu-family CPU_FAMILY\fR
606 Define cpu family for cross compilation.
607
608 .TP
609 \fB\-\-endian {big,little}\fR
610 Define endianness for cross compilation.
611
612 .SH The format command
613
614 .B meson format
615 formats a meson source file.
616
617 .B meson format [
618 .I options
619 .B ] [
620 .I sources...
621 .B ]
622
623 .SS "positional arguments:"
624
625 .TP
626 \fBsources...\fR
627 meson source files
628
629 .SS "options:"
630
631 .TP
632 \fB-h, --help\fR
633 show this help message and exit
634
635 .TP
636 \fB-q, --check-only\fR
637 exit with 1 if files would be modified by meson format
638
639 .TP
640 \fB-i, --inplace\fR
641 format files in-place
642
643 .TP
644 \fB-r, --recursive\fR
645 recurse subdirs (requires --check-only or --inplace option)
646
647 .TP
648 \fB-c meson.format, --configuration meson.format\fR
649 read configuration from meson.format
650
651 .TP
652 \fB-e, --editor-config\fR
653 try to read configuration from .editorconfig
654
655 .TP
656 \fB-o OUTPUT, --output OUTPUT\fR
657 output file (implies having exactly one input)
658
659 .SH When no command is specified
660
661 If you run Meson without a subcommand, it will assume you meant
662 \fBmeson setup\fR. However, this syntax is deprecated, and Meson
663 will print a warning message if it is used. You should always use
664 \fBmeson setup\fR explicitly, instead of relying on the default.
665
666 .SH EXIT STATUS
667
668 .TP
669 .B 0
670 Successful.
671 .TP
672 .B 1
673 Usage error, or an error parsing or executing meson.build.
674 .TP
675 .B 2
676 Internal error.
677 .TP
678 .B 125
679 .B meson test
680 could not rebuild the required targets.
681 .TP
682
683 .SH SEE ALSO
684
685 https://mesonbuild.com/
686
687 https://wrapdb.mesonbuild.com/
688
689 .MR meson-reference 3