-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBuiltin-options.html
1166 lines (1129 loc) · 37.2 KB
/
Builtin-options.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<base href=".">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Built-in options</title>
<link rel="stylesheet" href="assets/css/dark-frontend.css" type="text/css" title="dark">
<link rel="alternate stylesheet" href="assets/css/light-frontend.css" type="text/css" title="light">
<link rel="stylesheet" href="assets/css/bootstrap-toc.min.css" type="text/css">
<link rel="stylesheet" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" href="assets/js/search/enable_search.css" type="text/css">
<link rel="stylesheet" href="assets/css/prism-tomorrow.css" type="text/css" title="dark">
<link rel="alternate stylesheet" href="assets/css/prism.css" type="text/css" title="light">
<script src="assets/js/mustache.min.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/scrollspy.js"></script>
<script src="assets/js/typeahead.jquery.min.js"></script>
<script src="assets/js/search.js"></script>
<script src="assets/js/compare-versions.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/js/bootstrap-toc.min.js"></script>
<script src="assets/js/jquery.touchSwipe.min.js"></script>
<script src="assets/js/anchor.min.js"></script>
<script src="assets/js/tag_filtering.js"></script>
<script src="assets/js/language_switching.js"></script>
<script src="assets/js/styleswitcher.js"></script>
<script src="assets/js/lines_around_headings.js"></script>
<script src="assets/js/prism-core.js"></script>
<script src="assets/js/prism-autoloader.js"></script>
<script src="assets/js/prism_autoloader_path_override.js"></script>
<script src="assets/js/prism-keep-markup.js"></script>
<script src="assets/js/trie.js"></script>
<link rel="icon" type="image/png" href="assets/images/favicon.png">
<link rel="shortcut icon" href="assets/images/favicon.png">
</head>
<body class="no-script
">
<script>
$('body').removeClass('no-script');
</script>
<nav class="navbar navbar-fixed-top navbar-default" id="topnav">
<div class="container-fluid">
<div class="navbar-right">
<a id="toc-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-wrapper" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span title="light mode switch" class="glyphicon glyphicon-sunglasses pull-right" id="lightmode-icon"></span>
<form class="navbar-form pull-right" id="navbar-search-form">
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm" name="search" id="sidenav-lookup-field" placeholder="search" disabled>
<span class="glyphicon glyphicon-search form-control-feedback" id="search-mgn-glass"></span>
</div>
</form>
</div>
<div class="navbar-header">
<a id="sidenav-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<a id="home-link" href="index.html" class="hotdoc-navbar-brand">
<img src="assets/images/meson_logo.png" alt="Home">
</a>
</div>
<div class="navbar-collapse collapse" id="navbar-wrapper">
<ul class="nav navbar-nav" id="menu">
<li class="dropdown">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Modules <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="modules-menu">
<li>
<a href="CMake-module.html">CMake</a>
</li>
<li>
<a href="Cuda-module.html">CUDA</a>
</li>
<li>
<a href="Dlang-module.html">Dlang</a>
</li>
<li>
<a href="External-Project-module.html">External Project</a>
</li>
<li>
<a href="Fs-module.html">Filesystem</a>
</li>
<li>
<a href="Gnome-module.html">GNOME</a>
</li>
<li>
<a href="Hotdoc-module.html">Hotdoc</a>
</li>
<li>
<a href="i18n-module.html">i18n</a>
</li>
<li>
<a href="Icestorm-module.html">Icestorm</a>
</li>
<li>
<a href="Java-module.html">Java</a>
</li>
<li>
<a href="Keyval-module.html">Keyval</a>
</li>
<li>
<a href="Pkgconfig-module.html">Pkgconfig</a>
</li>
<li>
<a href="Python-3-module.html">Python 3</a>
</li>
<li>
<a href="Python-module.html">Python</a>
</li>
<li>
<a href="Qt4-module.html">Qt4</a>
</li>
<li>
<a href="Qt5-module.html">Qt5</a>
</li>
<li>
<a href="Qt6-module.html">Qt6</a>
</li>
<li>
<a href="Rust-module.html">Rust</a>
</li>
<li>
<a href="Simd-module.html">Simd</a>
</li>
<li>
<a href="SourceSet-module.html">SourceSet</a>
</li>
<li>
<a href="Wayland-module.html">Wayland</a>
</li>
<li>
<a href="Windows-module.html">Windows</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Quick References <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="quick-refs-menu">
<li>
<a href="Reference-manual.html">Functions</a>
</li>
<li>
<a href="Build-options.html">Options</a>
</li>
<li>
<a href="Configuration.html">Configuration</a>
</li>
<li>
<a href="Dependencies.html">Dependencies</a>
</li>
<li>
<a href="Unit-tests.html">Tests</a>
</li>
<li>
<a href="Syntax.html">Syntax</a>
</li>
</ul>
</li>
</ul>
<div class="hidden-xs hidden-sm navbar-text navbar-center">
<p><b>The Meson Build System</b></p>
</div>
</div>
</div>
</nav>
<main>
<div data-extension="core" data-hotdoc-in-toplevel="True" data-hotdoc-project="Meson-documentation" data-hotdoc-ref="Builtin-options.html" class="page_container" id="page-wrapper">
<script src="assets/js/utils.js"></script>
<div class="panel panel-collapse oc-collapsed" id="sidenav" data-hotdoc-role="navigation">
<script src="assets/js/full-width.js"></script>
<div id="sitenav-wrapper">
<iframe src="hotdoc-sitemap.html" id="sitenav-frame"></iframe>
</div>
</div>
<div id="body">
<div id="main">
<div id="page-description" data-hotdoc-role="main">
<h1 id="builtin-options">Built-in options</h1>
<p>Meson provides two kinds of options: <a href="Build-options.html">build options provided by the
build files</a> and built-in options that are either
universal options, base options, compiler options.</p>
<h2 id="universal-options">Universal options</h2>
<p>All these can be set by passing <code>-Doption=value</code> to <code>meson</code> (aka <code>meson setup</code>), or by setting them inside <code>default_options</code> of <a href="Reference-manual_functions.html#project"><ins><code>project()</code></ins></a> in your
<code>meson.build</code>. Some options can also be set by <code>--option=value</code>, or <code>--option value</code> -- a list is shown by running <code>meson setup --help</code>.</p>
<p>For legacy reasons <code>--warnlevel</code> is the cli argument for the
<code>warning_level</code> option.</p>
<p>They can also be edited after setup using <code>meson configure -Doption=value</code>.</p>
<p>Installation options are usually relative to the prefix but it should
not be relied on, since they can be absolute paths in the following cases:</p>
<ul>
<li>When the prefix is <code>/usr</code>: <code>sysconfdir</code> defaults to <code>/etc</code>,
<code>localstatedir</code> defaults to <code>/var</code>, and <code>sharedstatedir</code> defaults to
<code>/var/lib</code>
</li>
<li>When the prefix is <code>/usr/local</code>: <code>localstatedir</code> defaults
to <code>/var/local</code>, and <code>sharedstatedir</code> defaults to <code>/var/local/lib</code>
</li>
<li>When an absolute path outside of prefix is provided by the user/distributor.</li>
</ul>
<h3 id="directories">Directories</h3>
<table>
<thead>
<tr>
<th> Option</th>
<th> Default value</th>
<th> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td> prefix</td>
<td> see below</td>
<td> Installation prefix</td>
</tr>
<tr>
<td> bindir</td>
<td> bin</td>
<td> Executable directory</td>
</tr>
<tr>
<td> datadir</td>
<td> share</td>
<td> Data file directory</td>
</tr>
<tr>
<td> includedir</td>
<td> include</td>
<td> Header file directory</td>
</tr>
<tr>
<td> infodir</td>
<td> share/info</td>
<td> Info page directory</td>
</tr>
<tr>
<td> libdir</td>
<td> see below</td>
<td> Library directory</td>
</tr>
<tr>
<td> licensedir</td>
<td> see below</td>
<td> Licenses directory (since 1.1.0)</td>
</tr>
<tr>
<td> libexecdir</td>
<td> libexec</td>
<td> Library executable directory</td>
</tr>
<tr>
<td> localedir</td>
<td> share/locale</td>
<td> Locale data directory</td>
</tr>
<tr>
<td> localstatedir</td>
<td> var</td>
<td> Localstate data directory</td>
</tr>
<tr>
<td> mandir</td>
<td> share/man</td>
<td> Manual page directory</td>
</tr>
<tr>
<td> sbindir</td>
<td> sbin</td>
<td> System executable directory</td>
</tr>
<tr>
<td> sharedstatedir</td>
<td> com</td>
<td> Architecture-independent data directory</td>
</tr>
<tr>
<td> sysconfdir</td>
<td> etc</td>
<td> Sysconf data directory</td>
</tr>
</tbody>
</table>
<p><code>prefix</code> defaults to <code>C:/</code> on Windows, and <code>/usr/local</code> otherwise. You
should always override this value.</p>
<p><code>libdir</code> is automatically detected based on your platform, it should
be correct when doing "native" (build machine == host machine)
compilation. For cross compiles Meson will try to guess the correct
libdir, but it may not be accurate, especially on Linux where
different distributions have different defaults. Using a <a href="Cross-compilation.html#defining-the-environment">cross
file</a>, particularly the
paths section may be necessary.</p>
<p><code>licensedir</code> is empty by default. If set, it defines the default location
to install a dependency manifest and project licenses. For more details,
see <a href="Reference-manual_builtin_meson.html#mesoninstall_dependency_manifest"><ins><code>meson.install_dependency_manifest()</code></ins></a>.</p>
<h3 id="core-options">Core options</h3>
<p>Options that are labeled "per machine" in the table are set per
machine. See the <a href="Builtin-options.html#specifying-options-per-machine">specifying options per
machine</a> section for details.</p>
<table>
<thead>
<tr>
<th> Option</th>
<th> Default value</th>
<th> Description</th>
<th> Is per machine</th>
<th> Is per subproject</th>
</tr>
</thead>
<tbody>
<tr>
<td> auto_features {enabled, disabled, auto}</td>
<td> auto</td>
<td> Override value of all 'auto' features</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> backend {ninja, vs,<br>vs2010, vs2012, vs2013, vs2015, vs2017, vs2019, vs2022, xcode, none}</td>
<td> ninja</td>
<td> Backend to use</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> genvslite {vs2022}</td>
<td> vs2022</td>
<td> Setup multi-builtype ninja build directories and Visual Studio solution</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> buildtype {plain, debug,<br>debugoptimized, release, minsize, custom}</td>
<td> debug</td>
<td> Build type to use</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> debug</td>
<td> true</td>
<td> Enable debug symbols and other information</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> default_both_libraries {shared, static, auto}</td>
<td> shared</td>
<td> Default library type for both_libraries</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> default_library {shared, static, both}</td>
<td> shared</td>
<td> Default library type</td>
<td> no</td>
<td> yes</td>
</tr>
<tr>
<td> errorlogs</td>
<td> true</td>
<td> Whether to print the logs from failing tests.</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> install_umask {preserve, 0000-0777}</td>
<td> 022</td>
<td> Default umask to apply on permissions of installed files</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> layout {mirror,flat}</td>
<td> mirror</td>
<td> Build directory layout</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> optimization {plain, 0, g, 1, 2, 3, s}</td>
<td> 0</td>
<td> Optimization level</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> pkg_config_path {OS separated path}</td>
<td> ''</td>
<td> Additional paths for pkg-config to search before builtin paths</td>
<td> yes</td>
<td> no</td>
</tr>
<tr>
<td> prefer_static</td>
<td> false</td>
<td> Whether to try static linking before shared linking</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> cmake_prefix_path</td>
<td> []</td>
<td> Additional prefixes for cmake to search before builtin paths</td>
<td> yes</td>
<td> no</td>
</tr>
<tr>
<td> stdsplit</td>
<td> true</td>
<td> Split stdout and stderr in test logs</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> strip</td>
<td> false</td>
<td> Strip targets on install</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> unity {on, off, subprojects}</td>
<td> off</td>
<td> Unity build</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> unity_size {>=2}</td>
<td> 4</td>
<td> Unity file block size</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> warning_level {0, 1, 2, 3, everything}</td>
<td> 1</td>
<td> Set the warning level. From 0 = compiler default to everything = highest</td>
<td> no</td>
<td> yes</td>
</tr>
<tr>
<td> werror</td>
<td> false</td>
<td> Treat warnings as errors</td>
<td> no</td>
<td> yes</td>
</tr>
<tr>
<td> wrap_mode {default, nofallback,<br>nodownload, forcefallback, nopromote}</td>
<td> default</td>
<td> Wrap mode to use</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> force_fallback_for</td>
<td> []</td>
<td> Force fallback for those dependencies</td>
<td> no</td>
<td> no</td>
</tr>
<tr>
<td> vsenv</td>
<td> false</td>
<td> Activate Visual Studio environment</td>
<td> no</td>
<td> no</td>
</tr>
</tbody>
</table>
<p>(For the Rust language only, <code>warning_level=0</code> disables all warnings).</p>
<h4 id="details-for-backend">Details for <code>backend</code>
</h4>
<p>Several build file formats are supported as command runners to build the
configured project. Meson prefers ninja by default, but platform-specific
backends are also available for better IDE integration with native tooling:
Visual Studio for Windows, and xcode for macOS. It is also possible to
configure with no backend at all, which is an error if you have targets to
build, but for projects that need configuration + testing + installation allows
for a lighter automated build pipeline.</p>
<h4 id="details-for-genvslite">Details for <code>genvslite</code>
</h4>
<p>Setup multiple buildtype-suffixed, ninja-backend build directories (e.g.
[builddir]_[debug/release/etc.]) and generate [builddir]_vs containing a Visual
Studio solution with multiple configurations that invoke a meson compile of the
setup build directories, as appropriate for the current configuration (builtype).</p>
<p>This has the effect of a simple setup macro of multiple 'meson setup ...'
invocations with a set of different buildtype values. E.g.
<code>meson setup ... --genvslite vs2022 somebuilddir</code> does the following -</p>
<pre><code>meson setup ... --backend ninja --buildtype debug somebuilddir_debug
meson setup ... --backend ninja --buildtype debugoptimized somebuilddir_debugoptimized
meson setup ... --backend ninja --buildtype release somebuilddir_release
</code></pre>
<p>and additionally creates another 'somebuilddir_vs' directory that contains
a generated multi-configuration visual studio solution and project(s) that are
set to build/compile with the somebuilddir_[...] that's appropriate for the
solution's selected buildtype configuration.</p>
<h4 id="details-for-buildtype">Details for <code>buildtype</code>
</h4>
<p><a name="build-type-options"></a> For setting optimization levels and
toggling debug, you can either set the <code>buildtype</code> option, or you can
set the <code>optimization</code> and <code>debug</code> options which give finer control
over the same. Whichever you decide to use, the other will be deduced
from it. For example, <code>-Dbuildtype=debugoptimized</code> is the same as
<code>-Ddebug=true -Doptimization=2</code> and vice-versa. This table documents
the two-way mapping:</p>
<table>
<thead>
<tr>
<th> buildtype</th>
<th> debug</th>
<th> optimization</th>
</tr>
</thead>
<tbody>
<tr>
<td> plain</td>
<td> false</td>
<td> plain</td>
</tr>
<tr>
<td> debug</td>
<td> true</td>
<td> 0</td>
</tr>
<tr>
<td> debugoptimized</td>
<td> true</td>
<td> 2</td>
</tr>
<tr>
<td> release</td>
<td> false</td>
<td> 3</td>
</tr>
<tr>
<td> minsize</td>
<td> true</td>
<td> s</td>
</tr>
</tbody>
</table>
<p>All other combinations of <code>debug</code> and <code>optimization</code> set <code>buildtype</code> to <code>'custom'</code>.</p>
<h4 id="details-for-warning_level">Details for <code>warning_level</code>
</h4>
<p>Exact flags per warning level is compiler specific, but there is an approximative
table for most common compilers.</p>
<table>
<thead>
<tr>
<th> Warning level</th>
<th> GCC/Clang</th>
<th> MSVC</th>
</tr>
</thead>
<tbody>
<tr>
<td> 0</td>
<td></td>
<td></td>
</tr>
<tr>
<td> 1</td>
<td> -Wall</td>
<td> /W2</td>
</tr>
<tr>
<td> 2</td>
<td> -Wall -Wextra</td>
<td> /W3</td>
</tr>
<tr>
<td> 3</td>
<td> -Wall -Wextra -Wpedantic</td>
<td> /W4</td>
</tr>
<tr>
<td> everything</td>
<td> -Weverything</td>
<td> /Wall</td>
</tr>
</tbody>
</table>
<p>Clang's <code>-Weverything</code> is emulated on GCC by passing all known warning flags.</p>
<h4 id="details-for-vsenv">Details for <code>vsenv</code>
</h4>
<p>The <code>--vsenv</code> argument is supported since <code>0.60.0</code>, <code>-Dvsenv=true</code> syntax is supported
since <code>1.1.0</code>.</p>
<p>Since <code>0.59.0</code>, meson automatically activates a Visual Studio environment on Windows
for all its subcommands, but only if no other compilers (e.g. <code>gcc</code> or <code>clang</code>)
are found, and silently continues if Visual Studio activation fails.</p>
<p>Setting the <code>vsenv</code> option to <code>true</code> forces Visual Studio activation even when other
compilers are found. It also make Meson abort with an error message when activation
fails.</p>
<p><code>vsenv</code> is <code>true</code> by default when using the <code>vs</code> backend.</p>
<h4 id="details-for-default_both_libraries">Details for <code>default_both_libraries</code>
</h4>
<p>Since <code>1.6.0</code>, you can select the default type of library selected when using
a <code>both_libraries</code> object. This can be either 'shared' (default value, compatible
with previous meson versions), 'static', or 'auto'. With auto, the value from
<code>default_library</code> option is used, unless it is 'both', in which case 'shared'
is used instead.</p>
<p>When <code>default_both_libraries</code> is 'auto', passing a <a href="Reference-manual_returned_both_libs.html"><ins><code>both_libs</code></ins></a> dependency
in <a href="Reference-manual_functions.html#both_libraries"><ins><code>both_libraries()</code></ins></a> will link the static dependency with the static lib,
and the shared dependency with the shared lib.</p>
<h2 id="base-options">Base options</h2>
<p>These are set in the same way as universal options, either by
<code>-Doption=value</code>, or by setting them inside <code>default_options</code> of
<a href="Reference-manual_functions.html#project"><ins><code>project()</code></ins></a> in your <code>meson.build</code>. However, they cannot be shown in
the output of <code>meson setup --help</code> because they depend on both the current
platform and the compiler that will be selected. The only way to see
them is to setup a builddir and then run <code>meson configure</code> on it with
no options.</p>
<p>The following options are available. Note that they may not be
available on all platforms or with all compilers:</p>
<table>
<thead>
<tr>
<th> Option</th>
<th> Default value</th>
<th> Possible values</th>
<th> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td> b_asneeded</td>
<td> true</td>
<td> true, false</td>
<td> Use -Wl,--as-needed when linking</td>
</tr>
<tr>
<td> b_bitcode</td>
<td> false</td>
<td> true, false</td>
<td> Embed Apple bitcode, see below</td>
</tr>
<tr>
<td> b_colorout</td>
<td> always</td>
<td> auto, always, never</td>
<td> Use colored output</td>
</tr>
<tr>
<td> b_coverage</td>
<td> false</td>
<td> true, false</td>
<td> Enable coverage tracking</td>
</tr>
<tr>
<td> b_lundef</td>
<td> true</td>
<td> true, false</td>
<td> Don't allow undefined symbols when linking</td>
</tr>
<tr>
<td> b_lto</td>
<td> false</td>
<td> true, false</td>
<td> Use link time optimization</td>
</tr>
<tr>
<td> b_lto_threads</td>
<td> 0</td>
<td> Any integer*</td>
<td> Use multiple threads for lto. <em>(Added in 0.57.0)</em>
</td>
</tr>
<tr>
<td> b_lto_mode</td>
<td> default</td>
<td> default, thin</td>
<td> Select between lto modes, thin and default. <em>(Added in 0.57.0)</em>
</td>
</tr>
<tr>
<td> b_thinlto_cache</td>
<td> false</td>
<td> true, false</td>
<td> Enable LLVM's ThinLTO cache for faster incremental builds. <em>(Added in 0.64.0)</em>
</td>
</tr>
<tr>
<td> b_thinlto_cache_dir</td>
<td> (Internal build dir)</td>
<td> true, false</td>
<td> Specify where to store ThinLTO cache objects. <em>(Added in 0.64.0)</em>
</td>
</tr>
<tr>
<td> b_ndebug</td>
<td> false</td>
<td> true, false, if-release</td>
<td> Disable asserts</td>
</tr>
<tr>
<td> b_pch</td>
<td> true</td>
<td> true, false</td>
<td> Use precompiled headers</td>
</tr>
<tr>
<td> b_pgo</td>
<td> off</td>
<td> off, generate, use</td>
<td> Use profile guided optimization</td>
</tr>
<tr>
<td> b_sanitize</td>
<td> none</td>
<td> see below</td>
<td> Code sanitizer to use</td>
</tr>
<tr>
<td> b_staticpic</td>
<td> true</td>
<td> true, false</td>
<td> Build static libraries as position independent</td>
</tr>
<tr>
<td> b_pie</td>
<td> false</td>
<td> true, false</td>
<td> Build position-independent executables (since 0.49.0)</td>
</tr>
<tr>
<td> b_vscrt</td>
<td> from_buildtype</td>
<td> none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype</td>
<td> VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0)</td>
</tr>
</tbody>
</table>
<p>The value of <code>b_sanitize</code> can be one of: <code>none</code>, <code>address</code>, <code>thread</code>,
<code>undefined</code>, <code>memory</code>, <code>leak</code>, <code>address,undefined</code>, but note that some
compilers might not support all of them. For example Visual Studio
only supports the address sanitizer.</p>
<p>* < 0 means disable, == 0 means automatic selection, > 0 sets a specific number to use</p>
<p>LLVM supports <code>thin</code> lto, for more discussion see <a href="https://clang.llvm.org/docs/ThinLTO.html">LLVM's documentation</a></p>
<p><a name="b_vscrt-from_buildtype"></a>
The default value of <code>b_vscrt</code> is <code>from_buildtype</code>. The following table is
used internally to pick the CRT compiler arguments for <code>from_buildtype</code> or
<code>static_from_buildtype</code> <em>(since 0.56)</em> based on the value of the <code>buildtype</code>
option:</p>
<table>
<thead>
<tr>
<th> buildtype</th>
<th> from_buildtype</th>
<th> static_from_buildtype</th>
</tr>
</thead>
<tbody>
<tr>
<td> debug</td>
<td> <code>/MDd</code>
</td>
<td> <code>/MTd</code>
</td>
</tr>
<tr>
<td> debugoptimized</td>
<td> <code>/MD</code>
</td>
<td> <code>/MT</code>
</td>
</tr>
<tr>
<td> release</td>
<td> <code>/MD</code>
</td>
<td> <code>/MT</code>
</td>
</tr>
<tr>
<td> minsize</td>
<td> <code>/MD</code>
</td>
<td> <code>/MT</code>
</td>
</tr>
<tr>
<td> custom</td>
<td> error!</td>
<td> error!</td>
</tr>
</tbody>
</table>
<h3 id="notes-about-apple-bitcode-support">Notes about Apple Bitcode support</h3>
<p><code>b_bitcode</code> will pass <code>-fembed-bitcode</code> while compiling and will pass
<code>-Wl,-bitcode_bundle</code> while linking. These options are incompatible
with <code>b_asneeded</code>, so that option will be silently disabled.</p>
<p><a href="Reference-manual_functions.html#shared_module"><ins><code>shared_module()</code></ins></a>s will not have
bitcode embedded because <code>-Wl,-bitcode_bundle</code> is incompatible with
both <code>-bundle</code> and <code>-Wl,-undefined,dynamic_lookup</code> which are necessary
for shared modules to work.</p>
<h2 id="compiler-options">Compiler options</h2>
<p>Same caveats as base options above.</p>
<p>The following options are available. They can be set by passing
<code>-Doption=value</code> to <code>meson</code>. Note that both the options themselves and
the possible values they can take will depend on the target platform
or compiler being used:</p>
<table>
<thead>
<tr>
<th> Option</th>
<th> Default value</th>
<th> Possible values</th>
<th> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td> c_args</td>
<td></td>
<td> free-form comma-separated list</td>
<td> C compile arguments to use</td>
</tr>
<tr>
<td> c_link_args</td>
<td></td>
<td> free-form comma-separated list</td>
<td> C link arguments to use</td>
</tr>
<tr>
<td> c_std</td>
<td> none</td>
<td> none, c89, c99, c11, c17, c18, c2x, c23, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x, gnu23</td>
<td> C language standard to use</td>
</tr>
<tr>
<td> c_winlibs</td>
<td> see below</td>
<td> free-form comma-separated list</td>
<td> Standard Windows libs to link against</td>
</tr>
<tr>
<td> c_thread_count</td>
<td> 4</td>
<td> integer value ≥ 0</td>
<td> Number of threads to use with emcc when using threads</td>
</tr>
<tr>
<td> cpp_args</td>
<td></td>
<td> free-form comma-separated list</td>
<td> C++ compile arguments to use</td>
</tr>
<tr>
<td> cpp_link_args</td>
<td></td>
<td> free-form comma-separated list</td>
<td> C++ link arguments to use</td>
</tr>
<tr>
<td> cpp_std</td>
<td> none</td>
<td> none, c++98, c++03, c++11, c++14, c++17, c++20 <br>c++2a, c++1z, gnu++03, gnu++11, gnu++14, gnu++17, gnu++1z, <br> gnu++2a, gnu++20, vc++14, vc++17, vc++20, vc++latest</td>
<td> C++ language standard to use</td>
</tr>
<tr>
<td> cpp_debugstl</td>
<td> false</td>
<td> true, false</td>
<td> C++ STL debug mode</td>
</tr>
<tr>
<td> cpp_eh</td>
<td> default</td>
<td> none, default, a, s, sc</td>
<td> C++ exception handling type</td>
</tr>
<tr>
<td> cpp_rtti</td>
<td> true</td>
<td> true, false</td>
<td> Whether to enable RTTI (runtime type identification)</td>
</tr>
<tr>
<td> cpp_thread_count</td>
<td> 4</td>
<td> integer value ≥ 0</td>
<td> Number of threads to use with emcc when using threads</td>
</tr>
<tr>
<td> cpp_winlibs</td>
<td> see below</td>
<td> free-form comma-separated list</td>
<td> Standard Windows libs to link against</td>
</tr>
<tr>
<td> fortran_std</td>
<td> none</td>
<td> [none, legacy, f95, f2003, f2008, f2018]</td>
<td> Fortran language standard to use</td>
</tr>
<tr>
<td> cuda_ccbindir</td>
<td></td>
<td> filesystem path</td>
<td> CUDA non-default toolchain directory to use (-ccbin) <em>(Added in 0.57.1)</em>
</td>
</tr>
</tbody>
</table>
<p>The default values of <code>c_winlibs</code> and <code>cpp_winlibs</code> are in
compiler-specific argument forms, but the libraries are: kernel32,
user32, gdi32, winspool, shell32, ole32, oleaut32, uuid, comdlg32,
advapi32.</p>
<p>All these <code><lang>_*</code> options are specified per machine. See below in
the <a href="Builtin-options.html#specifying-options-per-machine">specifying options per machine</a>
section on how to do this in cross builds.</p>
<p>When using MSVC, <code>cpp_eh=[value]</code> will result in <code>/EH[value]</code> being passed.
The magic value <code>none</code> translates to <code>s-c-</code> to disable exceptions. <em>Since
0.51.0</em> <code>default</code> translates to <code>sc</code>. When using gcc-style compilers, nothing
is passed (allowing exceptions to work), while <code>cpp_eh=none</code> passes
<code>-fno-exceptions</code>.</p>
<p>Since <em>0.54.0</em> The <code><lang>_thread_count</code> option can be used to control
the value passed to <code>-s PTHREAD_POOL_SIZE</code> when using emcc. No other
c/c++ compiler supports this option.</p>
<p>Since <em>0.63.0</em> all compiler options can be set per subproject, see
<a href="Builtin-options.html#specifying-options-per-subproject">here</a> for details on how the default value
is inherited from the main project. This is useful, for example, when the main
project requires C++11, but a subproject requires C++14. The <code>cpp_std</code> value
from the subproject's <code>default_options</code> is now respected.</p>
<p>Since <em>1.3.0</em> <code>c_std</code> and <code>cpp_std</code> options now accept a list of values.
Projects that prefer GNU C, but can fallback to ISO C, can now set, for
example, <code>default_options: 'c_std=gnu11,c11'</code>, and it will use <code>gnu11</code> when
available, but fallback to c11 otherwise. It is an error only if none of the
values are supported by the current compiler.
Likewise, a project that can take benefit of <code>c++17</code> but can still build with
<code>c++11</code> can set <code>default_options: 'cpp_std=c++17,c++11'</code>.
This allows us to deprecate <code>gnuXX</code> values from the MSVC compiler. That means
that <code>default_options: 'c_std=gnu11'</code> will now print a warning with MSVC
but fallback to <code>c11</code>. No warning is printed if at least one
of the values is valid, i.e. <code>default_options: 'c_std=gnu11,c11'</code>.
In the future that deprecation warning will become an hard error because
<code>c_std=gnu11</code> should mean GNU is required, for projects that cannot be
built with MSVC for example.</p>
<h2 id="specifying-options-per-machine">Specifying options per machine</h2>
<p>Since <em>0.51.0</em>, some options are specified per machine rather than
globally for all machine configurations. Prefixing the option with
<code>build.</code> only affects the build machine configuration, while leaving it
unprefixed only affects the host machine configuration.
For example:</p>
<ul>
<li>
<p><code>build.pkg_config_path</code> controls the paths pkg-config will search
for <code>native: true</code> (build machine) dependencies.</p>
</li>
<li>
<p><code>pkg_config_path</code> controls the paths pkg-config will search for
<code>native: false</code> (host machine) dependencies.</p>
</li>
</ul>
<p>This is useful for cross builds. In native builds, the build and host
machines are the same, and the unprefixed option alone will suffice.</p>
<p>Prior to <em>0.51.0</em>, these options only affected native builds when
specified on the command line as there was no <code>build.</code> prefix.
Similarly named fields in the <code>[properties]</code> section of the cross file
would affect cross compilers, but the code paths were fairly different,
allowing differences in behavior to crop out.</p>
<h2 id="specifying-options-per-subproject">Specifying options per subproject</h2>
<p>Since <em>0.54.0</em> <code>default_library</code> and <code>werror</code> built-in options can be