| 1 |
--- |
| 2 |
short-description: Configuring a pre-generated build directory |
| 3 |
... |
| 4 |
|
| 5 |
# Configuring a build directory |
| 6 |
|
| 7 |
Often you want to change the settings of your build after it has been |
| 8 |
generated. For example you might want to change from a debug build |
| 9 |
into a release build, set custom compiler flags, change the build |
| 10 |
options provided in your `meson.options` file and so on. |
| 11 |
|
| 12 |
The main tool for this is the `meson configure` command. |
| 13 |
|
| 14 |
You invoke `meson configure` by giving it the location of your build |
| 15 |
dir. If omitted, the current working directory is used instead. Here's |
| 16 |
a sample output for a simple project. |
| 17 |
|
| 18 |
Core properties |
| 19 |
|
| 20 |
Source dir /home/jpakkane/clangdemo/2_address |
| 21 |
Build dir /home/jpakkane/clangdemo/2_address/buildmeson |
| 22 |
|
| 23 |
Core options: |
| 24 |
Option Current Value Possible Values Description |
| 25 |
------ ------------- --------------- ----------- |
| 26 |
auto_features auto [enabled, disabled, auto] Override value of all 'auto' features |
| 27 |
backend ninja [ninja, vs, vs2010, vs2015, vs2017, vs2019, vs2022, xcode] Backend to use |
| 28 |
buildtype release [plain, debug, debugoptimized, release, minsize, custom] Build type to use |
| 29 |
debug false [true, false] Debug |
| 30 |
default_library shared [shared, static, both] Default library type |
| 31 |
install_umask 0022 [preserve, 0000-0777] Default umask to apply on permissions of installed files |
| 32 |
layout mirror [mirror, flat] Build directory layout |
| 33 |
optimization 3 [plain, 0, g, 1, 2, 3, s] Optimization level |
| 34 |
prefer_static false [true, false] Whether to try static linking before shared linking |
| 35 |
strip false [true, false] Strip targets on install |
| 36 |
unity off [on, off, subprojects] Unity build |
| 37 |
warning_level 1 [0, 1, 2, 3, everything] Compiler warning level to use |
| 38 |
werror false [true, false] Treat warnings as errors |
| 39 |
|
| 40 |
Backend options: |
| 41 |
Option Current Value Possible Values Description |
| 42 |
------ ------------- --------------- ----------- |
| 43 |
backend_max_links 0 >=0 Maximum number of linker processes to run or 0 for no limit |
| 44 |
|
| 45 |
Base options: |
| 46 |
Option Current Value Possible Values Description |
| 47 |
------ ------------- --------------- ----------- |
| 48 |
b_asneeded true [true, false] Use -Wl,--as-needed when linking |
| 49 |
b_colorout always [auto, always, never] Use colored output |
| 50 |
b_coverage false [true, false] Enable coverage tracking. |
| 51 |
b_lto false [true, false] Use link time optimization |
| 52 |
b_lundef true [true, false] Use -Wl,--no-undefined when linking |
| 53 |
b_ndebug false [true, false, if-release] Disable asserts |
| 54 |
b_pch true [true, false] Use precompiled headers |
| 55 |
b_pgo off [off, generate, use] Use profile guided optimization |
| 56 |
b_sanitize none [none, address, thread, undefined, leak, memory, address,undefined] Code sanitizer to use |
| 57 |
b_staticpic true [true, false] Build static libraries as position independent |
| 58 |
|
| 59 |
Compiler options: |
| 60 |
Option Current Value Possible Values Description |
| 61 |
------ ------------- --------------- ----------- |
| 62 |
c_args [] Extra arguments passed to the C compiler |
| 63 |
c_link_args [] Extra arguments passed to the C linker |
| 64 |
c_std c99 [none, c89, c99, c11, c17, c18, c2x, c23, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x, gnu23] C language standard to use |
| 65 |
cpp_args [] Extra arguments passed to the C++ compiler |
| 66 |
cpp_debugstl false [true, false] STL debug mode |
| 67 |
cpp_link_args [] Extra arguments passed to the C++ linker |
| 68 |
cpp_std c++11 [none, c++98, c++03, c++11, c++14, c++17, c++1z, c++2a, c++20, gnu++03, gnu++11, gnu++14, gnu++17, gnu++1z, gnu++2a, gnu++20] C++ language standard to use |
| 69 |
fortran_std [] [none, legacy, f95, f2003, f2008, f2018] language standard to use |
| 70 |
|
| 71 |
Directories: |
| 72 |
Option Current Value Description |
| 73 |
------ ------------- ----------- |
| 74 |
bindir bin Executable directory |
| 75 |
datadir share Data file directory |
| 76 |
includedir include Header file directory |
| 77 |
infodir share/info Info page directory |
| 78 |
libdir lib/x86_64-linux-gnu Library directory |
| 79 |
libexecdir libexec Library executable directory |
| 80 |
localedir share/locale Locale data directory |
| 81 |
localstatedir /var/local Localstate data directory |
| 82 |
mandir share/man Manual page directory |
| 83 |
prefix /usr/local Installation prefix |
| 84 |
sbindir sbin System executable directory |
| 85 |
sharedstatedir /var/local/lib Architecture-independent data directory |
| 86 |
sysconfdir etc Sysconf data directory |
| 87 |
|
| 88 |
Project options: |
| 89 |
Option Current Value Possible Values Description |
| 90 |
------ ------------- --------------- ----------- |
| 91 |
array_opt [one, two] [one, two, three] array_opt |
| 92 |
combo_opt three [one, two, three] combo_opt |
| 93 |
free_array_opt [one, two] free_array_opt |
| 94 |
integer_opt 3 >=0, <=5 integer_opt |
| 95 |
other_one false [true, false] other_one |
| 96 |
some_feature enabled [enabled, disabled, auto] some_feature |
| 97 |
someoption optval An option |
| 98 |
|
| 99 |
Testing options: |
| 100 |
Option Current Value Possible Values Description |
| 101 |
------ ------------- --------------- ----------- |
| 102 |
errorlogs true [true, false] Whether to print the logs from failing tests |
| 103 |
stdsplit true [true, false] Split stdout and stderr in test logs |
| 104 |
|
| 105 |
These are all the options available for the current project arranged |
| 106 |
into related groups. The first column in every field is the name of |
| 107 |
the option. To set an option you use the `-D` option. For example, |
| 108 |
changing the installation prefix from `/usr/local` to `/tmp/testroot` |
| 109 |
you would issue the following command. |
| 110 |
|
| 111 |
meson configure -Dprefix=/tmp/testroot |
| 112 |
|
| 113 |
Then you would run your build command (usually `meson compile`), which |
| 114 |
would cause Meson to detect that the build setup has changed and do |
| 115 |
all the work required to bring your build tree up to date. |
| 116 |
|
| 117 |
Since 0.50.0, it is also possible to get a list of all build options |
| 118 |
by invoking [`meson configure`](Commands.md#configure) with the |
| 119 |
project source directory or the path to the root `meson.build`. In |
| 120 |
this case, Meson will print the default values of all options similar |
| 121 |
to the example output from above. |