short-description: Built-in options to configure project properties ...

Built-in options

Meson provides two kinds of options: build options provided by the build files and built-in options that are either universal options, base options, compiler options.

Universal options

A list of these options can be found by running meson --help. All these can be set by passing to meson (aka meson setup) in any of these ways: --option=value, --option value, -Doption=value, or by setting them inside default_options of project() in your meson.build.

For legacy reasons --warnlevel is the cli argument for the warning_level option.

They can also be edited after setup using meson configure.

Installation options are all relative to the prefix, except:

  • When the prefix is /usr: sysconfdir defaults to /etc, localstatedir defaults to /var, and sharedstatedir defaults to /var/lib
  • When the prefix is /usr/local: localstatedir defaults to /var/local, and sharedstatedir defaults to /var/local/lib

Directories

OptionDefault valueDescription
prefixsee belowInstallation prefix
bindirbinExecutable directory
datadirshareData file directory
includedirincludeHeader file directory
infodirshare/infoInfo page directory
libdirsee belowLibrary directory
libexecdirlibexecLibrary executable directory
localedirshare/localeLocale data directory
localstatedirvarLocalstate data directory
mandirshare/manManual page directory
sbindirsbinSystem executable directory
sharedstatedircomArchitecture-independent data directory
sysconfdiretcSysconf data directory

prefix defaults to C:/ on Windows, and /usr/local/ otherwise. You should always override this value.

libdir 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 cross file, particularly the paths section may be necessary.

Core options

Options that are labled “per machine” in the table are set per machine. Prefixing the option with build. just affects the build machine configuration, while unprefixed just affects the host machine configuration, respectively. Using the option as-is with no prefix affects all machines. For example:

  • build.pkg_config_path controls the paths pkg-config will search for just native: true dependencies (build machine).

  • pkg_config_path controls the paths pkg-config will search for just native: false dependencies (host machine).

OptionDefault valueDescriptionIs per machine
auto_features {enabled, disabled, auto}autoOverride value of all ‘auto’ featuresno
backend {ninja, vs,
vs2010, vs2015, vs2017, xcode}
ninjaBackend to useno
buildtype {plain, debug,
debugoptimized, release, minsize, custom}
debugBuild type to useno
debugtrueDebugno
default_library {shared, static, both}sharedDefault library typeno
errorlogstrueWhether to print the logs from failing tests.no
install_umask {preserve, 0000-0777}022Default umask to apply on permissions of installed filesno
layout {mirror,flat}mirrorBuild directory layoutno
optimization {0, g, 1, 2, 3, s}0Optimization levelno
pkg_config_path {OS separated path}''Additional paths for pkg-config to search before builtin pathsyes
cmake_prefix_path[]Additional prefixes for cmake to search before builtin pathsyes
stdsplittrueSplit stdout and stderr in test logsno
stripfalseStrip targets on installno
unity {on, off, subprojects}offUnity buildno
warning_level {0, 1, 2, 3}1Set the warning level. From 0 = none to 3 = highestno
werrorfalseTreat warnings as errorsno
wrap_mode {default, nofallback,
nodownload, forcefallback}
defaultWrap mode to useno

Base options

These are set in the same way as universal options, but cannot be shown in the output of meson --help 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 meson configure on it with no options.

The following options are available. Note that they may not be available on all platforms or with all compilers:

OptionDefault valuePossible valuesDescription
b_asneededtruetrue, falseUse -Wl,--as-needed when linking
b_bitcodefalsetrue, falseEmbed Apple bitcode, see below
b_coloroutalwaysauto, always, neverUse colored output
b_coveragefalsetrue, falseEnable coverage tracking
b_lundeftruetrue, falseDon't allow undefined symbols when linking
b_ltofalsetrue, falseUse link time optimization
b_ndebugfalsetrue, false, if-releaseDisable asserts
b_pchtruetrue, falseUse precompiled headers
b_pgooffoff, generate, useUse profile guided optimization
b_sanitizenonesee belowCode sanitizer to use
b_staticpictruetrue, falseBuild static libraries as position independent
b_piefalsetrue, falseBuild position-independent executables (since 0.49.0)
b_vscrtfrom_buildtypenone, md, mdd, mt, mtd, from_buildtypeVS runtime library to use (since 0.48.0)

The value of b_sanitize can be one of: none, address, thread, undefined, memory, address,undefined.

Notes about Apple Bitcode support

b_bitcode will pass -fembed-bitcode while compiling and will pass -Wl,-bitcode_bundle while linking. These options are incompatible with b_asneeded, so that option will be silently disabled.

Shared modules will not have bitcode embedded because -Wl,-bitcode_bundle is incompatible with both -bundle and -Wl,-undefined,dynamic_lookup which are necessary for shared modules to work.

Compiler options

Same caveats as base options above.

The following options are available. Note that both the options themselves and the possible values they can take will depend on the target platform or compiler being used:

OptionDefault valuePossible valuesDescription
c_argsfree-form comma-separated listC compile arguments to use
c_link_argsfree-form comma-separated listC link arguments to use
c_stdnonenone, c89, c99, c11, c17, c18, gnu89, gnu99, gnu11, gnu17, gnu18C language standard to use
c_winlibssee belowfree-form comma-separated listStandard Windows libs to link against
cpp_argsfree-form comma-separated listC++ compile arguments to use
cpp_link_argsfree-form comma-separated listC++ link arguments to use
cpp_stdnonenone, c++98, c++03, c++11, c++14, c++17,
c++1z, gnu++03, gnu++11, gnu++14, gnu++17, gnu++1z,
vc++14, vc++17, vc++latest
C++ language standard to use
cpp_debugstlfalsetrue, falseC++ STL debug mode
cpp_ehdefaultnone, default, a, s, scC++ exception handling type
cpp_winlibssee belowfree-form comma-separated listStandard Windows libs to link against

The default values of c_winlibs and cpp_winlibs are in compiler-specific argument forms, but the libraries are: kernel32, user32, gdi32, winspool, shell32, ole32, oleaut32, uuid, comdlg32, advapi32.

c_args, cpp_args, c_link_args, and cpp_link_args only affect native builds, when cross compiling they will not be applied to binaries or libraries targeting the host system, only those being run on the build system.

When using MSVC, cpp_eh=none will result in no exception flags being passed, while the cpp_eh=[value] will result in /EH[value]. Since 0.51.0 cpp_eh=default will result in /EHsc on MSVC. When using gcc-style compilers, nothing is passed (allowing exceptions to work), while cpp_eh=none passes -fno-exceptions.