meson-reference(3) Library Functions Manual meson-reference(3)

meson-reference 1.11.99 - a reference for meson functions and objects

This manual is divided into three sections, KERNEL FUNCTIONS, OBJECT METHODS, and MODULE FUNCTIONS. KERNEL FUNCTIONS contains all builtin meson functions and methods. Methods and module functions are denoted by [object / module name].[methodname].

SYNOPSIS
add_global_arguments(
glob[str],
language listify[str]:,
native bool:,
)

DESCRIPTION

Adds global arguments to the compiler command line.

POSARGS

0 glob[str]

The compiler arguments to add

KWARGS
language listify[str]

Specifies the language(s) that the arguments should be applied to. If an array of languages is given, the arguments are added to each of the corresponding compiler command lines. Note that there is no way to remove an argument set in this way. If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.

native bool

A boolean specifying whether the arguments should be applied to the native or cross compilation. If true the arguments will only be used for native compilations. If false the arguments will only be used in cross compilations. If omitted, the flags are added to native compilations if compiling natively and cross compilations (only) when cross compiling.

SYNOPSIS
add_global_link_arguments(
glob[str],
language listify[str]:,
native bool:,
)

DESCRIPTION

Adds global arguments to the linker command line.

Like [addglobalarguments] but the arguments are passed to the linker.

POSARGS

0 glob[str]

The linker arguments to add

KWARGS
language listify[str]

Specifies the language(s) that the arguments should be applied to. If an array of languages is given, the arguments are added to each of the corresponding compiler command lines. Note that there is no way to remove an argument set in this way. If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.

native bool

A boolean specifying whether the arguments should be applied to the native or cross compilation. If true the arguments will only be used for native compilations. If false the arguments will only be used in cross compilations. If omitted, the flags are added to native compilations if compiling natively and cross compilations (only) when cross compiling.

SYNOPSIS
add_languages(
glob[str],
native bool:,
required bool|feature:,
toolchain compiler:,
) -> bool

DESCRIPTION

Add programming languages used by the project.

This is equivalent to having them in the project declaration. This function is usually used to add languages that are only used under some conditions.

Returns true if all languages specified were found and false otherwise.

If native is omitted, the languages may be used for either build or host machine, but are never required for the build machine. (i.e. it is equivalent to add_languages(*langs*, native: false, required: *required*) and add_languages(*langs*, native: true, required: false). This default behaviour may change to native: false in a future Meson version.

POSARGS

0 glob[str]

The languages to add

KWARGS
native bool

If set to true, the language will be used to compile for the build machine, if false, for the host machine.

required bool|feature

If set to true, Meson will halt if any of the languages specified are not found. (since 0.47.0) The value of a [feature] option can also be passed.

toolchain compiler

Instead of detecting a toolchain, use the compiler toolchain for this language.

SYNOPSIS
add_project_arguments(
glob[str],
language listify[str]:,
native bool:,
)

DESCRIPTION

Adds project specific arguments to the compiler command line.

This function behaves in the same way as [addglobalarguments] except that the arguments are only used for the current project, they won't be used in any other subproject.

POSARGS

0 glob[str]

The compiler arguments to add

KWARGS
language listify[str]

Specifies the language(s) that the arguments should be applied to. If an array of languages is given, the arguments are added to each of the corresponding compiler command lines. Note that there is no way to remove an argument set in this way. If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.

native bool

A boolean specifying whether the arguments should be applied to the native or cross compilation. If true the arguments will only be used for native compilations. If false the arguments will only be used in cross compilations. If omitted, the flags are added to native compilations if compiling natively and cross compilations (only) when cross compiling.

SYNOPSIS
add_project_dependencies(
glob[dep],
language listify[str]:,
native bool:,
)

DESCRIPTION

Adds arguments to the compiler and linker command line, so that the given set of dependencies is included in all build products for this project.

POSARGS

0 glob[dep]

The dependencies to add; if internal dependencies are included, they must not include any built object.

KWARGS
language listify[str]

Specifies the language(s) that the arguments should be applied to. If an array of languages is given, the arguments are added to each of the corresponding compiler command lines. Note that there is no way to remove an argument set in this way. If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.

native bool

A boolean specifying whether the arguments should be applied to the native or cross compilation. If true the arguments will only be used for native compilations. If false the arguments will only be used in cross compilations. If omitted, the flags are added to native compilations if compiling natively and cross compilations (only) when cross compiling.

SYNOPSIS
add_project_link_arguments(
glob[str],
language listify[str]:,
native bool:,
)

DESCRIPTION

Adds project specific arguments to the linker command line.

Like [addprojectarguments] but the arguments are passed to the linker.

POSARGS

0 glob[str]

The linker arguments to add

KWARGS
language listify[str]

Specifies the language(s) that the arguments should be applied to. If an array of languages is given, the arguments are added to each of the corresponding compiler command lines. Note that there is no way to remove an argument set in this way. If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.

native bool

A boolean specifying whether the arguments should be applied to the native or cross compilation. If true the arguments will only be used for native compilations. If false the arguments will only be used in cross compilations. If omitted, the flags are added to native compilations if compiling natively and cross compilations (only) when cross compiling.

SYNOPSIS
add_test_setup(
str,
env dict[listify[str]]|env|listify[str]:,
exclude_suites listify[str]:,
exe_wrapper listify[exe]:,
gdb bool:,
is_default bool:,
timeout_multiplier int:,
)

DESCRIPTION

Add a custom test setup. This setup can be used to run the tests with a custom setup, for example under Valgrind.

To use the test setup, run meson test --setup=*name* inside the build dir.

Note that all these options are also available while running the meson test script for running tests instead of ninja test or msbuild RUN_TESTS.vcxproj, etc depending on the backend.

POSARGS

0 str

The name of the test setup

KWARGS
env dict[listify[str]]|env|listify[str]

environment variables to set , such as ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling. (Since 0.52.0) A dictionary is also accepted.

exclude_suites listify[str]

An array of test suites that should be excluded when using this setup. Suites specified in the --suite option to meson test will always run, overriding add_test_setup if necessary.

exe_wrapper listify[exe]

The command or script followed by the arguments to it

gdb bool

If true, the tests are also run under gdb

is_default bool

Set whether this is the default test setup. If true, the setup will be used whenever meson test is run without the --setup option.

timeout_multiplier int

A number to multiply the test timeout with. Since 0.57 if timeoutmultiplier is <= 0 the test has infinite duration, in previous versions of Meson the test would fail with a timeout immediately.

SYNOPSIS
alias_target(
str,
glob[alias_tgt|both_libs|build_tgt|custom_tgt],
) -> alias_tgt

DESCRIPTION

This function creates a new top-level target. Like all top-level targets, this integrates with the selected backend. For instance, with you can run it as meson compile target_name. This is a dummy target that does not execute any command, but ensures that all dependencies are built. Dependencies can be any build target. Since 0.60.0, this includes [@runtgt].

Since 1.6.0 passing a [@bothlibs] object builds both shared and static libraries.

POSARGS

0 str

The name of the alias target

1 glob[alias_tgt|both_libs|build_tgt|custom_tgt]

The targets to depend on

SYNOPSIS
assert(
bool,
str,
)

DESCRIPTION

Abort with an error message if condition evaluates to false.

POSARGS

0 bool

Abort if this evaluates to false

1 str

The error message to print.

SYNOPSIS
benchmark(
str,
build_tgt|custom_tgt|external_program|file|python_installation,
args listify[exe]:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
env dict[listify[str]]|env|listify[str]:,
expected_exitcode int:,
expected_fail bool:,
priority int:,
protocol str:,
should_fail bool:,
suite listify[str]:,
timeout int:,
workdir str:,
)

DESCRIPTION

Creates a benchmark item that will be run when the benchmark target is run. The behavior of this function is identical to [test] except for:

  • benchmark() has no is_parallel keyword because benchmarks are not run in parallel
  • benchmark() does not automatically add the MALLOC_PERTURB_ environment variable

Defined benchmarks can be run in a backend-agnostic way by calling meson test --benchmark inside the build dir, or by using backend-specific commands, such as ninja benchmark or msbuild RUN_TESTS.vcxproj.

POSARGS

0 str

The unique test id

1 build_tgt|custom_tgt|external_program|file|python_installation

The program to execute. (Since 1.4.0) A CustomTarget is also accepted.

KWARGS
args listify[exe]

Arguments to pass to the executable

depends listify[both_libs|build_tgt|custom_tgt|file]

specifies that this test depends on the specified target(s), even though it does not take any of them as a command line argument. This is meant for cases where test finds those targets internally, e.g. plugins or globbing. Those targets are built before test is executed even if they have build_by_default : false.

env dict[listify[str]]|env|listify[str]

environment variables to set, such as ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling. (Since 0.52.0) A dictionary is also accepted.

expected_exitcode int

the test is considered passed if the executable returns the specified returncode, only has effect when protocol is set to exitcode

expected_fail bool

when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error)

priority int

specifies the priority of a test. Tests with a higher priority are started before tests with a lower priority. The starting order of tests with identical priorities is implementation-defined. The default priority is 0, negative numbers are permitted.

protocol str

specifies how the test results are parsed and can be one of exitcode, tap, or gtest. For more information about test harness protocol read [Unit Tests]. The following values are accepted:

  • exitcode: the executable's exit code is used by the test harness to record the outcome of the test).
  • tap: [Test Anything Protocol].
  • gtest (since 0.55.0): for Google Tests.
  • rust (since 0.56.0): for native rust tests

should_fail bool

when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error)

suite listify[str]

timeout int

the amount of seconds the test is allowed to run, a test that exceeds its time limit is always considered failed, defaults to 30 seconds. Since 0.57 if timeout is <= 0 the test has infinite duration, in previous versions of Meson the test would fail with a timeout immediately.

workdir str

absolute path that will be used as the working directory for the test

SYNOPSIS
both_libraries(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> both_libs

DESCRIPTION

Builds both a static and shared library with the given sources. Positional and keyword arguments are otherwise the same as for [library]. Source files will be compiled only once and object files will be reused to build both shared and static libraries, unless b_staticpic user option or pic argument are set to false in which case sources will be compiled twice.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

(Since 1.3.0) [@customidx] are supported

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
build_target(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> both_libs|build_tgt

DESCRIPTION

Creates a build target whose type can be set dynamically with the target_type keyword argument.

target_type may be set to one of:

  • executable (see [executable])
  • shared_library (see [sharedlibrary])
  • shared_module (see [sharedmodule])
  • static_library (see [staticlibrary])
  • both_libraries (see [bothlibraries])
  • library (see [library])
  • jar (see [jar])

This declaration:

executable(<arguments and keyword arguments>)

is equivalent to this:

build_target(<arguments and keyword arguments>, target_type : 'executable')

The arrays for the kwargs (such as sources, objects, and dependencies) are always flattened, which means you can freely nest and add arrays while creating the final array.

The returned object also has methods that are documented in [@buildtgt].

"jar" is deprecated because it is fundamentally a different thing than the other buildtarget types.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

This can be used to expose which functions a sharedmodule loaded by an executable will be allowed to use.

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
configuration_data(
dict,
) -> cfg_data

DESCRIPTION

Creates an empty configuration object. You should add your configuration with the [@cfgdata] method calls and finally use it in a call to [configurefile].

POSARGS

0 dict

Optional dictionary to specify an initial data set. If provided, each key/value pair is added into the [@cfgdata] object as if the [cfgdata.set] method was called for each of them.

SYNOPSIS
configure_file(
build_subdir str:,
capture bool:,
command list:,
configuration cfg_data|dict:,
copy bool:,
depfile str:,
encoding str:,
format str:,
input listify[both_libs|build_tgt|custom_tgt|file|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
macro_name str:,
output str:,
output_format str:,
) -> file

DESCRIPTION

This function can run in three modes depending on the keyword arguments passed to it.

When a [@cfgdata] object is passed to the configuration: keyword argument, it takes a template file as the input: (optional) and produces the output: (required) by substituting values from the configuration data as detailed in [the configuration file documentation]. (since 0.49.0) A dictionary can be passed instead of a [@cfgdata] object.

When an array of strings is passed to the command: keyword argument, it takes any source or configured file as the input: and assumes that the output: is produced when the specified command is run.

You can install the outputted file with the install_dir: kwarg, see below.

(since 0.47.0) When the copy: keyword argument is set to true, this function will copy the file provided in input: to a file in the build directory with the name output: in the current directory.

KWARGS

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

capture bool

When this argument is set to true, Meson captures stdout of the command and writes it to the target file specified as output.

command list

As explained above, if specified, Meson does not create the file itself but rather runs the specified command, which allows you to do fully custom file generation. (since 0.52.0) The command can contain file objects and more than one file can be passed to the input keyword argument, see [customtarget] for details about string substitutions.

configuration cfg_data|dict

As explained above, when passed this will provide the replacement data for the input file (if provided) or key value pairs to be written to the output.

copy bool

As explained above, if specified Meson only copies the file from input to output.

depfile str

A dependency file that the command can write listing all the additional files this target depends on. A change in any one of these files triggers a reconfiguration.

encoding str

Set the file encoding for the input and output file. The supported encodings are those of python3, see [standard-encodings].

format str

The format of defines. It defaults to 'meson', and so substitutes #mesondefine statements and variables surrounded by @ characters, you can also use 'cmake' to replace #cmakedefine statements and variables with the ${variable} syntax. Finally you can use 'cmake@' in which case substitutions will apply on #cmakedefine statements and variables with the @variable@ syntax.

input listify[both_libs|build_tgt|custom_tgt|file|str]

The input file name. If it's not specified in configuration mode, all the variables in the configuration: object (see above) are written to the output: file.

install bool

When true, this generated file is installed during the install step, and install_dir must be set and not empty. When false, this generated file is not installed regardless of the value of install_dir. When omitted it defaults to true when install_dir is set and not empty, false otherwise.

install_dir str

The subdirectory to install the generated file to (e.g. share/myproject), if omitted or given the value of empty string, the file is not installed.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default the file has no install tag which means it is not being installed when --tags argument is specified.

macro_name str

When specified, macro guards will be used instead of '#pragma once'. The macro guard name will be the specified name.

output str

The output file name. (since 0.41.0) may contain @PLAINNAME@ or @BASENAME@ substitutions, as well as (since 1.5.0) their indexed versions, like @PLAINNAME0@ or @BASENAME0@. In configuration mode, the permissions of the input file (if it is specified) are copied to the output file.

output_format str

The format of the output to generate when no input was specified. It defaults to c, in which case preprocessor directives will be prefixed with #, you can also use nasm, in which case the prefix will be %. (since 1.3.0) json format can also be used.

SYNOPSIS
custom_target(
str,
build_always bool:,
build_always_stale bool:,
build_by_default bool:,
build_subdir str:,
capture bool:,
command listify[exe]:,
console bool:,
depend_files listify[file|str]:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
depfile str:,
env dict[listify[str]]|env|listify[str]:,
feed bool:,
input listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
install bool:,
install_dir listify[bool|str]:,
install_mode listify[bool|int|str]:,
install_tag str:,
output listify[str]:,
) -> custom_tgt

DESCRIPTION

Create a custom top level build target. The only positional argument is the name of this target and cannot contain path separators (/ or . The name of custom target might not be used by every backends, for instance with the Ninja backend, subdir/meson.build containing the example below, ninja -C builddir foo or ninja -C builddir subdir/foo won't work, it is instead ninja -C builddir subdir/file.txt. However, meson compile subdir/foo is accepted. .nf

custom_target('foo', output: 'file.txt', ...)


The files passed to output: cannot contain path separators. See the [manual on custom build targets] for an explanation on where output files should be placed.

You can install the outputted files with the install_dir: kwarg, see below.

Since 0.60.0 the name argument is optional and defaults to the basename of the first output (file.txt in the example above).

The array of strings passed to the command keyword argument accept the following special string substitutions:

  • @INPUT@: the full path to the input passed to input. If more than one input is specified, all of them will be substituted as separate arguments only if the command uses '@INPUT@' as a standalone-argument. For instance, this would not work: command : ['cp', './@INPUT@'], but this would: command : ['cp', '@INPUT@'].
  • @OUTPUT@: the full path to the output passed to output. If more than one outputs are specified, the behavior is the same as @INPUT@.
  • @INPUT0@ @INPUT1@ ...: the full path to the input with the specified array index in input
  • @OUTPUT0@ @OUTPUT1@ ...: the full path to the output with the specified array index in output
  • @OUTDIR@: the full path to the directory where the output(s) must be written
  • @DEPFILE@: the full path to the dependency file passed to depfile
  • @PLAINNAME@: the input filename, without a path
  • @PLAINNAME0@ @PLAINNAME1@ ... (since 1.5.0): the input filename without a path, with the specified array index in input
  • @BASENAME@: the input filename, with extension removed
  • @BASENAME0@ @BASENAME1@ ... (since 1.5.0): the input filename with extension removed, with the specified array index in input
  • @PRIVATE_DIR@ (since 0.50.1): path to a directory where the custom target must store all its intermediate files.
  • @SOURCE_ROOT@: the path to the root of the source tree. Depending on the backend, this may be an absolute or a relative to current workdir path.
  • @BUILD_ROOT@: the path to the root of the build tree. Depending on the backend, this may be an absolute or a relative to current workdir path.
  • @CURRENT_SOURCE_DIR@: this is the directory where the currently processed meson.build is located in. Depending on the backend, this may be an absolute or a relative to current workdir path.

(since 0.47.0) The depfile keyword argument also accepts the @BASENAME@ and @PLAINNAME@ substitutions.

The returned object also has methods that are documented in [@customtgt].

POSARGS

0 str

The unique id of the custom target

This posarg is optional since 0.60.0. It defaults to the basename of the first output.

KWARGS
build_always bool

If true this target is always considered out of date and is rebuilt every time. Equivalent to setting both build_always_stale and build_by_default to true.

build_always_stale bool

If true the target is always considered out of date. Useful for things such as build timestamps or revision control tags. The associated command is run even if the outputs are up to date.

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is false.

(since 0.50.0) If build_by_default is explicitly set to false, install will no longer override it. If build_by_default is not set, install will still determine its default.

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

capture bool

There are some compilers that can't be told to write their output to a file but instead write it to standard output. When this argument is set to true, Meson captures stdout and writes it to the target file. Note that your command argument array may not contain @OUTPUT@ when capture mode is active.

command listify[exe]

Command to run to create outputs from inputs. The command may be strings or the return value of functions that return file-like objects such as [findprogram], [executable], [configurefile], [files], [customtarget], etc. Meson will automatically insert the appropriate dependencies on targets and files listed in this keyword argument. Note: always specify commands in array form ['commandname', '-arg1', '-arg2'] rather than as a string 'commandname -arg1 -arg2' as the latter will not work.

Note: due to an [issue with path handling] any backslash ( characters are rewritten as slash (/).

console bool

Keyword argument conflicts with capture, and is meant for commands that are resource-intensive and take a long time to finish. With the Ninja backend, setting this will add this target to [Ninja's console pool], which has special properties such as not buffering stdout and serializing all targets in this pool.

depend_files listify[file|str]

files ([@str], [@file], or the return value of [configurefile] that this target depends on but are not listed in the command keyword argument. Useful for adding regen dependencies.

depends listify[both_libs|build_tgt|custom_tgt|file]

Specifies that this target depends on the specified target(s), even though it does not take any of them as a command line argument. This is meant for cases where you have a tool that e.g. does globbing internally. Usually you should just put the generated sources as inputs and Meson will set up all dependencies automatically (customidx was unavailable as a type between 0.60 and 1.4.0).

depfile str

A dependency file that the command can write listing all the additional files this target depends on, for example a C compiler would list all the header files it included, and a change in any one of these files triggers a recompilation.

(since 0.47.0) the @BASENAME@ and @PLAINNAME@ substitutions are also accepted.

env dict[listify[str]]|env|listify[str]

environment variables to set, such as {'NAME1': 'value1', 'NAME2': 'value2'} or ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling.

feed bool

There are some compilers that can't be told to read their input from a file and instead read it from standard input. When this argument is set to true, Meson feeds the input file to stdin. Note that your argument array may not contain @INPUT@ when feed mode is active.

input listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Array of source files. (since 0.41.0) the array is flattened.

install bool

When true, one or more files of this target are installed during the install step (see install_dir for details).

install_dir listify[bool|str]

If only one installdir is provided, all outputs are installed there. Since 0.40.0 Allows you to specify the installation directory for each corresponding output. For example: .nf

custom_target('different-install-dirs',
output : ['first.file', 'second.file'],
install : true,
install_dir : ['somedir', 'otherdir'])


This would install first.file to somedir and second.file to otherdir.

To only install some outputs, pass false for the outputs that you don't want installed. For example: .nf


custom_target('only-install-second',
output : ['first.file', 'second.file'],
install : true,
install_dir : [false, 'otherdir'])


This would install second.file to otherdir and not install first.file.

install_mode listify[bool|int|str]

The file mode and optionally the owner/uid and group/gid. See the install_mode kwarg of [installdata] for more information.

install_tag str

An array of strings, one per output, used by the meson install --tags command to install only a subset of the files.

By default all outputs have no install tag which means they are not being installed when --tags argument is specified. If only one tag is specified, it is assumed that all outputs have the same tag. false can be used for outputs that have no tag or are not installed.

output listify[str]

Array of output files. These cannot contain path separators.

SYNOPSIS
debug(
glob[bool|dict|feature|file|int|list|str],
)

DESCRIPTION

Write the argument string to the meson build log.

POSARGS

0 glob[bool|dict|feature|file|int|list|str]

The message to print

SYNOPSIS
declare_dependency(
compile_args listify[str]:,
dependencies listify[dep]:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
include_directories listify[inc|str]:,
link_args listify[str]:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
link_with_raw listify[str]:,
objects listify[file|str]:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
variables dict|list|str:,
version str:,
) -> dep

DESCRIPTION

This function returns a [@dep] object that behaves like the return value of [dependency] but is internal to the current build. One use case for this is in subprojects. This allows a subproject to easily specify how it should be used. This makes it interchangeable with the same dependency that is provided externally by the system. Another common use case is to declare project targets as dependencies so they may be used as dependencies of other build targets.

KWARGS

compile_args listify[str]

Compile arguments to use.

dependencies listify[dep]

Other dependencies needed to use this dependency.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

extra files to add to targets. mostly used for IDE integration.

include_directories listify[inc|str]

the directories to add to header search path, must be [@inc] objects or (since 0.50.0) plain strings.

link_args listify[str]

Link arguments to use.

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Libraries to link fully, same as [executable].

link_with listify[both_libs|build_tgt|custom_tgt|file]

Libraries to link against.

link_with_raw listify[str]

objects listify[file|str]

an array of object files, to be linked directly into the targets that use the dependency.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

sources to add to targets (or generated header files that should be built before sources including them are built)

variables dict|list|str

a dictionary of arbitrary strings, this is meant to be used in subprojects where special variables would be provided via cmake or pkg-config. since 0.56.0 it can also be an array of 'key=value' strings.

version str

the version of this dependency, such as 1.2.3. Defaults to the project version.

SYNOPSIS
dependency(
glob[str],
allow_fallback bool:,
components listify[str]:,
default_options dict[bool|int|list|str]|list[str]|str:,
disabler bool:,
fallback listify[str]:,
include_type str:,
language str:,
main bool:,
method str:,
modules listify[str]:,
native bool:,
not_found_message str:,
optional_modules listify[str]:,
required bool|feature:,
static bool:,
version listify[str]:,
) -> dep

DESCRIPTION

Finds an external dependency (usually a library installed on your system) with the given name with pkg-config and [with CMake] if pkg-config fails. Additionally, frameworks (OSX only) and [library-specific fallback detection logic] are also supported.

Since 0.60.0 more than one name can be provided, they will be tried in order and the first name to be found will be used. The fallback subproject will be used only if none of the names are found on the system. Once one of the name has been found, all other names are added into the cache so subsequent calls for any of those name will return the same value. This is useful in case a dependency could have different names, such as png and libpng.

•
Since 0.64.0 a dependency fallback can be provided by WrapDB. Simply download t.PD he database locally using meson wrap update-db command and Meson will automatically fallback to subprojects provided by WrapDB if the dependency is not found on the system and the project does not ship their own .wrap file.

Dependencies can also be resolved in two other ways:

•
if the same name was used in a meson.override_dependency prior to the call to dependency, the overriding dependency will be returned unconditionally; that is, the overriding dependency will be used independent of whether an external dependency is installed in the system. Typically, meson.override_dependency will have been used by a subproject.

•
by a fallback subproject which, if needed, will be brought into the current build specification as if [subproject()] had been called. The subproject can be specified with the fallback argument. Alternatively, if the fallback argument is absent, since 0.55.0 Meson can automatically identify a subproject as a fallback if a wrap file [provides] the dependency, or if a subproject has the same name as the dependency. In the latter case, the subproject must use meson.override_dependency to specify the replacement, or Meson will report a hard error. See the [Wrap documentation] for more details. This automatic search can be controlled using the allow_fallback keyword argument.

If dependency_name is '', the dependency is always not found. So with required: false, this always returns a dependency object for which the found() method returns false, and which can be passed like any other dependency to the dependencies: keyword argument of a build_target. This can be used to implement a dependency which is sometimes not required e.g. in some branches of a conditional, or with a fallback: kwarg, can be used to declare an optional dependency that only looks in the specified subproject, and only if that's allowed by --wrap-mode.

The returned object [@dep] also has additional methods.

POSARGS

0 glob[str]

The names of the dependency to look up. The dependencies are looked up in the order they are provided here. The first found dependency will then be used. The fallback subproject will be used only if none of the names are found on the system. Once one of the name has been found, all other names are added into the cache so subsequent calls for any of those name will return the same value. This is useful in case a dependency could have different names, such as png and libpng.

NOTE: Before 0.60.0 only a single dependency name was allowed.

KWARGS
allow_fallback bool

Specifies whether Meson should automatically pick a fallback subproject in case the dependency is not found in the system. If true and the dependency is not found on the system, Meson will fallback to a subproject that provides this dependency. If false, Meson will not fallback even if a subproject provides this dependency. By default, Meson will do so if required is true or [enabled]; see the [Wrap documentation] for more details.

components listify[str]

Ignored

default_options dict[bool|int|list|str]|list[str]|str

An array of default option values that override those set in the subproject's meson.options (like default_options in [project], they only have effect when Meson is run for the first time, and command line arguments override any default options in build files) (since 1.2.0): A dictionary may now be passed.

disabler bool

Returns a [disabler] object instead of a not-found dependency if this kwarg is set to true and the dependency couldn't be found.

fallback listify[str]

Manually specifies a subproject fallback to use in case the dependency is not found in the system. This is useful if the automatic search is not applicable or if you want to support versions of Meson older than 0.55.0. If the value is an array ['subproj_name', 'subproj_dep'], the first value is the name of the subproject and the second is the variable name in that subproject that contains a dependency object such as the return value of [declaredependency] or [dependency], etc. Note that this means the fallback dependency may be a not-found dependency, in which case the value of the required: kwarg will be obeyed. Since 0.54.0 the value can be a single string, the subproject name; in this case the subproject must use meson.override_dependency('dependency_name', subproj_dep) to specify the dependency object used in the superproject. If the value is an empty array it has the same effect as allow_fallback: false.

include_type str

An enum flag, marking how the dependency flags should be converted. Supported values are 'preserve', 'system' and 'non-system'. System dependencies may be handled differently on some platforms, for instance, using -isystem instead of -I, where possible. If include_type is set to 'preserve', no additional conversion will be performed.

language str

Ignored

main bool

Ignored

method str

Defines the way the dependency is detected, the default is auto but can be overridden to be e.g. qmake for Qt development, and [different dependencies support different values] for this (though auto will work on all of them)

modules listify[str]

A list of sub-dependencies for this dependency. Only supported by certain dependencies.

native bool

If set to true, causes Meson to find the dependency on the build machine system rather than the host system (i.e. where the cross compiled binary will run on), usually only needed if you build a tool to be used during compilation.

not_found_message str

An optional string that will be printed as a [message] if the dependency was not found.

optional_modules listify[str]

Ignored

required bool|feature

When set to false, Meson will proceed with the build even if the dependency is not found.

When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

(since 0.47.0) The value of a feature option can also be passed.

static bool

Tells the dependency provider to try to get static libraries instead of dynamic ones (note that this is not supported by all dependency backends)

Leaving this value unset will result in an implementation defined default value. For most dependencies this means the value of the prefer_static option, but some custom dependencies have their own method for determining the most useful default option.

Since 0.60.0 it also sets default_library option accordingly on the fallback subproject if it was not set explicitly in default_options keyword argument.

Since 0.63.0 when the prefer_static option is used to calculate the default value.

version listify[str]

Specifies the required version, a string containing a comparison operator followed by the version string, examples include >1.0.0, <=2.3.5 or 3.1.4 for exact matching. You can also specify multiple restrictions by passing an array to this keyword argument, such as: ['>=3.14.0', '<=4.1.0']. These requirements are never met if the version is unknown.

SYNOPSIS
disabler(
) -> disabler

DESCRIPTION

Returns a [@disabler] object.

SYNOPSIS
environment(
dict[listify[str]]|listify[str],
method str[append|prepend|set]:,
separator str:,
) -> env

DESCRIPTION

Returns an empty [@env] object.

POSARGS

0 dict[listify[str]]|listify[str]

If provided, each key/value pair is added into the [@env] object as if [env.set] method was called for each of them. Since 0.62.0 arrays of strings are allowed in dictionary values. In that case values are joined using the separator.

KWARGS
method str[append|prepend|set]

Must be one of 'set', 'prepend', or 'append' (defaults to 'set'). Controls if initial values defined in the first positional argument are prepended, appended or replace the current value of the environment variable.

separator str

The separator to use for the initial values defined in the first positional argument. If not explicitly specified, the default path separator for the host operating system will be used, i.e. ';' for Windows and ':' for UNIX/POSIX systems.

SYNOPSIS
error(
glob[bool|dict|feature|file|int|list|str],
)

DESCRIPTION

Print the argument string and halts the build process.

POSARGS

0 glob[bool|dict|feature|file|int|list|str]

The message to print

SYNOPSIS
executable(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> build_tgt

DESCRIPTION

Creates a new executable. The first argument specifies its name and the remaining positional arguments define the input files to use.

The arrays for the kwargs (such as sources, objects, and dependencies) are always flattened, which means you can freely nest and add arrays while creating the final array.

The returned object also has methods that are documented in [@exe].

Since 1.3.0 executable names can be the same across multiple targets as long as they each have a different name_suffix.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

This can be used to expose which functions a sharedmodule loaded by an executable will be allowed to use.

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
files(
glob[str],
) -> list

DESCRIPTION

This command takes the strings given to it in arguments and returns corresponding File objects that you can use as sources for build targets. The difference is that file objects remember the subdirectory they were defined in and can be used anywhere in the source tree.

POSARGS

0 glob[str]

Path to the file.

SYNOPSIS
find_program(
glob[file|str],
default_options dict[bool|int|list|str]|list[str]|str:,
dirs listify[str]:,
disabler bool:,
native bool:,
required bool|feature:,
version listify[str]:,
version_argument str:,
) -> external_program

DESCRIPTION

program_name here is a string that can be an executable or script to be searched for in PATH or other places inside the project. The search order is:

1. Program overrides set via [meson.overridefindprogram] 1. [[provide] sections] in subproject wrap files, if [wrap_mode] is set to forcefallback 1. [[binaries] section] in your machine files 1. Directories provided using the dirs: kwarg (see below) 1. Project's source tree relative to the current subdir - If you use the return value of [configurefile], the current subdir inside the build tree is used instead 1. PATH environment variable 1. [[provide] sections] in subproject wrap files, if [wrap_mode] is set to anything other than nofallback

Meson will also autodetect scripts with a shebang line and run them with the executable/interpreter specified in it both on Windows (because the command invocator will reject the command otherwise) and Unixes (if the script file does not have the executable bit set). Hence, you must not manually add the interpreter while using this script as part of an array of commands. Since 0.50.0 if the "python3" program is requested and it is not found in the system, Meson will return its current interpreter.

If you need to check for a program in a non-standard location, you can just pass an absolute path to find_program, e.g.

setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)

It is also possible to pass an array to find_program in case you need to construct the set of paths to search on the fly:

setcap = find_program(['setcap', '/usr/sbin/setcap', '/sbin/setcap'], required : false)

Since 1.2.0 find_program('meson') is automatically overridden to the Meson command used to execute the build script.

The returned [@program] object also has documented methods.

POSARGS

0 glob[file|str]

The name of the program to search, or a [@file] object to be used without searching.

KWARGS
default_options dict[bool|int|list|str]|list[str]|str

An array of default option values that override those set in the subproject's meson.options (like default_options in [project], they only have effect when Meson is run for the first time, and command line arguments override any default options in build files)

dirs listify[str]

extra array of absolute paths where to look for program names.

disabler bool

If true and the program couldn't be found, return a [@disabler] object instead of a not-found object.

native bool

Defines how this executable should be searched. By default it is set to false, which causes Meson to first look for the executable in the cross file (when cross building) and if it is not defined there, then from the system. If set to true, the cross file is ignored and the program is only searched from the system.

required bool|feature

When true, Meson will abort if no program can be found. If required is set to false, Meson continue even if none of the programs can be found. You can then use the .found() method on the returned [@program] to check whether it was found or not. (since 0.47.0) The value of a [feature] option can also be passed to the required keyword argument.

version listify[str]

Specifies the required version, see [dependency] for argument format. By default, the version of the program is determined by running program_name --version command. If stdout is empty it fallbacks to stderr. If the output contains more text than simply a version number, only the first occurrence of numbers separated by dots is kept. If the output is more complicated than that, the version checking will have to be done manually using [runcommand].

version_argument str

Specifies the argument to pass when trying to find the version of the program. If this is unspecified, program_name --version will be used.

SYNOPSIS
generator(
exe,
arguments list:,
capture bool:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
depfile str:,
output listify[str]:,
) -> generator

DESCRIPTION

See also: [customtarget]

This function creates a [@generator] object that can be used to run custom compilation commands. The only positional argument is the executable to use. It can either be a self-built executable or one returned by findprogram.

The template strings passed to all the keyword arguments accept the following special substitutions:

  • @PLAINNAME@: the complete input file name, e.g: foo.c becomes foo.c (unchanged)
  • @BASENAME@: the base of the input filename, e.g.: foo.c.y becomes foo.c (extension is removed)

Each string passed to the output keyword argument must be constructed using one or both of these two substitutions.

In addition to the above substitutions, the arguments keyword argument also accepts the following:

  • @OUTPUT@: the full path to the output file
  • @INPUT@: the full path to the input file
  • @DEPFILE@: the full path to the depfile
  • @SOURCE_DIR@: the full path to the root of the source tree
  • @CURRENT_SOURCE_DIR@: this is the directory where the currently processed meson.build is located in
  • @BUILD_DIR@: the full path to the root of the build dir where the output will be placed

NOTE: Generators should only be used for outputs that will only be used as inputs for a [buildtarget] or a [customtarget]. When you use the processed output of a generator in multiple targets, the generator will be run multiple times to create outputs for each target. Each output will be created in a target-private directory @BUILD_DIR@.

If you want to generate files for general purposes such as for generating headers to be used by several sources, or data that will be installed, and so on, use a [customtarget] instead.

POSARGS

0 exe

Executable for the command to run

KWARGS
arguments list

An array of template strings that will be the command line arguments passed to the executable.

capture bool

When this argument is set to true, Meson captures stdout of the executable and writes it to the target file specified as output.

depends listify[both_libs|build_tgt|custom_tgt|file]

An array of build targets that must be built before this generator can be run. This is used if you have a generator that calls a second executable that is built in this project (customidx was not available between 0.60 and 1.4.0).

depfile str

A template string pointing to a dependency file that a generator can write listing all the additional files this target depends on, for example a C compiler would list all the header files it included, and a change in any one of these files triggers a recompilation,

output listify[str]

Template string (or array of template strings) defining how an output file name is (or multiple output names are) generated from a single source file name.

SYNOPSIS
get_option(
str,
) -> bool|feature|int|list|str

DESCRIPTION

Obtains the value of the [project build option] specified in the positional argument.

Note that the value returned for built-in options that end in dir such as bindir and libdir is usually a path relative to (and inside) the prefix but you should not rely on that, as it can also be an absolute path [in some cases]. [install_dir arguments] handle that as expected but if you need an absolute path, e.g. to use in a define etc., you should use the path concatenation operator like this: get_option('prefix') / get_option('localstatedir'). Never manually join paths as if they were strings.

For options of type feature a [@feature] option object is returned instead of a string. See [feature options] documentation for more details.

For options that are [specified per-machine] get_option() retrieves the value of the option for the build machine if the argument starts with build..

POSARGS

0 str

Name of the option to query

SYNOPSIS
get_variable(
any,
any,
) -> any

DESCRIPTION

This function can be used to dynamically obtain a variable. res = get_variable(varname, fallback) takes the value of varname (which must be a string) and stores the variable of that name into res. If the variable does not exist, the variable fallback is stored to resinstead. If a fallback is not specified, then attempting to read a non-existing variable will cause a fatal error.

POSARGS

0 any

Name of the variable to get

1 any

Fallback value to return when the variable does not exist

SYNOPSIS
import(
str,
disabler bool:,
required bool|feature:,
) -> module

DESCRIPTION

Imports the given extension module. Returns an object that can be used to call the methods of the module. Here's an example for a hypothetical testmod module.

POSARGS

0 str

Name of the module to import.

KWARGS
disabler bool

Returns a [@disabler] object when not found.

required bool|feature

When set to false, Meson will proceed with the build even if the module is not found. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
include_directories(
glob[inc|str],
is_system bool:,
) -> list

DESCRIPTION

Returns an opaque object which contains the directories (relative to the current directory) given in the positional arguments. The result can then be passed to the include_directories: keyword argument when building executables or libraries. You can use the returned object in any subdirectory you want, Meson will make the paths work automatically.

Note that this function call itself does not add the directories into the search path, since there is no global search path. For something like that, see [add_project_arguments()].

See also implicit_include_directories parameter of [executable], which adds current source and build directories to include path.

Each directory given is converted to two include paths: one that is relative to the source root and one relative to the build root.

POSARGS

0 glob[inc|str]

Include paths to add.

KWARGS
is_system bool

If set to true, flags the specified directories as system directories. This means that they will be used with the -isystem compiler argument rather than -I on compilers that support this flag (in practice everything except Visual Studio).

SYNOPSIS
install_data(
glob[file|str],
follow_symlinks bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
preserve_path bool:,
rename listify[str]:,
sources listify[file|str]:,
)

DESCRIPTION

Installs files from the source tree that are listed as positional arguments. Please note that this can only install static files from the source tree. Generated files are installed via the install_dir: kwarg on the respective generators, such as custom_target() or configure_file().

See [Installing] for more examples.

POSARGS

0 glob[file|str]

Files to install.

KWARGS
follow_symlinks bool

If true, dereferences links and copies their target instead. The default value will become false in the future.

install_dir str

The absolute or relative path to the installation directory. If this is a relative path, it is assumed to be relative to the prefix.

If omitted, the directory defaults to {datadir}/{projectname} (since 0.45.0).

install_mode listify[bool|int|str]

specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files. For example:

install_mode: 'rw-r--r--' for just the file mode

install_mode: ['rw-r--r--', 'nobody', 'nogroup'] for the file mode and the user/group

install_mode: ['rw-r-----', 0, 0] for the file mode and uid/gid

To leave any of these three as the default, specify false.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have no install tag which means they are not being installed when --tags argument is specified.

preserve_path bool

Disable stripping child-directories from data files when installing.

This is equivalent to GNU Automake's nobase option.

rename listify[str]

If specified renames each source file into corresponding file from rename array. Nested paths are allowed and they are joined with install_dir. Length of rename array must be equal to the number of sources.

sources listify[file|str]

Additional files to install.

SYNOPSIS
install_emptydir(
glob[str],
install_mode listify[bool|int|str]:,
install_tag str:,
)

DESCRIPTION

Installs a new directory entry to the location specified by the positional argument. If the directory exists and is not empty, the contents are left in place.

POSARGS

0 glob[str]

Directory to create during installation.

KWARGS
install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the created directory.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default this directory has no install tag which means it is not installed when the --tags argument is specified.

SYNOPSIS
install_headers(
glob[file|str],
follow_symlinks bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
preserve_path bool:,
subdir str:,
)

DESCRIPTION

Installs the specified header files from the source tree into the system header directory (usually /{prefix}/include) during the install step. This directory can be overridden by specifying it with the install_dir keyword argument. If you just want to install into a subdirectory of the system header directory, then use the subdir argument. As an example if this has the value myproj then the headers would be installed to /{prefix}/include/myproj.

Please note that this can only install static files from the source tree. Generated files are installed via the install_dir: kwarg on the respective generators, such as custom_target() or configure_file().

POSARGS

0 glob[file|str]

Header files to install.

KWARGS
follow_symlinks bool

If true, dereferences links and copies their target instead. The default value will become false in the future.

install_dir str

Where to install to.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have the devel install tag which means they are installed explicitly or when no tags given at all.

preserve_path bool

Disable stripping child-directories from header files when installing.

This is equivalent to GNU Automake's nobase option.

subdir str

Install to the subdir subdirectory of the default includedir.

Incompatible with the install_dir kwarg.

SYNOPSIS
install_man(
glob[both_libs|build_tgt|custom_tgt|file|str],
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
locale str:,
)

DESCRIPTION

Installs the specified man files from the source tree into system's man directory during the install step. This directory can be overridden by specifying it with the install_dir keyword argument.

(since 0.49.0) [manpages are no longer compressed implicitly][installman49]. (since 1.11.0) installman supports install_tag kwarg

[installman49]: https://mesonbuild.com/Release-notes-for-0-49-0.html#manpages-are-no-longer-compressed-implicitly

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|str]

Man pages to install.

KWARGS
install_dir str

Where to install to.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have man install tag which means they are installed explicitly or when no tags given at all

locale str

Can be used to specify the locale into which the man page will be installed within the manual page directory tree. An example manual might be foo.fr.1 with a locale of fr, such that {mandir}/{locale}/man{num}/foo.1 becomes the installed file.

SYNOPSIS
install_subdir(
str,
exclude_directories listify[str]:,
exclude_files listify[str]:,
follow_symlinks bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
strip_directory bool:,
)

DESCRIPTION

Installs the entire given subdirectory and its contents from the source tree to the location specified by the keyword argument install_dir.

(since 0.45.0, deprecated since 0.60.0) If the subdirectory does not exist in the source tree, an empty directory is created in the specified location. A newly created subdirectory may only be created in the keyword argument install_dir. There are a number of flaws with this method, and it was never intentionally designed to work this way, please use [installemptydir] instead.

POSARGS

0 str

The sub-directory to install

KWARGS
exclude_directories listify[str]

An array of directory names that should not be installed. Names are interpreted as paths relative to the subdir_name location.

exclude_files listify[str]

An array of file names that should not be installed. Names are interpreted as paths relative to the subdir_name location.

follow_symlinks bool

If true, dereferences links and copies their target instead. The default value will become false in the future.

install_dir str

Where to install to.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have no install tag which means they are not being installed when --tags argument is specified.

strip_directory bool

Install directory contents. If strip_directory=true only the last component of the source path is used.

SYNOPSIS
install_symlink(
str,
install_dir str:,
install_tag str:,
pointing_to str:,
)

DESCRIPTION

Installs a symbolic link to pointing_to target under installdir.

POSARGS

0 str

Name of the created link under install_dir. It cannot contain path separators. Those should go in install_dir.

KWARGS
install_dir str

The absolute or relative path to the installation directory for the links. If this is a relative path, it is assumed to be relative to the prefix.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have no install tag which means they are not being installed when --tags argument is specified.

pointing_to str

Target to point the link to. Can be absolute or relative and that will be respected when creating the link.

SYNOPSIS
is_disabler(
any,
) -> bool

DESCRIPTION

Returns true if a variable is a disabler and false otherwise.

POSARGS

0 any

The variable to test

SYNOPSIS
is_null(
any|null,
) -> bool

POSARGS

0 any|null

SYNOPSIS
is_variable(
str,
) -> bool

DESCRIPTION

Returns true if a variable of the given name exists and false otherwise.

POSARGS

0 str

The variable to test

SYNOPSIS
join_paths(
glob[str],
) -> str

DESCRIPTION

Joins the given strings into a file system path segment. For example join_paths('foo', 'bar') results in foo/bar. If any one of the individual segments is an absolute path, all segments before it are dropped. That means that join_paths('foo', '/bar') returns /bar.

(since 0.49.0) Using the / operator on strings is equivalent to calling [joinpaths].

# res1 and res2 will have identical values
res1 = join_paths(foo, bar)
res2 = foo / bar

0

POSARGS

0 glob[str]

The path parts to join.

SYNOPSIS
library(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> both_libs|build_tgt

DESCRIPTION

Builds a library that is either static, shared or both depending on the value of default_library user [option]. You should use this instead of [sharedlibrary], [staticlibrary] or [bothlibraries] most of the time. This allows you to toggle your entire project (including subprojects) from shared to static with only one option. This option applies to libraries being built internal to the entire project. For external dependencies, the default library type preferred is shared. This can be adapted on a per library basis using the [dependency] static keyword.

The keyword arguments for this are the same as for [buildtarget]

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

(Since 1.3.0) [@customidx] are supported

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
message(
glob[bool|dict|feature|file|int|list|str],
)

DESCRIPTION

This function prints its argument to stdout.

POSARGS

0 glob[bool|dict|feature|file|int|list|str]

The message to print.

SYNOPSIS
option(
str,
choices list:,
deprecated bool|str|dict[str]|list[str]:,
description str:,
max int:,
min int:,
type str:,
value any:,
yield bool:,
)

POSARGS

0 str

KWARGS
choices list

deprecated bool|str|dict[str]|list[str]

description str

max int

min int

type str

value any

yield bool

SYNOPSIS
p(
any|null,
inspect bool:,
pretty bool:,
) -> any

POSARGS

0 any|null

KWARGS
inspect bool

pretty bool

SYNOPSIS
print(
str,
) -> any

POSARGS

0 str

SYNOPSIS
project(
str,
glob[str],
default_options dict[bool|int|list|str]|list[str]|str:,
license listify[str]:,
license_files listify[str]:,
meson_version str:,
module_dir str:,
subproject_dir str:,
version file|str:,
)

DESCRIPTION

The first function called in each project, to initialize Meson.

The first argument to this function must be a string defining the name of this project.

The project name can be any string you want, it's not used for anything except descriptive purposes. However since it is written to e.g. the dependency manifest it usually makes sense to have it be the same as the project tarball or pkg-config name. So for example you would probably want to use the name libfoobar instead of The Foobar Library.

It may be followed by the array of programming languages that the project uses.

(since 0.40.0) The array of languages is optional.

These languages may be used both for native: false (the default) (host machine) targets and for native: true (build machine) targets. (since 0.56.0) The build machine compilers for the specified languages are not required.

Supported values for languages are c, cpp (for C++), cuda, cython, d, objc, objcpp, fortran, java, cs (for C#), swift, nasm, masm, linearasm, vala and rust.

POSARGS

0 str

The name of the project.

1 glob[str]

The languages that Meson should initialize.

KWARGS
default_options dict[bool|int|list|str]|list[str]|str

Accepts strings in the form key=value which have the same format as options to meson configure. For example to set the default project type you would set this: default_options : ['buildtype=debugoptimized']. Note that these settings are only used when running Meson for the first time.

Note that some options can override the default behavior; for example, using c_args here means that the CFLAGS environment variable is not used. Consider using [addprojectarguments()] instead.

Also note that not all options are taken into account when building as a subproject, and the exact set of options that are per-subproject has increased over time; for more information, see [core options] and [compiler options].

(since 1.2.0): A dictionary may now be passed.

license listify[str]

Takes a string or array of strings describing the license(s) the code is under.

This should be an [SPDX license expression], using the standardized license identifier from the [SPDX license list]. Usually this would be something like license : 'GPL-2.0-or-later'. If there are multiple licenses you can use the AND and OR operators to join them: license : 'Apache-2.0 OR GPL-2.0'.

For backwards compatibility reasons you can also pass an array of licenses here. This is not recommended, as it is ambiguous: license : ['Apache-2.0', 'GPL-2.0-only'] instead use an SPDX expression: license : 'Apache-2.0 OR GPL-2.0-only', which makes it clear that the license mean OR, not AND.

Note that the text is informal and is only written to the dependency manifest. Meson does not do any license validation, you are responsible for verifying that you abide by all licensing terms. You can access the value in your Meson build files with meson.project_license().

license_files listify[str]

Takes a string or array of strings with the paths to the license file(s) the code is under.

This enhances the value of the license kwarg by allowing to specify both the short license name and the full license text. Usually this would be something like license_files: ['COPYING'].

Note that the files are informal and are only installed with the dependency manifest. Meson does not do any license validation, you are responsible for verifying that you abide by all licensing terms. You can access the value in your Meson build files with [meson.projectlicensefiles].

meson_version str

Takes a string describing which Meson version the project requires. Usually something like >=0.28.0.

module_dir str

Specify a directory to search for .meson files in when import()-ing modules

subproject_dir str

Specifies the top level directory name that holds Meson subprojects. This is only meant as a compatibility option for existing code bases that house their embedded source code in a custom directory. All new projects should not set this but instead use the default value. It should be noted that this keyword argument is ignored inside subprojects. There can be only one subproject dir and it is set in the top level Meson file.

version file|str

A free form string describing the version of this project. You can access the value in your Meson build files with [meson.projectversion]. (Since 0.57.0) this can also be a [@file] object pointing to a file that contains exactly one line of text.

SYNOPSIS
range(
int,
int,
int,
) -> list

DESCRIPTION

Return an opaque object that can be only be used in foreach statements.

<pre><code class="language-meson">[@range] range([@int] <b>stop</b>) [@range] range([@int] <b>start</b>, [@int] <b>stop</b>[, [@int] <b>step</b>])</code></pre>

  • start must be integer greater or equal to 0. Defaults to 0.
  • stop must be integer greater or equal to start.
  • step must be integer greater or equal to 1. Defaults to 1.

It cause the foreach loop to be called with the value from start included to stop excluded with an increment of step after each loop.

POSARGS

0 int

The start of the range

1 int

The end of the range

2 int

The loop increment

SYNOPSIS
run_command(
glob[compiler|external_program|file|python_installation|str],
capture bool:,
check bool:,
console bool:,
env dict[listify[str]]|env|listify[str]:,
feed both_libs|build_tgt|custom_tgt|file|str:,
) -> runresult

DESCRIPTION

Runs the command specified in positional arguments. command can be a string, or the output of [findprogram], [files] or [configurefile], or [a compiler object].

Returns a [@runresult] object containing the result of the invocation. The command is run from an unspecified directory, and Meson will set three environment variables MESON_SOURCE_ROOT, MESON_BUILD_ROOT and MESON_SUBDIR that specify the source directory, build directory and subdirectory the target was defined in, respectively.

See also [External commands].

POSARGS

0 glob[compiler|external_program|file|python_installation|str]

The command to execute during the setup process.

KWARGS
capture bool

If true, any output generated on stdout will be captured and returned by the .stdout() method. If it is false, then .stdout() will return an empty string.

check bool

If true, the exit status code of the command will be checked, and the configuration will fail if it is non-zero. Note that the default value will be true in future releases.

console bool

stdout and stderr are written to console as it is generated by the command. Meant for commands that are resource-intensive and take a long time to finish.

env dict[listify[str]]|env|listify[str]

environment variables to set, such as ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling. (Since 0.52.0) A dictionary is also accepted.

feed both_libs|build_tgt|custom_tgt|file|str

Specify a file to be used for stdin

SYNOPSIS
run_target(
str,
command listify[exe]:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
env dict[listify[str]]|env|listify[str]:,
) -> custom_tgt

DESCRIPTION

This function creates a new top-level target that runs a specified command with the specified arguments. Like all top-level targets, this integrates with the selected backend. For instance, you can run it as meson compile target_name. Note that a run target produces no output as far as Meson is concerned. It is only meant for tasks such as running a code formatter or flashing an external device's firmware with a built file.

The command is run from an unspecified directory, and Meson will set three environment variables MESON_SOURCE_ROOT, MESON_BUILD_ROOT and MESON_SUBDIR that specify the source directory, build directory and subdirectory the target was defined in, respectively.

Since 0.57.0 The template strings passed to command keyword arguments accept the following special substitutions: - @SOURCE_ROOT@: the path to the root of the source tree. Depending on the backend, this may be an absolute or a relative to current workdir path. - @BUILD_ROOT@: the path to the root of the build tree. Depending on the backend, this may be an absolute or a relative to current workdir path. - @CURRENT_SOURCE_DIR@ Since 0.57.1: this is the directory where the currently processed meson.build is located in. Depending on the backend, this may be an absolute or a relative to current workdir path.

POSARGS

0 str

The name of the run target

KWARGS
command listify[exe]

An array containing the command to run and the arguments to pass to it. Each array element may be a string or a target. For instance, passing the return value of [executable] as the first item will run that executable, or passing a string as the first item will find that command in PATH and run it.

depends listify[both_libs|build_tgt|custom_tgt|file]

An array of targets that this target depends on but which are not listed in the command array (because, for example, the script does file globbing internally, customidx was not possible as a type between 0.60 and 1.4.0).

env dict[listify[str]]|env|listify[str]

environment variables to set, such as {'NAME1': 'value1', 'NAME2': 'value2'} or ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling.

SYNOPSIS
set_variable(
str,
any,
)

DESCRIPTION

Assigns a value to the given variable name. Calling set_variable('foo', bar) is equivalent to foo = bar.

(since 0.46.1) The value parameter can be an array type.

POSARGS

0 str

The name of the variable to set

1 any

The value to set the variable to

SYNOPSIS
shared_library(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> build_tgt

DESCRIPTION

Builds a shared library with the given sources.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

(Since 1.3.0) [@customidx] are supported

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
shared_module(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> build_tgt

DESCRIPTION

Builds a shared module with the given sources.

This is useful for building modules that will be dlopen()ed and hence may contain undefined symbols that will be provided by the library that is loading it.

If you want the shared module to be able to refer to functions and variables defined in the [executable] it is loaded by, you will need to set the export_dynamic argument of the executable to true.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

(Since 1.3.0) [@customidx] are supported

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
static_library(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
name_prefix list|str:,
name_suffix list|str:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> build_tgt

DESCRIPTION

Builds a static library with the given sources.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

The name for this build target, followed by an optional list of sources.

KWARGS
android_exe_type str

Specifies the intended target of the executable. This can either be executable, if the intended usecase is to run the executable using fork + exec, or application if the executable is supposed to be loaded as shared object by the android runtime.

<lang>_args listify[str]

compiler flags to use for the given language; eg: cpp_args for C++

<lang>_pch build_tgt|file|list|str

precompiled header file to use for the given language

<lang>_shared_args listify[str]

Arguments that are only passed to a shared library

<lang>_static_args listify[str]

Arguments that are only passed to a static library

build_by_default bool

Causes, when set to true, to have this target be built by default. This means it will be built when meson compile is called without any arguments. The default value is true for all built target types.

build_rpath str

A string to add to target's rpath definition in the build dir, but which will be removed on install

build_subdir str

Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses installdir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique buildsubdir values for each one. To prevent collisions within the build directory, buildsubdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory.

darwin_versions listify[int|str]

Defines the compatibility version and current version for the dylib on macOS. If an array is specified, it must be either zero, one, or two elements. If only one element is specified or if it's not an array the specified value will be used for setting both compatibility version and current version. If unspecified, the soversion will be used as per the aforementioned rules.

dependencies listify[dep]

one or more dependency objects created with [dependency] or [compiler.findlibrary] (for external deps) or [declaredependency] (for deps built by the project)

export_dynamic bool

when set to true causes the target's symbols to be dynamically exported, allowing modules built using the [sharedmodule] function to refer to functions, variables and other symbols defined in the executable itself.

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

Not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio).

These may only be static sources.

gnu_symbol_visibility str

Specifies how symbols should be exported, see e.g [the GCC Wiki] for more information. This value can either be an empty string or one of default, internal, hidden, protected or inlineshidden, which is the same as hidden but also includes things like C++ implicit constructors as specified in the GCC manual. Ignored on compilers that do not support GNU visibility arguments. See also [snippets.symbol_visibility_header()] method to help with defining public API.

gui_app bool

When set to true flags this target as a GUI application on platforms where this makes a difference, deprecated since 0.56.0, use win_subsystem instead.

implib bool|str

When set to a string, that will be the name of a generated import library.

Since 1.10.0 passing a boolean value is deprecated.

When set to true, an import library is generated for the executable (the name of the import library is based on exename). Alternatively, when set to a string, that gives the base name for the import library. The import library is used when the returned build target object appears in link_with: elsewhere. Only has any effect on platforms where that is meaningful (e.g. Windows). Implies the export_dynamic argument.

implicit_include_directories bool

Controls whether Meson adds the current source and build directories to the include path

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

install bool

When set to true, all outputs of this buildtarget will be installed.

install_dir str

override install directory for outputs of this build target. If the value is a relative path, it will be considered relative the prefix option. For example, if you want to install plugins into a subdir, you'd use something like this: install_dir : get_option('libdir') / 'projectname-1.0'.

This can be set to an array of values to control the the installation path of build targets with multiple outputs. Currently, that means Vala. Setting them to true means "use the default", and false means, don't install. By default the first element is true, and all other elements are false.

Since 1.11.0 Passing an array is deprecated, and installvalaheader, installvalavapi, and installvalagir keyword arguments should be used instead.

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_rpath str

A string to set the target's rpath to after install (but not before that). On Windows, this argument has no effect.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default all build targets have the tag runtime except for static libraries that have the devel tag.

install_vala_gir bool|str

If set to a string value, the vala generated gir library will be installed to that path, if set to true, the default gir path will be used, if false the gir library will not be installed.

It is an error for this to be either true or a string and vala_gir to be unset.

The default value is false.

install_vala_header bool|str

If set to a string value, the vala generated header will be installed to that path, if set to true, the default include path will be used, if false the header will not be installed.

The default value is false.

install_vala_vapi bool|str

If set to a string value, the vala generated vapi library will be installed to that path, if set to true, the default vapi path will be used, if false the vapi library will not be installed.

The default value is false.

link_args listify[str]

Flags to use during linking. You can use UNIX-style flags here for all platforms.

link_depends listify[build_tgt|custom_tgt|file|str]

Strings, files, or custom targets the link step depends on such as a symbol visibility map. The purpose is to automatically trigger a re-link (but not a re-compile) of the target when this file changes.

link_early_args listify[str]

Flags to use during linking. These are just like linkargs, except that they are inserted into the linker command line before any object files or libraries. You can use UNIX-style flags here for all platforms. This is only supported when using the Ninja backend.

link_language str

Makes the linker for this target be for the specified language. It is generally unnecessary to set this, as Meson will detect the right linker to use in most cases. There are only two cases where this is needed. One, your main function in an executable is not in the language Meson picked, or second you want to force a library to use only one ABI.

(broken until 0.55.0)

link_whole listify[both_libs|build_tgt|custom_tgt|file]

Links all contents of the given static libraries whether they are used or not, equivalent to the -Wl,--whole-archive argument flag of GCC, or the '/WHOLEARCHIVE' MSVC linker option. This allows the linked target to re-export symbols from all objects in the static libraries.

(since 0.41.0) If passed an array that array will be flattened.

(since 0.51.0) This argument also accepts outputs produced by custom targets. The user must ensure that the output is a library in the correct format.

link_with listify[both_libs|build_tgt|custom_tgt|file]

One or more shared or static libraries (built by this project) that this target should be linked with. (since 0.41.0) If passed an array that array will be flattened. (since 0.51.0) The arguments can also be custom targets. In this case Meson will assume that merely adding the output file in the linker command line is sufficient to make linking work. If this is not sufficient, then the build system writer must write all other steps manually.

name_prefix list|str

The string that will be used as the prefix for the target output filename by overriding the default (only used for libraries). By default this is lib on all platforms and compilers, except for MSVC shared libraries where it is omitted to follow convention, and Cygwin shared libraries where it is cyg.

Set this to [], or omit the keyword argument for the default behaviour.

name_suffix list|str

The string that will be used as the extension for the target by overriding the default. By default on Windows this is exe for executables and on other platforms it is omitted.

For shared libraries, the default value is dylib on macOS, dll on Windows, and so everywhere else. For static libraries, it is a everywhere. By convention MSVC static libraries use the lib suffix, but we use a to avoid a potential name clash with shared libraries which also generate import libraries with a lib suffix.

Set this to [], or omit the keyword argument for the default behaviour.

native bool

Controls whether the target is compiled for the build or host machines.

objects listify[file|str]

List of object files that should be linked in this target.

Since 1.1.0 this can include generated files in addition to object files that you don't have source to or that object files produced by other build targets. In earlier release, generated object files had to be placed in sources.

override_options dict[bool|int|list|str]|list[str]|str

takes an array of strings in the same format as project's default_options overriding the values of these options for this target only. (since 1.2.0): A dictionary may now be passed.

pic bool

Builds the library as positional independent code (so it can be linked into a shared library). This option has no effect on Windows and OS X since it doesn't make sense on Windows and PIC cannot be disabled on OS X.

pie bool

Build a position-independent executable.

shortname str

A string specifying a DLL name fitting to 8.3 limit on OS/2 of this shared library.

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

Additional source files. Same as the source varargs.

soversion int|str

A string or integer specifying the soversion of this shared library, such as 0. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if soversion is 4, a Windows DLL will be called foo-4.dll and one of the aliases of the Linux shared library would be libfoo.so.4. If this is not specified, the first part of version is used instead (see below). For example, if version is 3.6.0 and soversion is not defined, it is set to 3.

target_type str

The actual target type to build

version str

A string specifying the version of this shared library, such as 1.1.0. On Linux and OS X, this is used to set the shared library version in the filename, such as libfoo.so.1.1.0 and libfoo.1.1.0.dylib. If this is not specified, soversion is used instead (see above).

vs_module_defs custom_tgt|file|str

Specify a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).

This can be used to expose which functions a sharedmodule loaded by an executable will be allowed to use.

win_subsystem str

Specifies the subsystem type to use on the Windows platform. Typical values include console for text mode programs and windows for gui apps. The value can also contain version specification such as windows,6.0. See [MSDN documentation] for the full list.

SYNOPSIS
subdir(
str,
if_found listify[dep]:,
)

DESCRIPTION

Enters the specified subdirectory and executes the meson.build file in it. Once that is done, it returns and execution continues on the line following this subdir() command. Variables defined in that meson.build file are then available for use in later parts of the current build file and in all subsequent build files executed with subdir().

Note that this means that each meson.build file in a source tree can and must only be executed once.

POSARGS

0 str

Directory relative to the current meson.build to enter.

Cannot contain ..

KWARGS
if_found listify[dep]

Only enter the subdir if all [dep.found] methods return true.

SYNOPSIS
subdir_done(
)

DESCRIPTION

Stops further interpretation of the Meson script file from the point of the invocation. All steps executed up to this point are valid and will be executed by Meson. This means that all targets defined before the call of [subdirdone] will be built.

If the current script was called by subdir, the execution returns to the calling directory and continues as if the script had reached the end. If the current script is the top level script, Meson configures the project as defined up to this point.

SYNOPSIS
subproject(
str,
default_options dict[bool|int|list|str]|list[str]|str:,
required bool|feature:,
version listify[str]:,
) -> subproject

DESCRIPTION

Takes the project specified in the positional argument and brings that in the current build specification by returning a [@subproject] object. Subprojects must always be placed inside the subprojects directory at the top source directory. So for example a subproject called foo must be located in ${MESON_SOURCE_ROOT}/subprojects/foo.

  • default_options (since 0.37.0): an array of default option values that override those set in the subproject's meson.options (like default_options in project, they only have effect when Meson is run for the first time, and command line arguments override any default options in build files). (since 0.54.0): default_library built-in option can also be overridden. (since 1.2.0): A dictionary may be passed instead of array.
  • version: works just like the same as in dependency. It specifies what version the subproject should be, as an example >=1.0.1
  • required (since 0.48.0): By default, required is true and Meson will abort if the subproject could not be setup. You can set this to false and then use the .found() method on the [@subproject] object. You may also pass the value of a [feature] option, same as [dependency].

Note that you can use the returned [@subproject] object to access any variable in the subproject. However, if you want to use a dependency object from inside a subproject, an easier way is to use the fallback: keyword argument to [dependency].

[See additional documentation].

POSARGS

0 str

Name of the subproject. The subproject must exist in the subprojects directory (or the directory specified in the subproject_dir of [project]) as a directory or wrap file.

KWARGS
default_options dict[bool|int|list|str]|list[str]|str

An array of default option values that override those set in the subproject's meson.options (like default_options in [project], they only have effect when Meson is run for the first time, and command line arguments override any default options in build files). (since 0.54.0): default_library built-in option can also be overridden. (since 1.2.0): A dictionary may now be passed.

required bool|feature

Works just the same as in [dependency].

version listify[str]

Works just like the same as in [dependency]. It specifies what version the subproject should be, as an example >=1.0.1.

SYNOPSIS
summary(
dict[bool|dep|external_program|feature|int|str|list[bool|dep|external_program|feature|int|str]]|str,
bool|dep|external_program|feature|int|str|list[bool|dep|external_program|feature|int|str],
bool_yn bool:,
list_sep str:,
section str:,
)

DESCRIPTION

This function is used to summarize build configuration at the end of the build process. This function provides a way for projects (and subprojects) to report this information in a clear way.

The content is a series of key/value pairs grouped into sections. If the section keyword argument is omitted, those key/value pairs are implicitly grouped into a section with no title. key/value pairs can optionally be grouped into a dictionary, but keep in mind that dictionaries do not guarantee ordering. key must be string, value can be:

  • an integer, boolean or string
  • since 0.57.0 an external program or a dependency
  • since 0.58.0 a feature option
  • an array of those.

Instead of calling summary as summary(key, value), it is also possible to directly pass a dictionary to the [summary] function, as seen in the example below.

summary() can be called multiple times as long as the same section/key pair doesn't appear twice. All sections will be collected and printed at the end of the configuration in the same order as they have been called.

POSARGS

0 dict[bool|dep|external_program|feature|int|str|list[bool|dep|external_program|feature|int|str]]|str

The name of the new entry, or a dict containing multiple entries. If a dict is passed it is equivalent to calling summary() once for each key-value pair. Keep in mind that dictionaries do not guarantee ordering.

1 bool|dep|external_program|feature|int|str|list[bool|dep|external_program|feature|int|str]

The value to print for the key. Only valid if key_or_dict is a str.

KWARGS
bool_yn bool

Convert bool values to yes and no

list_sep str

The separator to use when printing array values in this summary. If no separator is given, each array item will be printed on its own line.

section str

The section to put this summary information under. If the section keyword argument is omitted, key/value pairs are implicitly grouped into a section with no title.

SYNOPSIS
test(
str,
build_tgt|custom_tgt|external_program|file|python_installation,
args listify[exe]:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
env dict[listify[str]]|env|listify[str]:,
expected_exitcode int:,
expected_fail bool:,
is_parallel bool:,
priority int:,
protocol str:,
should_fail bool:,
suite listify[str]:,
timeout int:,
verbose bool:,
workdir str:,
)

DESCRIPTION

Defines a test to run with the test harness. Takes two positional arguments, the first is the name of the test and the second is the executable to run. The executable can be an [@exe] object returned by [executable] or an [@program] object] returned by [findprogram].

(since 0.55.0) When cross compiling, if an exewrapper is needed and defined the environment variable MESON_EXE_WRAPPER will be set to the string value of that wrapper (implementation detail: using mesonlib.join_args). Test scripts may use this to run cross built binaries. If your test needs MESON_EXE_WRAPPER in cross build situations it is your responsibility to return code 77 to tell the harness to report "skip".

By default, environment variable [MALLOC_PERTURB_] is automatically set by meson test to a random value between 1..255. This can help find memory leaks on configurations using glibc, including with non-GCC compilers. However, this can have a performance impact, and may fail a test due to external libraries whose internals are out of the user's control. To check if this feature is causing an expected runtime crash, disable the feature by temporarily setting environment variable MALLOC_PERTURB_=0. While it's preferable to only temporarily disable this check, if a project requires permanent disabling of this check in meson.build do like:

nomalloc = environment({'MALLOC_PERTURB_': '0'})
test(..., env: nomalloc, ...)

By default, the environment variables ASAN_OPTIONS, UBSAN_OPTIONS, and MSAN_OPTIONS are set to enable aborting on detected violations and to give a backtrace. To suppress this, ASAN_OPTIONS, UBSAN_OPTIONS, or MSAN_OPTIONS can be set in the environment.

In addition to running individual executables as test cases, test() can also be used to invoke an external test harness. In this case, it is best to use verbose: true (since 0.62.0) and, if supported by the external harness, protocol: 'tap' (since 0.50.0). This will ensure that Meson logs each subtest as it runs, instead of including the whole log at the end of the run.

Defined tests can be run in a backend-agnostic way by calling meson test inside the build dir, or by using backend-specific commands, such as ninja test or msbuild RUN_TESTS.vcxproj.

POSARGS

0 str

The unique test id

1 build_tgt|custom_tgt|external_program|file|python_installation

The program to execute. (Since 1.4.0) A CustomTarget is also accepted.

KWARGS
args listify[exe]

Arguments to pass to the executable

depends listify[both_libs|build_tgt|custom_tgt|file]

specifies that this test depends on the specified target(s), even though it does not take any of them as a command line argument. This is meant for cases where test finds those targets internally, e.g. plugins or globbing. Those targets are built before test is executed even if they have build_by_default : false.

env dict[listify[str]]|env|listify[str]

environment variables to set, such as ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling. (Since 0.52.0) A dictionary is also accepted.

expected_exitcode int

the test is considered passed if the executable returns the specified returncode, only has effect when protocol is set to exitcode

expected_fail bool

when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error)

is_parallel bool

when false, specifies that no other test must be running at the same time as this test

priority int

specifies the priority of a test. Tests with a higher priority are started before tests with a lower priority. The starting order of tests with identical priorities is implementation-defined. The default priority is 0, negative numbers are permitted.

protocol str

specifies how the test results are parsed and can be one of exitcode, tap, or gtest. For more information about test harness protocol read [Unit Tests]. The following values are accepted:

  • exitcode: the executable's exit code is used by the test harness to record the outcome of the test).
  • tap: [Test Anything Protocol].
  • gtest (since 0.55.0): for Google Tests.
  • rust (since 0.56.0): for native rust tests

should_fail bool

when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error)

suite listify[str]

timeout int

the amount of seconds the test is allowed to run, a test that exceeds its time limit is always considered failed, defaults to 30 seconds. Since 0.57 if timeout is <= 0 the test has infinite duration, in previous versions of Meson the test would fail with a timeout immediately.

verbose bool

if true, forces the test results to be logged as if --verbose was passed to meson test.

workdir str

absolute path that will be used as the working directory for the test

SYNOPSIS
typeof(
any|null,
) -> str

POSARGS

0 any|null

SYNOPSIS
unset_variable(
str,
)

DESCRIPTION

Unsets a variable. Referencing a variable which has been unset is an error until it has been set again.

POSARGS

0 str

The variable to unset.

SYNOPSIS
vcs_tag(
command listify[exe]:,
fallback str:,
input listify[both_libs|build_tgt|custom_tgt|file|str]:,
install bool:,
install_dir listify[bool|str]:,
install_mode listify[bool|int|str]:,
install_tag str:,
output str:,
replace_string str:,
) -> custom_tgt

DESCRIPTION

This command detects revision control commit information at build time and places it in the specified output file. This file is guaranteed to be up to date on every build. Keywords are similar to [customtarget].

Meson will read the contents of input, substitute the replace_string with the detected revision number, and write the result to output. This method returns a [@customtgt] object that (as usual) should be used to signal dependencies if other targets use the file outputted by this.

For example, if you generate a header with this and want to use that in a build target, you must add the return value to the sources of that build target. Without that, Meson will not know the order in which to build the targets.

If you desire more specific behavior than what this command provides, you should use [customtarget].

KWARGS

command listify[exe]

The command to execute, see [customtarget] for details on how this command must be specified.

This parameter is optional. If it is absent, Meson will try its best to find a suitable default command.

(since 0.62.0) [@file] is accepted.

(since 0.63.0) [@customtgt], [@exe], and [@program] are accepted.

fallback str

Version number to use when no revision control information is present, such as when building from a release tarball.

input listify[both_libs|build_tgt|custom_tgt|file|str]

File to modify (e.g. version.c.in).

install bool

When true, this generated file is installed during the install step, and install_dir must be set and not empty.

install_dir listify[bool|str]

The subdirectory to install the generated file to (e.g. share/myproject).

install_mode listify[bool|int|str]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of [installdata] for more information.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default the file has no install tag which means it is not being installed when --tags argument is specified.

output str

File to write the results to (e.g. version.c).

replace_string str

String in the input file to substitute with the commit information.

SYNOPSIS
warning(
glob[bool|dict|feature|file|int|list|str],
)

DESCRIPTION

This function prints its argument to stdout prefixed with WARNING:.

POSARGS

0 glob[bool|dict|feature|file|int|list|str]

The message to print.

SYNOPSIS
to_int(
) -> int

DESCRIPTION

Returns 1 if true and 0 if false

SYNOPSIS
to_string(
str,
str,
) -> str

DESCRIPTION

Returns the string 'true' if the boolean is true or 'false' otherwise. You can also pass it two strings as positional arguments to specify what to return for true/false. For instance, bool.to_string('yes', 'no') will return yes if the boolean is true and no if it is false.

POSARGS

0 str

The string to return when the boolean is true

1 str

The string to return when the boolean is false

SYNOPSIS
extract_all_objects(
recursive bool:,
) -> list

KWARGS

recursive bool

SYNOPSIS
extract_objects(
glob[custom_tgt|file|generated_list|str],
) -> list

POSARGS

0 glob[custom_tgt|file|generated_list|str]

SYNOPSIS
found(
) -> bool

SYNOPSIS
full_path(
) -> str

SYNOPSIS
get_shared_lib(
) -> build_tgt

DESCRIPTION

Returns the stored shared library

SYNOPSIS
get_static_lib(
) -> build_tgt

DESCRIPTION

Returns the stored static library

SYNOPSIS
name(
) -> str

SYNOPSIS
path(
) -> str

SYNOPSIS
private_dir_include(
) -> str

SYNOPSIS
address_bits(
) -> int

SYNOPSIS
cpu(
) -> str

DESCRIPTION

Returns a more specific CPU name, such as i686, armv8l, etc.

SYNOPSIS
cpu_family(
) -> str

DESCRIPTION

Returns the CPU family name. [This table] contains all known CPU families. These are guaranteed to continue working.

SYNOPSIS
endian(
) -> str[big|little]

DESCRIPTION

Returns 'big' on big-endian systems and 'little' on little-endian systems.

SYNOPSIS
kernel(
) -> str

DESCRIPTION

Returns the name of the operating system kernel, such as linux, xnu, and nt. [See here for a more complete list]. These are more specific than system. If this cannot be detected (for the build machine), or is not set in the cross file (for the host machine when cross compiling), calling this method is fatal.

SYNOPSIS
set_properties(
dict,
)

POSARGS

0 dict

accepted properties: .nf

{ cpu?: str, cpu_family?: str, endian?: big|little, kernel?: str, system?: unknown|dragonfly|freebsd|gnu|haiku|linux|netbsd|openbsd|sunos|android|emscripten|windows|cygwin|msys2|darwin, subsystem?: unknown|dragonfly|freebsd|gnu|haiku|linux|netbsd|openbsd|sunos|android|emscripten|windows|cygwin|msys2|darwin|macos|ios|tvos|visionos }


str

SYNOPSIS
set_props(
dict,
)

POSARGS

0 dict

accepted properties: .nf

{ cpu?: str, cpu_family?: str, endian?: big|little, kernel?: str, system?: unknown|dragonfly|freebsd|gnu|haiku|linux|netbsd|openbsd|sunos|android|emscripten|windows|cygwin|msys2|darwin, subsystem?: unknown|dragonfly|freebsd|gnu|haiku|linux|netbsd|openbsd|sunos|android|emscripten|windows|cygwin|msys2|darwin|macos|ios|tvos|visionos }


setproperties

SYNOPSIS
subsystem(
) -> str[android|cygwin|darwin|dragonfly|emscripten|freebsd|gnu|haiku|ios|linux|macos|msys2|netbsd|openbsd|sunos|tvos|unknown|visionos|windows]

DESCRIPTION

Returns the variant of the operating system, such as ios and tvos. [See here for a more complete list]. These are more specific than system. If this cannot be detected (for the build machine), or is not set in the cross file (for the host machine when cross compiling), calling this method is fatal.

SYNOPSIS
system(
) -> str[android|cygwin|darwin|dragonfly|emscripten|freebsd|gnu|haiku|linux|msys2|netbsd|openbsd|sunos|unknown|windows]

DESCRIPTION

Returns the operating system name. [This table] lists all of the currently known operating system names. These are guaranteed to continue working.

SYNOPSIS
extract_all_objects(
recursive bool:,
) -> list

DESCRIPTION

Acts the same as extract_objects, but returns all object files generated by this target.

By default only objects built for this target are returned to maintain backward compatibility with previous versions. The default value for the recursive kwarg will eventually be changed to true in a future version.

KWARGS

recursive bool

Also return objects passed to the objects argument of this target.

SYNOPSIS
extract_objects(
glob[custom_tgt|file|generated_list|str],
) -> list

DESCRIPTION

Returns an opaque value representing the object files generated for those source files. This is typically used to take single object files and link them to unit tests or to compile some source files with custom flags. To use the object file(s) in another build target, use the objects: keyword argument to a [buildtarget] or [declaredependency], or include them in the command line of a [customtarget].

POSARGS

0 glob[custom_tgt|file|generated_list|str]

Source filenames for which the built objects should be extracted.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Always returns true. This function is meant to make executables objects feature compatible with [@program] objects. This simplifies use-cases where an executable is used instead of an [@program].

SYNOPSIS
full_path(
) -> str

DESCRIPTION

Returns a full path pointing to the result target file. NOTE: In most cases using the object itself will do the same job as this and will also allow Meson to setup inter-target dependencies correctly. Please file a bug if that doesn't work for you.

SYNOPSIS
name(
) -> str

DESCRIPTION

Returns the name of the target.

SYNOPSIS
path(
) -> str

DESCRIPTION

Does the exact same as [buildtgt.fullpath]. NOTE: This function is solely kept for compatibility with [@program] objects. It will be removed once the, also deprecated, corresponding path() function in the [@program] object is removed.

SYNOPSIS
private_dir_include(
) -> str

DESCRIPTION

Returns a value that works like [includedirectories], but points to the private directory of this target. Usually only needed if an another target needs to access some generated internal headers of this target.

SYNOPSIS
get(
str,
any,
) -> any

DESCRIPTION

Returns the value of varname, if the value has not been set returns default_value if it is defined (since 0.38.0) and errors out if not

POSARGS

0 str

The name of the variable to query

1 any

The default value to return when varname does not exist

SYNOPSIS
get_unquoted(
str,
any,
) -> any

DESCRIPTION

Returns the value of varname but without surrounding double quotes ("). If the value has not been set returns default_value if it is defined and errors out if not.

POSARGS

0 str

The name of the variable to query

1 any

The default value to return when varname does not exist

SYNOPSIS
has(
str,
) -> bool

DESCRIPTION

returns true if the specified variable is set

POSARGS

0 str

The name of the variable to query

SYNOPSIS
keys(
) -> list

DESCRIPTION

Returns an array of keys of the configuration data object.

You can iterate over this array with the [foreach statement].

SYNOPSIS
merge_from(
cfg_data,
)

DESCRIPTION

Takes as argument a different configuration data object and copies all entries from that object to the current.

POSARGS

0 cfg_data

The other [@cfgdata] object to merge into this one.

SYNOPSIS
set(
str,
bool|int|str,
description str:,
)

DESCRIPTION

Sets a variable to a given value

POSARGS

0 str

The name of the variable to set

1 bool|int|str

The value to set

KWARGS
description str

Message / Comment that will be written in the result file. The replacement assumes a file with C syntax. If your generated file is source code in some other language, you probably don't want to add a description field because it most likely will cause a syntax error.

SYNOPSIS
set10(
str,
bool,
description str:,
)

DESCRIPTION

Is the same as [cfgdata.set] but the value is either true or false and will be written as 1 or 0, respectively

POSARGS

0 str

The name of the variable to set

1 bool

The value to set as either 1 or 0

Passing numbers was never intended to work, and since 0.62 it has been deprecated. It will be removed in a future version of Meson. If you need to pass numbers use the .set method.

KWARGS
description str

Message / Comment that will be written in the result file. The replacement assumes a file with C syntax. If your generated file is source code in some other language, you probably don't want to add a description field because it most likely will cause a syntax error.

SYNOPSIS
set_quoted(
str,
str,
description str:,
)

DESCRIPTION

Is same as [cfgdata.set] but quotes the value in double quotes (")

POSARGS

0 str

The name of the variable to set

1 str

The value to set

KWARGS
description str

Message / Comment that will be written in the result file. The replacement assumes a file with C syntax. If your generated file is source code in some other language, you probably don't want to add a description field because it most likely will cause a syntax error.

SYNOPSIS
alignment(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> int

DESCRIPTION

Returns the alignment of the specified type. For C-like languages, For C-like languages, the header stddef.h and stdio.h are included implicitly for native compilation, only stddef.h is included when cross-compiling.

POSARGS

0 str

The name of the type to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

one or more objects created with the [includedirectories] function, or (since 0.50.0) strings, which will be transparently expanded to include directory objects

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

werror bool

SYNOPSIS
check_header(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the specified header is usable with the specified prefix, dependencies, and arguments.

POSARGS

0 str

The header to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the header check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
cmd_array(
) -> list

DESCRIPTION

Returns an array containing the command(s) for the compiler.

SYNOPSIS
compiles(
file|str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the code compiles.

POSARGS

0 file|str

The source code to check.

If a string is passed, the code is used directly. If a [@file] object is passed, its content is used for the compiler check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check.

prefix listify[str]

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

When set to true, compiler warnings are treated as error.

SYNOPSIS
compute_int(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> int

DESCRIPTION

Computes the value of the given expression (as an example 1 + 2). When cross compiling this is evaluated with an iterative algorithm, you can specify keyword arguments low (defaults to -1024), high (defaults to 1024) and guess to specify max and min values for the search and the value to try first. For C-like languages, the header stddef.h and stdio.h are included implicitly for native compilation, only stddef.h is included when cross-compiling.

POSARGS

0 str

The expression to compute.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

The value to try first.

high int

The max value.

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

The min value.

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

werror bool

SYNOPSIS
configure(
str[archiver|compiler|linker],
cmd_array listify[str]:,
handlers dict[bool|function|list[str]]:,
libdirs listify[str]:,
overwrite bool:,
version str:,
)

POSARGS

0 str[archiver|compiler|linker]

KWARGS
cmd_array listify[str]

handlers dict[bool|function|list[str]]

libdirs listify[str]

overwrite bool

version str

SYNOPSIS
find_library(
str,
dirs listify[str]:,
disabler bool:,
has_headers listify[str]:,
header_args listify[str]:,
header_dependencies listify[dep]:,
header_include_directories listify[inc|str]:,
header_no_builtin_args null:,
header_prefix null:,
header_required bool:,
required bool|feature:,
static bool:,
) -> dep

DESCRIPTION

Tries to find the library specified in the positional argument.

POSARGS

0 str

The library to find.

KWARGS
dirs listify[str]

Additional directories to search in.

By default the library is searched for in the system library directory (e.g. /usr/lib). Specifying more directories here, causes Meson to search in those directories as well as the system directories.

disabler bool

If true, this method will return a [@disabler] on a failed check.

has_headers listify[str]

An array of headers that must be found as well. This check is equivalent to checking each header with a [compiler.hasheader] call.

When used, kwargs that [compiler.hasheader] would accept can be passed here prefixed with header_, and will have the same effect on the header check.

header_args listify[str]

When the has_headers kwarg is also used, this argument is passed to [compiler.hasheader] as args.

header_dependencies listify[dep]

When the has_headers kwarg is also used, this argument is passed to [compiler.hasheader] as dependencies.

header_include_directories listify[inc|str]

When the has_headers kwarg is also used, this argument is passed to [compiler.hasheader] as include_directories. (Since 1.10.0) Strings are also accepted.

header_no_builtin_args null

When the has_headers kwarg is also used, this argument is passed to [compiler.hasheader] as no_builtin_args.

header_prefix null

When the has_headers kwarg is also used, this argument is passed to [compiler.hasheader] as prefix.

header_required bool

When used in conjunction with the hasheaders keyword, set the requirement of the headers.

required bool|feature

If set true, Meson will abort with an error if the library could not be found. Otherwise, Meson will continue and the found method of the returned object will return false.

When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

(since 0.47.0) The value of a feature option can also be passed here.

static bool

If true, the search is limited to static libraries only. Setting this value to false (the default) will search for both shared and static libraries.

SYNOPSIS
first_supported_argument(
glob[str],
) -> list

DESCRIPTION

Given an array of strings, returns a single-element array containing the first argument that passes the [compiler.hasargument] test or an empty array if none pass.

POSARGS

0 glob[str]

The arguments to check.

SYNOPSIS
first_supported_link_argument(
glob[str],
) -> list

DESCRIPTION

Given an array of strings, returns the first argument that passes the [compiler.haslinkargument] test or an empty array if none pass.

POSARGS

0 glob[str]

The link arguments to check.

SYNOPSIS
get_argument_syntax(
) -> str

DESCRIPTION

returns a string identifying the type of arguments the compiler takes. Can be one of gcc, msvc, or an undefined string value. This method is useful for identifying compilers that are not gcc or msvc, but use the same argument syntax as one of those two compilers such as clang or icc, especially when they use different syntax on different operating systems.

SYNOPSIS
get_define(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> str

DESCRIPTION

Returns the given preprocessor symbol's value as a string or empty string if it is not defined.

(since 0.47.0) This method will concatenate string literals as the compiler would. E.g. "a" "b" will become "ab".

POSARGS

0 str

The define to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

werror bool

SYNOPSIS
get_id(
) -> str

DESCRIPTION

Returns a string identifying the compiler. For example, gcc, msvc, [and more].

SYNOPSIS
get_internal_archiver_id(
) -> str

SYNOPSIS
get_internal_id(
) -> str

SYNOPSIS
get_internal_linker_id(
) -> str

SYNOPSIS
get_linker_id(
) -> str

DESCRIPTION

Returns a string identifying the linker. For example, ld.bfd, link, [and more].

SYNOPSIS
get_supported_arguments(
glob[str],
) -> list

DESCRIPTION

Returns an array containing only the arguments supported by the compiler, as if [compiler.hasargument] were called on them individually.

POSARGS

0 glob[str]

The arguments to check.

SYNOPSIS
get_supported_function_attributes(
glob[str],
) -> list

DESCRIPTION

Returns an array containing any names that are supported GCC style attributes. Equivalent to [compiler.hasfunctionattribute] was called on each of them individually.

POSARGS

0 glob[str]

SYNOPSIS
get_supported_link_arguments(
glob[str],
) -> list

DESCRIPTION

Returns an array containing only the arguments supported by the compiler, as if [compiler.haslinkargument] were called on them individually.

POSARGS

0 glob[str]

The link arguments to check.

SYNOPSIS
has_argument(
str,
required bool|feature:,
) -> bool

DESCRIPTION

Returns true if the compiler accepts the specified command line argument, that is, can compile code without erroring out or printing a warning about an unknown flag.

POSARGS

0 str

The argument to check.

KWARGS
required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
has_define(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the given preprocessor symbol is defined.

POSARGS

0 str

The define to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

werror bool

SYNOPSIS
has_function(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the given function is provided by the standard library or a library passed in with the args keyword.

POSARGS

0 str

The function to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
has_function_attribute(
str,
required bool|feature:,
) -> bool

DESCRIPTION

Returns true if the compiler supports the GNU style (__attribute__(...)) name. This is preferable to manual compile checks as it may be optimized for compilers that do not support such attributes. [This table] lists all of the supported attributes.

POSARGS

0 str

The attribute name to check.

KWARGS
required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
has_header(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the specified header is exists with the specified prefix, dependencies, and arguments.

This method is faster than [compiler.checkheader] since it only does a pre-processor check.

POSARGS

0 str

The header to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the header check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
has_header_symbol(
str,
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Detects whether a particular symbol is declared in the specified header.

Symbols here include function, variable, #define, type definition, etc.

POSARGS

0 str

The header to check.

1 str

The symbol to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the header check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
has_link_argument(
str,
required bool|feature:,
) -> bool

DESCRIPTION

Returns true if the linker accepts the specified command line argument, that is, can compile and link code without erroring out or printing a warning about an unknown flag. Link arguments will be passed to the compiler, so should usually have the -Wl, prefix. On VisualStudio a /link argument will be prepended.

POSARGS

0 str

The argument to check.

KWARGS
required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
has_member(
str,
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the type has the specified member.

POSARGS

0 str

The type to check.

1 str

The member to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
has_members(
str,
glob[str],
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the type has all the specified members.

POSARGS

0 str

The type to check.

1 glob[str]

The members to check

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
has_multi_arguments(
glob[str],
required bool|feature:,
) -> bool

DESCRIPTION

the same as [compiler.hasargument] but takes multiple arguments and uses them all in a single compiler invocation.

POSARGS

0 glob[str]

The arguments to check.

KWARGS
required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
has_multi_link_arguments(
glob[str],
required bool|feature:,
) -> bool

DESCRIPTION

the same as [compiler.haslinkargument] but takes multiple arguments and uses them all in a single compiler invocation.

POSARGS

0 glob[str]

The link arguments to check.

KWARGS
required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

SYNOPSIS
has_type(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the specified token is a type.

POSARGS

0 str

The type to check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

SYNOPSIS
links(
file|str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> bool

DESCRIPTION

Returns true if the code compiles and links.

Since 0.60.0, if the file object's suffix does not match the compiler object's language, the compiler corresponding to the suffix is used to compile the source, while the target of the links method is used to link the resulting object file.

POSARGS

0 file|str

The source code to check.

If a string is passed, the code is used directly. If a [@file] object is passed, its content is used for the compiler check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check.

prefix listify[str]

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

When set to true, compiler warnings are treated as error.

SYNOPSIS
machine(
) -> build_machine

SYNOPSIS
preprocess(
glob[custom_tgt|file|generated_list|str],
compile_args listify[str]:,
dependencies listify[dep]:,
depends listify[both_libs|build_tgt|custom_tgt|file]:,
include_directories listify[inc|str]:,
output str:,
) -> list

DESCRIPTION

Preprocess an array of source files but do not compile them. The preprocessor will receive the same arguments (include directories, defines, etc) as with normal compilation. That includes for example args added with add_project_arguments(), or on the command line with -Dc_args=-DFOO.

POSARGS

0 glob[custom_tgt|file|generated_list|str]

Input source to preprocess. The following types are supported:

  • Strings relative to the current source directory
  • [@file] objects defined in any preceding build file
  • The return value of configure-time generators such as [configurefile]
  • The return value of build-time generators such as [customtarget] or [generator.process]

KWARGS
compile_args listify[str]

Extra flags to pass to the preprocessor

dependencies listify[dep]

Additionally dependencies required.

depends listify[both_libs|build_tgt|custom_tgt|file]

Specifies that this target depends on the specified target(s). These targets should be built before starting to preprocess an input.

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

output str

Template for name of preprocessed files: @PLAINNAME@ is replaced by the source filename and @BASENAME@ is replaced by the source filename without its extension.

SYNOPSIS
run(
file|str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> runresult

DESCRIPTION

Attempts to compile and execute the given code fragment.

POSARGS

0 file|str

The source code to check.

If a string is passed, the code is used directly. If a [@file] object is passed, its content is used for the compiler check.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

The name to use for printing a message about the compiler check. If this keyword argument is not passed, no message will be printed about the check.

prefix listify[str]

required bool|feature

When set to true, Meson will halt if the check fails. When set to a [feature] option, the feature will control if it is searched and whether to fail if not found.

werror bool

When set to true, compiler warnings are treated as error.

SYNOPSIS
sizeof(
str,
args listify[str]:,
dependencies listify[dep]:,
guess int:,
high int:,
include_directories listify[inc|str]:,
low int:,
name str:,
prefix listify[str]:,
required bool|feature:,
werror bool:,
) -> int

DESCRIPTION

returns the size of the given type (e.g. 'int') or -1 if the type is unknown. For C-like languages, the header stddef.h and stdio.h are included implicitly for native compilation, only stddef.h is included when cross-compiling.

POSARGS

0 str

The type to compute.

KWARGS
args listify[str]

Used to pass an array of compiler arguments. Defining include paths for headers not in the default include path via -Isome/path/to/header is generally supported, however, usually not recommended.

This is because include directories can also be specified via the include_directories or the dependency kwarg (if present). The same is also true for passing libraries to link with -lfoo.

dependencies listify[dep]

Additionally dependencies required for compiling and / or linking.

guess int

high int

include_directories listify[inc|str]

Extra directories for header searches, created with the [includedirectories] function. (Since 1.10.0) Strings are also accepted.

low int

name str

prefix listify[str]

Used to add #includes and other things that are required for the symbol to be declared. Since 1.0.0 an array is accepted too. When an array is passed, the items are concatenated together separated by a newline. System definitions should be passed via compiler args (eg: _GNU_SOURCE is often required for some symbols to be exposed on Linux, and it should be passed via args keyword argument).

required bool|feature

werror bool

SYNOPSIS
symbols_have_underscore_prefix(
) -> bool

DESCRIPTION

Returns true if the C symbol mangling is one underscore (_) prefixed to the symbol.

SYNOPSIS
target_triple(
) -> dict

SYNOPSIS
version(
) -> str

DESCRIPTION

Returns the compiler's version number as a string.

SYNOPSIS
version_raw(
) -> str

SYNOPSIS
full_path(
) -> str

DESCRIPTION

Returns a full path pointing to the result target file NOTE: In most cases using the object itself will do the same job as this and will also allow Meson to setup inter-target dependencies correctly. Please file a bug if that doesn't work for you. (since 0.54.0) It can be also called on indexes objects: custom_targets[i].full_path().

SYNOPSIS
to_list(
) -> list

DESCRIPTION

Returns an array of opaque objects that references this target, and can be used as a source in other targets. This can be used to iterate outputs with foreach loop.

SYNOPSIS
as_link_whole(
) -> dep

DESCRIPTION

Only dependencies created with [declaredependency], returns a copy of the dependency object with all linkwith arguments changed to linkwhole. This is useful for example for fallback dependency from a subproject built with default_library=static. Note that all link_with objects must be static libraries otherwise an error will be raised when trying to link_whole a shared library.

SYNOPSIS
as_shared(
recursive bool:,
) -> dep

DESCRIPTION

Only for dependencies created with [declaredependency], returns a copy of the dependency object that prefer the shared version of [bothlibraries].

KWARGS

recursive bool

If true, this is recursively applied to dependencies

SYNOPSIS
as_static(
recursive bool:,
) -> dep

DESCRIPTION

Only for dependencies created with [declaredependency], returns a copy of the dependency object that prefer the static version of [bothlibraries].

KWARGS

recursive bool

If true, this is recursively applied to dependencies

SYNOPSIS
as_system(
str,
) -> dep

DESCRIPTION

Returns a copy of the dependency object, which has changed the value of include_type to value. The value argument is optional and defaults to 'system'.

POSARGS

0 str

The new value. See [dependency] for supported values.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Returns whether the dependency was found.

SYNOPSIS
get_configtool_variable(
str,
) -> str

DESCRIPTION

Gets the command line argument from the config tool (with -- prepended), or, if invoked on a non config-tool dependency, error out.

POSARGS

0 str

Name of the variable to query

SYNOPSIS
get_pkgconfig_variable(
str,
default str:,
) -> str

DESCRIPTION

Gets the pkg-config variable specified, or, if invoked on a non pkg-config dependency, error out.

POSARGS

0 str

Name of the variable to query

KWARGS
default str

The value to return if the variable was not found. A warning is issued if the variable is not defined and this kwarg is not set.

SYNOPSIS
get_variable(
str,
default_value str:,
internal str:,
pkgconfig str:,
pkgconfig_define listify[str]:,
system str:,
) -> str

DESCRIPTION

A generic variable getter method, which replaces the get_*type*_variable methods. This allows one to get the variable from a dependency without knowing specifically how that dependency was found. If default_value is set and the value cannot be gotten from the object then default_value is returned, if it is not set then an error is raised.

POSARGS

0 str

This argument is used as a default value for cmake, pkgconfig, configtool, internal and system keyword arguments. It is useful in the common case where pkgconfig and internal use the same variable name, in which case it's easier to write dep.get_variable('foo') instead of dep.get_variable(pkgconfig: 'foo', internal: 'foo').

KWARGS
default_value str

The default value to return when the variable does not exist

internal str

The internal variable name

pkgconfig str

The pkgconfig variable name

pkgconfig_define listify[str]

See [dep.getpkgconfigvariable]

system str

The system variable name

SYNOPSIS
include_type(
) -> str

DESCRIPTION

Returns the value set by the include_type kwarg.

SYNOPSIS
name(
) -> str

DESCRIPTION

Returns the name of the dependency that was searched. Returns 'internal' for dependencies created with [declaredependency].

NOTE: This was not implemented for dep objects returned by [compiler.findlibrary] until Meson 1.5.0

SYNOPSIS
partial_dependency(
compile_args bool:,
includes bool:,
link_args bool:,
links bool:,
sources bool:,
) -> dep

DESCRIPTION

Returns a new dependency object with the same name, version, found status, type name, and methods as the object that called it. This new object will only inherit other attributes from its parent as controlled by keyword arguments.

If the parent has any dependencies, those will be applied to the new partial dependency with the same rules. So, given:

dep1 = declare_dependency(compile_args : '-Werror=foo', link_with : 'libfoo')
dep2 = declare_dependency(compile_args : '-Werror=bar', dependencies : dep1)
dep3 = dep2.partial_dependency(compile_args : true)

dep3 will add ['-Werror=foo', '-Werror=bar'] to the compiler args of any target it is added to, but libfoo will not be added to the linkargs.

The following arguments will add the following attributes:

  • compileargs: any arguments passed to the compiler
  • linkargs: any arguments passed to the linker
  • links: anything passed via linkwith or linkwhole
  • includes: any includedirectories
  • sources: any compiled or static sources the dependency has

KWARGS

compile_args bool

Whether to include compileargs

includes bool

Whether to include includes

link_args bool

Whether to include linkargs

links bool

Whether to include links

sources bool

Whether to include sources

SYNOPSIS
type_name(
) -> str

DESCRIPTION

Returns a string describing the type of the dependency, the most common values are internal for deps created with [declaredependency] and pkgconfig for system dependencies obtained with Pkg-config.

SYNOPSIS
version(
) -> str

DESCRIPTION

the version number as a string, for example 1.2.8. unknown if the dependency provider doesn't support determining the version.

SYNOPSIS
delete(
str,
)

DESCRIPTION

Delete a key from a dictionary. Note that this mutates the underlying dictionary and also may reorder its keys.

POSARGS

0 str

SYNOPSIS
get(
str,
any,
) -> any

DESCRIPTION

returns the value for the key given as first argument if it is present in the dictionary, or the optional fallback value given as the second argument. If a single argument was given and the key was not found, causes a fatal error

POSARGS

0 str

The key to query.

1 any

Fallback value that is returned if the key is not in the [@dict].

SYNOPSIS
has_key(
str,
) -> bool

DESCRIPTION

Returns true if the dictionary contains the key given as argument, false otherwise.

POSARGS

0 str

The key to query.

SYNOPSIS
keys(
) -> list

DESCRIPTION

Returns an array of keys in the dictionary, sorted in ascending order.

SYNOPSIS
set(
str,
any,
)

POSARGS

0 str

1 any

SYNOPSIS
values(
) -> list

DESCRIPTION

Returns an array of values in the dictionary, sorted by the corresponding keys in ascending order.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Always returns false

SYNOPSIS
append(
str,
glob[str],
separator str:,
)

DESCRIPTION

appends the given values to the old value of the environment variable, e.g. env.append('FOO', 'BAR', 'BAZ', separator : ';') produces BOB;BAR;BAZ if FOO had the value BOB and plain BAR;BAZ if the value was not defined.

POSARGS

0 str

The variable to modify

1 glob[str]

The values to append

KWARGS
separator str

The separator to use. If not explicitly specified, the default path separator for the host operating system will be used, i.e. ';' for Windows and ':' for UNIX/POSIX systems.

SYNOPSIS
prepend(
str,
glob[str],
separator str:,
)

DESCRIPTION

Same as append except that it writes to the beginning of the variable.

POSARGS

0 str

The variable to modify

1 glob[str]

The values to prepend

KWARGS
separator str

The separator to use. If not explicitly specified, the default path separator for the host operating system will be used, i.e. ';' for Windows and ':' for UNIX/POSIX systems.

SYNOPSIS
set(
str,
glob[str],
separator str:,
)

DESCRIPTION

Sets the environment variable specified in the first argument to the values in the varargs joined by the separator. For instance, env.set('FOO', 'BAR'), sets envvar FOO to value BAR.

POSARGS

0 str

The variable to modify

1 glob[str]

The values to set

KWARGS
separator str

The separator to use. If not explicitly specified, the default path separator for the host operating system will be used, i.e. ';' for Windows and ':' for UNIX/POSIX systems.

SYNOPSIS
unset(
str,
)

DESCRIPTION

Unset the specified environment variable. If this variable does not exist, nothing happens.

POSARGS

0 str

The name to unset

SYNOPSIS
cmd_array(
) -> list

DESCRIPTION

Returns an array containing the command(s) for the program.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Returns whether the executable was found.

SYNOPSIS
full_path(
) -> str

DESCRIPTION

Returns a string pointing to the script or executable.

NOTE: You should not usually need to use this method. Passing the object itself should work in most contexts where a program can appear, and allows Meson to setup inter-target dependencies correctly (for example in cases where a program might be overridden by a [@buildtgt]). Only use this if you specifically need a string, such as when embedding a program path into a header file, or storing it into an environment variable.

For example:

run_command(find_program('foo'), 'arg1', 'arg2')

str

SYNOPSIS
path(
) -> str

DESCRIPTION

Deprecated: Use [program.fullpath] instead.

Returns a string pointing to the script or executable.

NOTE: You should not usually need to use this method. Passing the object itself should work in most contexts where a program can appear, and allows Meson to setup inter-target dependencies correctly (for example in cases where a program might be overridden by a [@buildtgt]). Only use this if you specifically need a string, such as when embedding a program path into a header file, or storing it into an environment variable.

For example:

run_command(find_program('foo'), 'arg1', 'arg2')

list

SYNOPSIS
version(
) -> str

DESCRIPTION

The version number as a string, for example 1.2.8.

unknown if the program cannot determine the version via a --version argument.

SYNOPSIS
allowed(
) -> bool

DESCRIPTION

Returns whether the feature was set to 'enabled' or 'auto'

SYNOPSIS
auto(
) -> bool

DESCRIPTION

Returns whether the feature was set to 'auto'

SYNOPSIS
disable_auto_if(
bool,
) -> feature

DESCRIPTION

Returns the feature, with 'auto' converted to 'disabled' if value is true.

| Feature | value = true | value = false | | -------- | -------------- | --------------- | | Auto | Disabled | Auto | | Enabled | Enabled | Enabled | | Disabled | Disabled | Disabled |

POSARGS

0 bool

See the table above

SYNOPSIS
disable_if(
bool,
error_message str:,
) -> feature

DESCRIPTION

Returns the object itself if the value is false; an error if the object is 'enabled' and the value is true; a disabled feature if the object is 'auto' or 'disabled' and the value is true.

| Feature | value = true | value = false | | -------- | -------------- | --------------- | | Auto | Disabled | Auto | | Enabled | Error | Enabled | | Disabled | Disabled | Disabled |

This is equivalent to feature_opt.require(not condition), but may make code easier to reason about, especially when mixed with enable_if

POSARGS

0 bool

The value to check

KWARGS
error_message str

The error message to print if the check fails

SYNOPSIS
disabled(
) -> bool

DESCRIPTION

Returns whether the feature was set to 'disabled'

SYNOPSIS
enable_auto_if(
bool,
) -> feature

DESCRIPTION

Returns the feature, with 'auto' converted to 'enabled' if value is true.

| Feature | value = true | value = false | | -------- | -------------- | --------------- | | Auto | Enabled | Auto | | Enabled | Enabled | Enabled | | Disabled | Disabled | Disabled |

POSARGS

0 bool

See the table above

SYNOPSIS
enable_if(
bool,
error_message str:,
) -> feature

DESCRIPTION

Returns the object itself if the value is false; an error if the object is 'disabled' and the value is true; an enabled feature if the object is 'auto' or 'enabled' and the value is true.

| Feature | value = true | value = false | | -------- | -------------- | --------------- | | Auto | Enabled | Auto | | Enabled | Enabled | Enabled | | Disabled | Error | Disabled |

POSARGS

0 bool

The value to check

KWARGS
error_message str

The error message to print if the check fails

SYNOPSIS
enabled(
) -> bool

DESCRIPTION

Returns whether the feature was set to 'enabled'

SYNOPSIS
require(
bool,
error_message str:,
) -> feature

DESCRIPTION

Returns the object itself if the value is true; an error if the object is 'enabled' and the value is false; a disabled feature if the object is 'auto' or 'disabled' and the value is false.

| Feature | value = true | value = false | | -------- | -------------- | --------------- | | Auto | Auto | Disabled | | Enabled | Enabled | Error | | Disabled | Disabled | Disabled |

POSARGS

0 bool

The value to check

KWARGS
error_message str

The error message to print if the check fails

SYNOPSIS
full_path(
) -> str

DESCRIPTION

Returns a full path pointing to the file. This is useful for printing the path with e.g [message] function for debugging purpose. NOTE: In most cases using the object itself will do the same job as this and will also allow Meson to setup dependencies correctly.

SYNOPSIS
process(
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
env dict[listify[str]]|env|listify[str]:,
extra_args listify[str]:,
preserve_path_from str:,
) -> generated_list

DESCRIPTION

Takes an array of files, causes them to be processed and returns an object containing the result which can then, for example, be passed into a build target definition.

POSARGS

0 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

sources to process.

KWARGS
env dict[listify[str]]|env|listify[str]

environment variables to set, such as {'NAME1': 'value1', 'NAME2': 'value2'} or ['NAME1=value1', 'NAME2=value2'], or an [@env] object which allows more sophisticated environment juggling.

extra_args listify[str]

If present, will be used to replace an entry @EXTRA_ARGS@ in the argument array.

preserve_path_from str

If given, specifies that the output files need to maintain their directory structure inside the target temporary directory. The most common value for this is meson.current_source_dir(). With this value when a file called subdir/one.input is processed it generates a file {target private directory}/subdir/one.out as opposed to {target private directory}/one.out.

SYNOPSIS
full_path(
) -> str

SYNOPSIS
is_even(
) -> bool

DESCRIPTION

Returns true if the number is even.

SYNOPSIS
is_odd(
) -> bool

DESCRIPTION

Returns true if the number is odd

SYNOPSIS
to_string(
fill int:,
) -> str

DESCRIPTION

Returns the value of the number as a string.

KWARGS

fill int

SYNOPSIS
clear(
)

SYNOPSIS
contains(
any,
) -> bool

DESCRIPTION

Returns true if the array contains the object given as argument, false otherwise

POSARGS

0 any

The item to check

SYNOPSIS
dedup(
) -> list

SYNOPSIS
delete(
int,
)

POSARGS

0 int

SYNOPSIS
flatten(
) -> list

DESCRIPTION

Returns a flattened copy of the array, with all nested arrays removed.

SYNOPSIS
get(
int,
any,
) -> any

DESCRIPTION

returns the object at the given index, negative indices count from the back of the array, indexing out of bounds returns the fallback value (since 0.38.0) or, if it is not specified, causes a fatal error

POSARGS

0 int

Index of the array position to query. Negative values start at the end of the array

1 any

Fallback value that is returned if the index is out of range.

SYNOPSIS
length(
) -> int

DESCRIPTION

Returns the current size of the array.

SYNOPSIS
slice(
int,
int,
step int:,
) -> list

DESCRIPTION

Return a selection of the elements of the array starting at index start and continuing with step size jumps until stop. Negative indices count from the back of the array. The step size cannot be zero, but may be negative. If it is negative, start and stop default to the end and beginning of the array, respectively. If step is positive, start defaults to 0 and stop defaults to the length of the array. Either both or none of start and stop must be provided to prevent ambiguity.

POSARGS

0 int

The lower bound of the slice

1 int

The upper bound of the slice

KWARGS
step int

The step size

SYNOPSIS
add_devenv(
dict[listify[str]]|env|listify[str],
method str[append|prepend|set]:,
separator str:,
)

DESCRIPTION

add an [@env] object (returned by [environment]) to the list of environments that will be applied when using [meson devenv] command line.

This is useful for developers who wish to use the project without installing it, it is often needed to set for example the path to plugins directory, etc. Alternatively, a list or dictionary can be passed as first argument.

devenv = environment()
devenv.set('PLUGINS_PATH', meson.current_build_dir())
meson.add_devenv(devenv)

After configuring and compiling that project, a terminal can be opened with the environment set:

$ meson devenv -C <builddir>
$ echo $PLUGINS_PATH
/path/to/source/subdir

See [meson devenv] command documentation for a list of environment variables that are set by default by Meson.

POSARGS

0 dict[listify[str]]|env|listify[str]

The [@env] object to add. Since 0.62.0 array of strings is allowed in dictionary values. In that case values are joined using the separator.

KWARGS
method str[append|prepend|set]

Must be one of 'set', 'prepend', or 'append' (defaults to 'set'). Controls if initial values defined in the first positional argument are prepended, appended or replace the current value of the environment variable.

separator str

The separator to use for the initial values defined in the first positional argument. If not explicitly specified, the default path separator for the host operating system will be used, i.e. ';' for Windows and ':' for UNIX/POSIX systems.

SYNOPSIS
add_dist_script(
glob[exe],
)

DESCRIPTION

Causes the script given as argument to run during dist operation after the distribution source has been generated but before it is archived. Note that this runs the script file that is in the staging directory, not the one in the source directory. If the script file cannot be found in the staging directory, it is a hard error. The MESON_DIST_ROOT environment variables is set when dist scripts is run.

(since 0.54.0) The MESON_SOURCE_ROOT and MESON_BUILD_ROOT environment variables are set when dist scripts are run. They are path to the root source and build directory of the main project, even when the script comes from a subproject.

(since 0.58.0) This command can be invoked from a subproject, it was a hard error in earlier versions. Subproject dist scripts will only be executed when running meson dist --include-subprojects. MESON_PROJECT_SOURCE_ROOT, MESON_PROJECT_BUILD_ROOT and MESON_PROJECT_DIST_ROOT environment variables are set when dist scripts are run. They are identical to MESON_SOURCE_ROOT, MESON_BUILD_ROOT and MESON_DIST_ROOT for main project scripts, but for subproject scripts they have the path to the root of the subproject appended, usually subprojects/<subproject-name>.

(since 1.4.0) The MESONREWRITE environment variable contains the path to the rewrite command that corresponds to the meson executable that was used to configure the build. (This might be a different path than the first executable found in PATH.) It can be used to remove or replace any [runcommand] that depends on the revision control system from the build configuration. Note that the value will contain many parts. For example, it may be python3 /path/to/meson.py introspect. The user is responsible for splitting the string to an array if needed by splitting lexically like a UNIX shell would. If your script uses Python, shlex.split() is the easiest correct way to do this.

POSARGS

0 glob[exe]

The script to execute.

(since 0.55.0) The output of [findprogram] as well as strings are accepted.

(since 0.57.0) [@file] objects and the output of [configurefile] may be used.

SYNOPSIS
add_install_script(
glob[exe],
dry_run bool:,
install_tag str:,
skip_if_destdir bool:,
)

DESCRIPTION

Causes the script given as an argument to be run during the install step, this script will have the environment variables MESON_SOURCE_ROOT, MESON_BUILD_ROOT, MESON_INSTALL_PREFIX, MESON_INSTALL_DESTDIR_PREFIX, and MESONINTROSPECT set. All positional arguments are passed as parameters.

(since 0.54.0) If meson install is called with the --quiet option, the environment variable MESON_INSTALL_QUIET will be set.

(since 1.1.0) If meson install is called with the --dry-run option, the environment variable MESON_INSTALL_DRY_RUN will be set.

Meson uses the DESTDIR environment variable as set by the inherited environment to determine the (temporary) installation location for files. Your install script must be aware of this while manipulating and installing files. The correct way to handle this is with the MESON_INSTALL_DESTDIR_PREFIX variable which is always set and contains DESTDIR (if set) and prefix joined together. This is useful because both are usually absolute paths and there are platform-specific edge-cases in joining two absolute paths.

In case it is needed, MESON_INSTALL_PREFIX is also always set and has the value of the prefix option passed to Meson.

MESONINTROSPECT contains the path to the introspect command that corresponds to the meson executable that was used to configure the build. (This might be a different path than the first executable found in PATH.) It can be used to query build configuration. Note that the value will contain many parts, f.ex., it may be python3 /path/to/meson.py introspect. The user is responsible for splitting the string to an array if needed by splitting lexically like a UNIX shell would. If your script uses Python, shlex.split() is the easiest correct way to do this.

POSARGS

0 glob[exe]

The script to execute.

(since 0.55.0) The output of [findprogram], [executable], [customtarget], as well as strings are accepted.

(since 0.57.0) [@file] objects and the output of [configurefile] may be used.

KWARGS
dry_run bool

If true the script will be run even if --dry-run option is provided to the meson install command. The script can use the MESON_INSTALL_DRY_RUN variable to determine if it is in dry run mode or not.

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default the script has no install tag which means it is not being run when meson install --tags argument is specified.

skip_if_destdir bool

If true the script will not be run if DESTDIR is set during installation. This is useful in the case the script updates system wide cache that is only needed when copying files into final destination.

SYNOPSIS
add_postconf_script(
glob[exe],
)

DESCRIPTION

Runs the given command after all project files have been generated. This script will have the environment variables MESON_SOURCE_ROOT and MESON_BUILD_ROOT set.

POSARGS

0 glob[exe]

The script to execute.

(since 0.55.0) The output of [findprogram] as well as strings are accepted.

(since 0.57.0) [@file] objects and the output of [configurefile] may be used.

SYNOPSIS
argv0(
) -> str

DESCRIPTION

returns the argv[0] that was used to invoke muon itself

SYNOPSIS
backend(
) -> str

DESCRIPTION

Returns a string representing the current backend:

  • ninja
  • vs2010
  • vs2012
  • vs2013
  • vs2015
  • vs2017
  • vs2019
  • vs2022
  • xcode

SYNOPSIS
build_options(
) -> str

DESCRIPTION

Returns a string with the configuration line used to set the current project up.

SYNOPSIS
build_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the build root directory. This function will return the build root of the parent project if called from a subproject, which is usually not what you want. Try using [meson.currentbuilddir] or [meson.projectbuildroot]. In the rare cases where the root of the main project is needed, use [meson.globalbuildroot] that has the same behaviour but with a more explicit name.

SYNOPSIS
can_run_host_binaries(
) -> bool

DESCRIPTION

Returns true if the build machine can run binaries compiled for the host. This returns true unless you are cross compiling, need a helper to run host binaries, and don't have one. For example when cross compiling from Linux to Windows, one can use wine as the helper.

SYNOPSIS
current_build_dir(
) -> str

DESCRIPTION

Returns a string with the absolute path to the current build directory.

SYNOPSIS
current_source_dir(
) -> str

DESCRIPTION

Returns a string to the current source directory.

SYNOPSIS
export_module(
str,
module,
)

POSARGS

0 str

1 module

SYNOPSIS
get_compiler(
str,
native bool:,
) -> compiler

DESCRIPTION

Returns a [@compiler] object describing a compiler.

POSARGS

0 str

The language of the compiler to return.

See our [list of supported languages].

KWARGS
native bool

When set to true Meson returns the compiler for the build machine (the "native" compiler) and when false it returns the host compiler (the "cross" compiler). If native is omitted, Meson returns the "cross" compiler if we're currently cross-compiling and the "native" compiler if we're not.

SYNOPSIS
get_cross_property(
str,
any,
) -> any

DESCRIPTION

Returns the given property from a cross file, the optional fallbackvalue is returned if not cross compiling or the given property is not found.

This method is replaced by [meson.getexternalproperty].

POSARGS

0 str

Name of the property in the cross / native file.

1 any

Value to return if propname is not set in the machine file.

SYNOPSIS
get_external_property(
str,
any,
native bool:,
) -> any

DESCRIPTION

Returns the given property from a native or cross file. The optional fallbackvalue is returned if the given property is not found.

POSARGS

0 str

Name of the property in the cross / native file.

1 any

Value to return if propname is not set in the machine file.

KWARGS
native bool

Setting native to true forces retrieving a variable from the native file, even when cross-compiling. If native: false or not specified, the variable is retrieved from the cross-file if cross-compiling, and from the native-file when not cross-compiling.

SYNOPSIS
global_build_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the build root directory. This function will return the build root of the main project if called from a subproject, which is usually not what you want. It is usually preferable to use [meson.currentbuilddir] or [meson.projectbuildroot].

SYNOPSIS
global_source_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the source root directory. This function will return the source root of the main project if called from a subproject, which is usually not what you want. It is usually preferable to use [meson.currentsourcedir] or [meson.projectsourceroot].

SYNOPSIS
has_compiler(
str,
native bool:,
) -> bool

DESCRIPTION

returns whether or not a compiler for the given language has been configured

POSARGS

0 str

KWARGS
native bool

SYNOPSIS
has_exe_wrapper(
) -> bool

DESCRIPTION

Use [meson.canrunhostbinaries] instead.

SYNOPSIS
has_external_property(
str,
native bool:,
) -> any

DESCRIPTION

Checks whether the given property exist in a native or cross file.

POSARGS

0 str

Name of the property in the cross / native file.

KWARGS
native bool

Setting native to true forces retrieving a variable from the native file, even when cross-compiling. If native: false or not specified, the variable is retrieved from the cross-file if cross-compiling, and from the native-file when not cross-compiling.

SYNOPSIS
is_cross_build(
) -> bool

DESCRIPTION

Returns true if the current build is a [cross build] and false otherwise.

SYNOPSIS
is_subproject(
) -> bool

DESCRIPTION

Returns true if the current project is being built as a subproject of some other project and false otherwise.

SYNOPSIS
is_unity(
) -> bool

DESCRIPTION

Returns true when doing a [unity build] (multiple sources are combined before compilation to reduce build time) and false otherwise.

SYNOPSIS
override_dependency(
str,
dep,
native bool:,
static bool:,
)

DESCRIPTION

Specifies that whenever [dependency] with name is used, Meson should not look it up on the system but instead return dep_object, which may either be the result of [dependency] or [declaredependency].

Doing this in a subproject allows the parent project to retrieve the dependency without having to know the dependency variable name: dependency(name, fallback : subproject_name).

POSARGS

0 str

The name of the dependency to override.

1 dep

The dependency to set as the override for name.

KWARGS
native bool

If set to true, the dependency is always overwritten for the build machine. Otherwise, the dependency is overwritten for the host machine, which differs from the build machine when cross-compiling.

static bool

Used to override static and/or shared dependencies separately. If not specified it is assumed dep_object follows default_library option value.

SYNOPSIS
override_find_program(
str,
build_tgt|custom_tgt|external_program|file|python_installation|list[str],
native bool:,
)

DESCRIPTION

specifies that whenever [findprogram] is used to find a program named progname, Meson should not look it up on the system but instead return program, which may either be the result of [findprogram], [configurefile] or [executable].

(since 0.55.0) If a version check is passed to [findprogram] for a program that has been overridden with an executable, the current project version is used.

POSARGS

0 str

The name of the program to override.

1 build_tgt|custom_tgt|external_program|file|python_installation|list[str]

The program to set as the override for progname.

KWARGS
native bool

Controls whether the target is compiled for the build or host machines.

SYNOPSIS
private_dir(
) -> str

DESCRIPTION

returns the path to muon's private directory in the build folder

SYNOPSIS
project(
) -> dict

DESCRIPTION

return a dict containing read-only properties of the current project

SYNOPSIS
project_build_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the build root directory of the current (sub)project.

SYNOPSIS
project_license(
) -> list

DESCRIPTION

Returns the array of licenses specified in [project] function call.

SYNOPSIS
project_license_files(
) -> list

DESCRIPTION

Returns the array of license files specified in the [project] function call.

SYNOPSIS
project_name(
) -> str

DESCRIPTION

Returns the project name specified in the [project] function call.

SYNOPSIS
project_source_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the source root directory of the current (sub)project.

SYNOPSIS
project_version(
) -> str

DESCRIPTION

Returns the version string specified in [project] function call.

SYNOPSIS
register_dependency_handler(
str,
builtin function:,
config_tool function:,
order listify[str]:,
pkgconfig function:,
system function:,
)

DESCRIPTION

register custom callbacks to run when a specific dependency lookup is invoked

POSARGS

0 str

KWARGS
builtin function

config_tool function

order listify[str]

pkgconfig function

system function

SYNOPSIS
set_external_properties(
dict,
native bool:,
)

DESCRIPTION

set properties to be accessed by meson.getcrossproperty() and meson.getexternalproperty()

POSARGS

0 dict

KWARGS
native bool

SYNOPSIS
set_option(
str,
bool|feature|int|list|str,
native bool:,
)

DESCRIPTION

set the value of an option as if it were set on the commandline

POSARGS

0 str

1 bool|feature|int|list|str

KWARGS
native bool

SYNOPSIS
source_root(
) -> str

DESCRIPTION

Returns a string with the absolute path to the source root directory.

This function will return the source root of the parent project if called from a subproject, which is usually not what you want. Try using [meson.currentsourcedir] or [meson.projectsourceroot]. In the rare cases where the root of the main project is needed, use [meson.globalsourceroot] that has the same behaviour but with a more explicit name.

SYNOPSIS
version(
) -> str

DESCRIPTION

Return a string with the version of Meson.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Returns true if the module was successfully imported, otherwise false.

SYNOPSIS
cmd_array(
) -> list

SYNOPSIS
dependency(
allow_fallback bool:,
components listify[str]:,
default_options dict[bool|int|list|str]|list[str]|str:,
disabler bool:,
embed bool:,
fallback listify[str]:,
include_type str:,
language str:,
main bool:,
method str:,
modules listify[str]:,
native bool:,
not_found_message str:,
optional_modules listify[str]:,
required bool|feature:,
static bool:,
version listify[str]:,
) -> dep

KWARGS

allow_fallback bool

components listify[str]

Ignored

default_options dict[bool|int|list|str]|list[str]|str

disabler bool

embed bool

fallback listify[str]

include_type str

language str

Ignored

main bool

Ignored

method str

modules listify[str]

A list of sub-dependencies for this dependency. Only supported by certain dependencies.

native bool

not_found_message str

optional_modules listify[str]

Ignored

required bool|feature

static bool

version listify[str]

SYNOPSIS
extension_module(
str,
glob[both_libs|build_tgt|custom_tgt|file|generated_list|str],
android_exe_type str:,
<lang>_args listify[str]:,
<lang>_pch build_tgt|file|list|str:,
<lang>_shared_args listify[str]:,
<lang>_static_args listify[str]:,
build_by_default bool:,
build_rpath str:,
build_subdir str:,
darwin_versions listify[int|str]:,
dependencies listify[dep]:,
export_dynamic bool:,
extra_files listify[both_libs|build_tgt|custom_tgt|file|str]:,
gnu_symbol_visibility str:,
gui_app bool:,
implib bool|str:,
implicit_include_directories bool:,
include_directories listify[inc|str]:,
install bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_rpath str:,
install_tag str:,
install_vala_gir bool|str:,
install_vala_header bool|str:,
install_vala_vapi bool|str:,
limited_api str:,
link_args listify[str]:,
link_depends listify[build_tgt|custom_tgt|file|str]:,
link_early_args listify[str]:,
link_language str:,
link_whole listify[both_libs|build_tgt|custom_tgt|file]:,
link_with listify[both_libs|build_tgt|custom_tgt|file]:,
native bool:,
objects listify[file|str]:,
override_options dict[bool|int|list|str]|list[str]|str:,
pic bool:,
pie bool:,
shortname str:,
sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]:,
soversion int|str:,
subdir str:,
target_type str:,
version str:,
vs_module_defs custom_tgt|file|str:,
win_subsystem str:,
) -> build_tgt

POSARGS

0 str

1 glob[both_libs|build_tgt|custom_tgt|file|generated_list|str]

KWARGS
android_exe_type str

<lang>_args listify[str]

<lang>_pch build_tgt|file|list|str

<lang>_shared_args listify[str]

<lang>_static_args listify[str]

build_by_default bool

build_rpath str

build_subdir str

darwin_versions listify[int|str]

dependencies listify[dep]

export_dynamic bool

extra_files listify[both_libs|build_tgt|custom_tgt|file|str]

gnu_symbol_visibility str

gui_app bool

implib bool|str

implicit_include_directories bool

include_directories listify[inc|str]

install bool

install_dir str

install_mode listify[bool|int|str]

install_rpath str

install_tag str

install_vala_gir bool|str

install_vala_header bool|str

install_vala_vapi bool|str

limited_api str

link_args listify[str]

link_depends listify[build_tgt|custom_tgt|file|str]

link_early_args listify[str]

link_language str

link_whole listify[both_libs|build_tgt|custom_tgt|file]

link_with listify[both_libs|build_tgt|custom_tgt|file]

native bool

objects listify[file|str]

override_options dict[bool|int|list|str]|list[str]|str

pic bool

pie bool

shortname str

sources listify[both_libs|build_tgt|custom_tgt|file|generated_list|str]

soversion int|str

subdir str

target_type str

version str

vs_module_defs custom_tgt|file|str

win_subsystem str

SYNOPSIS
found(
) -> bool

SYNOPSIS
full_path(
) -> str

SYNOPSIS
get_install_dir(
pure bool:,
subdir str:,
) -> str

KWARGS

pure bool

subdir str

SYNOPSIS
get_path(
str,
str,
) -> str

POSARGS

0 str

1 str

SYNOPSIS
get_variable(
str,
any,
) -> any

POSARGS

0 str

1 any

SYNOPSIS
has_path(
str,
) -> bool

POSARGS

0 str

SYNOPSIS
has_variable(
str,
) -> bool

POSARGS

0 str

SYNOPSIS
install_sources(
glob[file|str],
follow_symlinks bool:,
install_dir str:,
install_mode listify[bool|int|str]:,
install_tag str:,
preserve_path bool:,
pure bool:,
rename listify[str]:,
sources listify[file|str]:,
subdir str:,
)

POSARGS

0 glob[file|str]

KWARGS
follow_symlinks bool

install_dir str

install_mode listify[bool|int|str]

install_tag str

preserve_path bool

pure bool

rename listify[str]

sources listify[file|str]

subdir str

SYNOPSIS
language_version(
) -> str

SYNOPSIS
path(
) -> str

SYNOPSIS
version(
) -> str

SYNOPSIS
compiled(
) -> bool

DESCRIPTION

If true, the compilation succeeded, if false it did not and the other methods return unspecified data. This is only available for compiler.run() results.

SYNOPSIS
returncode(
) -> int

DESCRIPTION

The return code of executing the compiled binary

SYNOPSIS
stderr(
) -> str

DESCRIPTION

The standard error produced when the command was run.

SYNOPSIS
stdout(
) -> str

DESCRIPTION

The standard out produced when the command was run.

SYNOPSIS
dependencies(
) -> list

SYNOPSIS
sources(
) -> list

SYNOPSIS
add(
glob[custom_tgt|dep|file|generated_list|str],
if_false listify[custom_tgt|dep|file|generated_list|str]:,
if_true listify[custom_tgt|dep|file|generated_list|str]:,
when listify[dep|str]:,
)

POSARGS

0 glob[custom_tgt|dep|file|generated_list|str]

KWARGS
if_false listify[custom_tgt|dep|file|generated_list|str]

if_true listify[custom_tgt|dep|file|generated_list|str]

when listify[dep|str]

SYNOPSIS
add_all(
glob[source_set],
if_true listify[source_set]:,
when listify[dep|str]:,
)

POSARGS

0 glob[source_set]

KWARGS
if_true listify[source_set]

when listify[dep|str]

SYNOPSIS
all_dependencies(
) -> list

SYNOPSIS
all_sources(
) -> list

SYNOPSIS
apply(
cfg_data|dict,
strict bool:,
) -> source_configuration

POSARGS

0 cfg_data|dict

KWARGS
strict bool

SYNOPSIS
contains(
str,
) -> bool

DESCRIPTION

Returns true if string contains the string specified as the argument.

POSARGS

0 str

The string fragment to check

SYNOPSIS
endswith(
str,
) -> bool

DESCRIPTION

Returns true if string ends with the string specified as the argument.

POSARGS

0 str

The string fragment to check

SYNOPSIS
format(
glob[bool|dict|feature|file|int|list|str],
) -> str

DESCRIPTION

Strings can be built using the string formatting functionality.

See [the Meson syntax entry] for more information.

Since 1.3.0 values other than strings, integers, bools, options, dictionaries and lists thereof are deprecated. They were previously printing the internal representation of the raw Python object.

POSARGS

0 glob[bool|dict|feature|file|int|list|str]

The string to format.

The formatting works by replacing placeholders of type @number@ with the corresponding varargs.

SYNOPSIS
full_path(
) -> str

SYNOPSIS
join(
glob[str],
) -> str

DESCRIPTION

The opposite of split, for example '.'.join(['a', 'b', 'c']) yields 'a.b.c'.

POSARGS

0 glob[str]

The strings to join with the current string.

Before Meson 0.60.0 this function only accepts a single positional argument of the type [array[str]].

SYNOPSIS
length(
) -> int

SYNOPSIS
percent_decode(
) -> str

SYNOPSIS
percent_encode(
) -> str

SYNOPSIS
replace(
str,
str,
) -> str

DESCRIPTION

Search all occurrences of old and replace it with new

POSARGS

0 str

The substring to search

1 str

The replacement string

SYNOPSIS
shell_quote(
shell str[cmd|posix]:,
) -> str

KWARGS

shell str[cmd|posix]

SYNOPSIS
shell_split(
shell str[cmd|posix]:,
) -> list

KWARGS

shell str[cmd|posix]

SYNOPSIS
split(
str,
) -> list

DESCRIPTION

Splits the string at the specified character (or whitespace if not set) and returns the parts in an array.

POSARGS

0 str

Specifies the character / substring where to split the string.

SYNOPSIS
splitlines(
) -> list

DESCRIPTION

Splits the string into an array of lines. Unlike .split('0), the empty string produced an empty array, and if the string ends in a newline, splitlines() doesn't split on that last newline. '0, '' and '0 are all considered newlines.

SYNOPSIS
startswith(
str,
) -> bool

DESCRIPTION

Returns true if string starts with the string specified as the argument.

POSARGS

0 str

The string fragment to check

SYNOPSIS
strip(
str,
) -> str

DESCRIPTION

Removes leading/ending characters from the string.

By default the characters to remove are spaces and newlines.

POSARGS

0 str

Instead of whitespace, strip all the characters in this string.

SYNOPSIS
substring(
int,
int,
) -> str

DESCRIPTION

Returns a substring specified from start to end. Both start and end arguments are optional, so, for example, 'foobar'.substring() will return 'foobar'.

The method accepts negative values where negative start is relative to the end of string len(string) - start as well as negative end.

If start or end are out of bounds, the position of the closest character will be used. If start is bigger than end, the result will be an empty substring.

POSARGS

0 int

The start position

1 int

The end position

SYNOPSIS
to_int(
) -> int

DESCRIPTION

Converts the string to an int and throws an error if it can't be

SYNOPSIS
to_lower(
) -> str

DESCRIPTION

Converts all characters to lower case

SYNOPSIS
to_upper(
) -> str

DESCRIPTION

Converts all characters to upper case

SYNOPSIS
underscorify(
) -> str

DESCRIPTION

Creates a string where every non-alphabetical non-number character is replaced with _.

SYNOPSIS
version_compare(
glob[str],
) -> bool

DESCRIPTION

Does semantic version comparison.

POSARGS

0 glob[str]

The string to compare to.

SYNOPSIS
found(
) -> bool

DESCRIPTION

Returns whether the subproject was successfully setup.

SYNOPSIS
get_variable(
str,
any,
) -> any

DESCRIPTION

fetches the specified variable from inside the subproject. This is useful to, for instance, get a [declaredependency] from the [subproject].

If the variable does not exist, the variable fallback is returned. If a fallback is not specified, then attempting to read a non-existing variable will cause a fatal error.

POSARGS

0 str

The name of the variable to query

1 any

The fallback value to return if var_name does not exist.

SYNOPSIS
import(
str,
required bool|feature:,
) -> module

POSARGS

0 str

KWARGS
required bool|feature

SYNOPSIS
fetch(
list[str]|str,
batch_size int:,
progress bool|feature:,
) -> str

DESCRIPTION

Fetch url(s) using libcurl. Only available if libcurl support is enabeld.

POSARGS

0 list[str]|str

the url(s) to fetch

KWARGS
batch_size int

Batch size

progress bool|feature

Show progress output

SYNOPSIS
getopt(
listify[str],
dict[dict],
) -> list

DESCRIPTION

Parse command line arguments using getopt. Returns the array of trailing positional args.

POSARGS

0 listify[str]

the array of arguments to parse

1 dict[dict]

A dict of opt -> handler.

  • opt must be a single character.
  • handler is a dict that may contain the following keys:


- required - defaults to false, causes this option to be required - action - required, a function that will be called to handle this option


If the function accepts a single argument then the option will be required to supply a value - desc - required, a string to show in the help message.

SYNOPSIS
parse(
str,
check bool:,
) -> dict|list

DESCRIPTION

Parse a json string into an object

POSARGS

0 str

the json to parse

KWARGS
check bool

SYNOPSIS
stringify(
bool|dict|feature|file|int|list|str|null,
) -> any

DESCRIPTION

Convert an object into a json string

POSARGS

0 bool|dict|feature|file|int|list|str|null

the object to stringify

SYNOPSIS
clean(
listify[str],
force bool:,
)

DESCRIPTION

Clean subprojects with .wrap files

POSARGS

0 listify[str]

A list of subprojects to operate on.

KWARGS
force bool

Force the operation.

SYNOPSIS
fetch(
str,
str,
)

DESCRIPTION

Fetch a project using a .wrap file

POSARGS

0 str

The wrap file to fetch.

1 str

The directory to fetch into

SYNOPSIS
list(
listify[str],
print bool:,
) -> list

DESCRIPTION

List subprojects with .wrap files and their status.

POSARGS

0 listify[str]

A list of subprojects to operate on.

KWARGS
print bool

Print out a formatted list of subprojects as well as returning it.

SYNOPSIS
load_wrap(
str,
)

DESCRIPTION

Load a wrap file into a dict

POSARGS

0 str

The wrap file to load.

SYNOPSIS
update(
listify[str],
required bool|feature:,
)

DESCRIPTION

Update subprojects with .wrap files

POSARGS

0 listify[str]

A list of subprojects to operate on.

KWARGS
required bool|feature

Fail if any update would have been skipped (e.g. if the destination is dirty).

SYNOPSIS
nanosleep(
int,
)

POSARGS

0 int

SYNOPSIS
timer_read(
int,
) -> int

POSARGS

0 int

SYNOPSIS
timer_start(
) -> int

SYNOPSIS
create(
inherit compiler:,
inherit_archiver compiler|str:,
inherit_compiler compiler|str:,
inherit_linker compiler|str:,
inherit_static_linker compiler|str:,
) -> compiler

DESCRIPTION

Creates a new compiler object that can be passed in to the toolchain keyword on add_languages or inherited from when coreating a new toolchain. The toolchain object is reffered to as a compiler for historical reasons, although it also contains other information required to compile programs such as linker metadata.

KWARGS

inherit compiler

A toolchain to inherit from

inherit_archiver compiler|str

The archiver component to inherit from. Can be either a compiler object or static linker type name.

inherit_compiler compiler|str

The compiler component to inherit from. Can be either a compiler object or compiler type name.

inherit_linker compiler|str

The linker component to inherit from. Can be either a compiler object or linker type name.

inherit_static_linker compiler|str

Deprecated. Please use inheritarchiver instead

SYNOPSIS
handler(
str,
str,
str,
) -> function|list

DESCRIPTION

Retrieve a previously defined handler

POSARGS

0 str

1 str

2 str

SYNOPSIS
parse_triple(
str,
) -> dict

DESCRIPTION

parse a target triple

POSARGS

0 str

SYNOPSIS
register_archiver(
str,
detect function:,
exe str:,
handlers dict[bool|function|list[str]]:,
inherit str:,
public_id str:,
) -> dict

DESCRIPTION

Register a new static linker type

POSARGS

0 str

The id of this component

KWARGS
detect function

If set, defines a function (str) -> int that will be called with the version output. This function is passed a string containing the combined stdout and stderr resulting from executing the candidate exe with this components version argument. If no version argument is defined then the empty string is passed. The return value should be a number indicating the confidence of a match, anything <= 0 will be skipped. If no detect function is specified the default score of 1 will be applied. After all candidate's detections are executed, the candidate with the highest score will be selected.

exe str

The exe_name is used to bootstrap toolchain detection when no executable is explicitly defined (e.g. using CC=clang).

handlers dict[bool|function|list[str]]

A dict mapping handler names to functions. If the handler returns a constant value, then that may be used instead of a function. The full list of supported handlers for this component are listed in the table below. For some handlers, the description shows a common value for that handler. For examples of toolchain definitons, see src/script/runtime/toolchains.meson in muon's source tree. |name|signature|description| |---|---|---| always|(compiler) -> list[str]|Arguments that are almost always passed, except in special cases such as detection. base|(compiler) -> list[str]|Arguments used to create an archive, e.g. csr for ar-posix. inputoutput|(compiler, str, str) -> list[str]|Passed in input and output and orders them properly, optionally adding additional flags. needswipe|(compiler) -> bool|true if this archiver cannot overwrite old archives and needs muon to remove them for it. version|(compiler) -> list[str]|--version

inherit str

If set, inherit properties from a previously defined component.

public_id str

Returned by compiler.get_id() and compiler.get_linker_id(). Defaults to id if not set.

SYNOPSIS
register_compiler(
str,
archiver function|str:,
detect function:,
exe dict[str]:,
handlers dict[bool|function|list[str]]:,
inherit str:,
linker function|str:,
public_id str:,
) -> dict

DESCRIPTION

Register a new compiler type

POSARGS

0 str

The id of this component

KWARGS
archiver function|str

If set, defines a string or function (compiler) -> str that will be used to determine the archiver id for this compiler.

detect function

If set, defines a function (str) -> int that will be called with the version output. This function is passed a string containing the combined stdout and stderr resulting from executing the candidate exe with this components version argument. If no version argument is defined then the empty string is passed. The return value should be a number indicating the confidence of a match, anything <= 0 will be skipped. If no detect function is specified the default score of 1 will be applied. After all candidate's detections are executed, the candidate with the highest score will be selected.

exe dict[str]

A dict mapping langage -> exe_name, e.g. {'c': 'clang', 'cpp': 'clang++'}. The exe_name is used to bootstrap toolchain detection when no executable is explicitly defined (e.g. using CC=clang).

handlers dict[bool|function|list[str]]

A dict mapping handler names to functions. If the handler returns a constant value, then that may be used instead of a function. The full list of supported handlers for this component are listed in the table below. For some handlers, the description shows a common value for that handler. For examples of toolchain definitons, see src/script/runtime/toolchains.meson in muon's source tree. |name|signature|description| |---|---|---| always|(compiler) -> list[str]|Arguments that are almost always passed, except in special cases such as detection. argumentsyntax|(compiler) -> list[str]|Defines the return value of compiler.getargumentsyntax(). cancompilellvmir|(compiler) -> bool|True if this compiler can compile llvmir, e.g. clang. checkignoredoption|(compiler, str) -> bool|Called for compiler.hasargument() with the compiler's output. Useful if the compiler exits 0 but indicates on stderr or stdout that an option was ignored. coloroutput|(compiler, str) -> list[str]|-fdiagnostics-color compileonly|(compiler) -> list[str]|-c coverage|(compiler) -> list[str]|--coverage crt|(compiler, str, bool) -> list[str]|Determine the C-runtime, e.g. for msvc. debug|(compiler) -> list[str]|-g debugfile|(compiler, str) -> list[str]|Used to tell msvc where to put pdb files. define|(compiler, str) -> list[str]|-D deps|(compiler, str, str) -> list[str]|Arguments that instruct the compiler to output extra dependencies such as headers. depstype|(compiler) -> list[str]|Determines deps type that ninja to uses doarchiverpassthrough|(compiler) -> bool|true if the archiver is the same executable as the compiler (e.g. tcc) dolinkerpassthrough|(compiler) -> bool|true if the linker should only be invoked through the compiler driver, or false if the linker should be invoked directly. dumpmachine|(compiler) -> list[str]|Argument to output the compiler's target triple. emitpch|(compiler) -> list[str]| ltocompile|(compiler, int) -> list[str]|Link-time optimization compile arguments. Receives the thread count as a string; 0 means automatic. ltolink|(compiler, int) -> list[str]|Link-time optimization link arguments. Receives the thread count as a string; 0 means automatic. ltosupported|(compiler) -> bool|Whether this compiler supports LTO compilation and linking. forcelanguage|(compiler, str) -> list[str]|-x include|(compiler, str) -> list[str]|-I includedirafter|(compiler, str) -> list[str]|-idirafter includepch|(compiler, str) -> list[str]| includesystem|(compiler, str) -> list[str]|-isystem linkerdelimiter|(compiler) -> list[str]|/link linkerpassthrough|(compiler, list[str]) -> list[str]|Handles properly using -Wl, to pass arguments to the linker. objectext|(compiler) -> list[str]|e.g. .o or .obj optimization|(compiler, str[0 / 1 / 2 / 3 / g / none / s]) -> list[str]| output|(compiler, str) -> list[str]|-o pchext|(compiler) -> list[str]| permissive|(compiler) -> list[str]|-fpermissive pgo|(compiler, str[generate / use]) -> list[str]| pic|(compiler) -> list[str]|-fPIC pie|(compiler) -> list[str]|-fPIE preprocessonly|(compiler) -> list[str]|-E printsearchdirs|(compiler) -> list[str]|Instruct the compilerArgument to output the compiler's internal search directories. sanitize|(compiler, list[str]) -> list[str]|-fsanitize setstd|(compiler, str) -> list[str]|-std stdunsupported|(compiler, str) -> bool|Return true if the passed in std is unsupported by the current compiler. version|(compiler) -> list[str]|--version visibility|(compiler, str[default / hidden / inlineshidden / internal / protected]) -> list[str]| warneverything|(compiler) -> list[str]|-Weverything warninglvl|(compiler, str[0 / 1 / 2 / 3 / everything]) -> list[str]| werror|(compiler) -> list[str]|-Werror winvalidpch|(compiler) -> list[str]| asanlundefwarning|(compiler) -> bool|whether to warn if blundef is used alongside sanitizers

inherit str

If set, inherit properties from a previously defined component.

linker function|str

If set, defines a string or function (compiler) -> str that will be used to determine the linker id for this compiler.

public_id str

Returned by compiler.get_id() and compiler.get_linker_id(). Defaults to id if not set.

SYNOPSIS
register_linker(
str,
detect function:,
exe str:,
handlers dict[bool|function|list[str]]:,
inherit str:,
public_id str:,
) -> dict

DESCRIPTION

Register a new linker type

POSARGS

0 str

The id of this component

KWARGS
detect function

If set, defines a function (str) -> int that will be called with the version output. This function is passed a string containing the combined stdout and stderr resulting from executing the candidate exe with this components version argument. If no version argument is defined then the empty string is passed. The return value should be a number indicating the confidence of a match, anything <= 0 will be skipped. If no detect function is specified the default score of 1 will be applied. After all candidate's detections are executed, the candidate with the highest score will be selected.

exe str

The exe_name is used to bootstrap toolchain detection when no executable is explicitly defined (e.g. using CC=clang).

handlers dict[bool|function|list[str]]

A dict mapping handler names to functions. If the handler returns a constant value, then that may be used instead of a function. The full list of supported handlers for this component are listed in the table below. For some handlers, the description shows a common value for that handler. For examples of toolchain definitons, see src/script/runtime/toolchains.meson in muon's source tree. |name|signature|description| |---|---|---| allowshlibundefined|(compiler) -> list[str]|Allow undefined symbols always|(compiler) -> list[str]|Arguments that are almost always passed, except in special cases such as detection. asneeded|(compiler) -> list[str]| checkignoredoption|(compiler, str) -> bool|Called for compiler.haslinkargument() with the linker's output. Useful if the linker exits 0 but indicates on stderr or stdout that an option was ignored. coverage|(compiler) -> list[str]|--coverage debug|(compiler) -> list[str]|/DEBUG def|(compiler, str) -> list[str]|/DEF endgroup|(compiler) -> list[str]|--end-group exportdynamic|(compiler) -> list[str]|-export-dynamic fatalwarnings|(compiler) -> list[str]|--fatal-warnings fuseld|(compiler) -> list[str]|-fuse-ld= implib|(compiler, str) -> list[str]|/IMPLIB implibsuffix|(compiler) -> list[str]|Linker specific import library suffix for DLLs. Defaults to '-implib.lib' if not provided. inputoutput|(compiler, str, str) -> list[str]|Passed in input and output and orders them properly, optionally adding additional flags. lib|(compiler, str) -> list[str]|-l noundefined|(compiler) -> list[str]|--no-undefined pgo|(compiler, str[generate / use]) -> list[str]| processrpath|(compiler, kwargs glob[any]:) -> list[str]|process rpath directories rpath|(compiler, list[str]) -> list[str]|-rpath sanitize|(compiler, list[str]) -> list[str]|-fsanitize shared|(compiler) -> list[str]|-shared sharedmodule|(compiler) -> list[str]| soname|(compiler, str) -> list[str]|-soname startgroup|(compiler) -> list[str]|--start-group tonative|(compiler, list[str]) -> list[str]|Convert arguments to linker-specific native format. version|(compiler) -> list[str]|-v wholearchive|(compiler, str) -> list[str]|--whole-archive

inherit str

If set, inherit properties from a previously defined component.

public_id str

Returned by compiler.get_id() and compiler.get_linker_id(). Defaults to id if not set.

SYNOPSIS
exit(
int,
)

POSARGS

0 int

SYNOPSIS
repr(
any|null,
) -> str

DESCRIPTION

return a string representing the passed object

POSARGS

0 any|null

SYNOPSIS
serial_dump(
file|str,
any,
)

POSARGS

0 file|str

1 any

SYNOPSIS
serial_load(
file|str,
) -> any

POSARGS

0 file|str

SYNOPSIS
add_suffix(
str,
str,
) -> str

DESCRIPTION

Append a suffix to a path

POSARGS

0 str

1 str

SYNOPSIS
as_posix(
str,
) -> str

DESCRIPTION

Convert backslashes to /

POSARGS

0 str

SYNOPSIS
canonicalize(
str,
) -> str

DESCRIPTION

Make a path absolute and replace ..

POSARGS

0 str

SYNOPSIS
copy(
file|str,
str,
force bool:,
)

DESCRIPTION

Copy a file to a destination at configure time

POSARGS

0 file|str

1 str

KWARGS
force bool

SYNOPSIS
copyfile(
file|str,
str,
install bool:,
install_dir listify[bool|str]:,
install_mode listify[bool|int|str]:,
install_tag str:,
) -> custom_tgt

DESCRIPTION

Creates a custom target that copies a file at build time

POSARGS

0 file|str

1 str

KWARGS
install bool

install_dir listify[bool|str]

install_mode listify[bool|int|str]

install_tag str

SYNOPSIS
cwd(
) -> str

DESCRIPTION

Return the muon's current working directory

SYNOPSIS
delete_with_suffix(
str,
str,
) -> list

DESCRIPTION

Recursively delete all files with a matching suffix

POSARGS

0 str

1 str

SYNOPSIS
executable(
str,
) -> str

DESCRIPTION

Prepend ./ to a path if it is a basename

POSARGS

0 str

SYNOPSIS
exists(
str,
) -> bool

DESCRIPTION

Check if a file or directory exists

POSARGS

0 str

SYNOPSIS
expanduser(
str,
) -> str

DESCRIPTION

Expand a path that starts with a ~ into an absolute path

POSARGS

0 str

SYNOPSIS
glob(
str,
) -> list

DESCRIPTION

Gather a list of files matching a glob expression

POSARGS

0 str

SYNOPSIS
hash(
file|str,
str,
) -> str

DESCRIPTION

Calculate the content hash of a file

POSARGS

0 file|str

1 str

SYNOPSIS
is_absolute(
file|str,
) -> bool

DESCRIPTION

Check if a path is absolute

POSARGS

0 file|str

SYNOPSIS
is_basename(
str,
) -> bool

DESCRIPTION

Check if a path is a basename

POSARGS

0 str

SYNOPSIS
is_dir(
str,
) -> bool

DESCRIPTION

Check if a directory exists

POSARGS

0 str

SYNOPSIS
is_file(
str,
) -> bool

DESCRIPTION

Check if a file exists

POSARGS

0 str

SYNOPSIS
is_samepath(
file|str,
file|str,
) -> bool

DESCRIPTION

Check if two paths point to the same object

POSARGS

0 file|str

1 file|str

SYNOPSIS
is_subpath(
str,
str,
) -> bool

DESCRIPTION

Check if a path is a subpath of another path

POSARGS

0 str

1 str

SYNOPSIS
is_symlink(
file|str,
) -> bool

DESCRIPTION

Check if a symlink exists

POSARGS

0 file|str

SYNOPSIS
make_absolute(
str,
) -> str

DESCRIPTION

Make a path absolute by prepending the current working directory

POSARGS

0 str

SYNOPSIS
mkdir(
str,
make_parents bool:,
)

DESCRIPTION

Create a directory

POSARGS

0 str

KWARGS
make_parents bool

SYNOPSIS
name(
both_libs|build_tgt|custom_tgt|file|str,
) -> str

DESCRIPTION

Get the basename of a path

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

SYNOPSIS
parent(
both_libs|build_tgt|custom_tgt|file|str,
) -> str

DESCRIPTION

Get the dirname of a path

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

SYNOPSIS
read(
file|str,
encoding str:,
) -> str

DESCRIPTION

Read a file from disk

POSARGS

0 file|str

KWARGS
encoding str

SYNOPSIS
relative_to(
both_libs|build_tgt|custom_tgt|file|str,
both_libs|build_tgt|custom_tgt|file|str,
) -> str

DESCRIPTION

Get a path relative to another path

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

1 both_libs|build_tgt|custom_tgt|file|str

SYNOPSIS
replace_suffix(
both_libs|build_tgt|custom_tgt|file|str,
str,
) -> str

DESCRIPTION

Replace a path's suffix

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

1 str

SYNOPSIS
rmdir(
str,
force bool:,
recursive bool:,
) -> list

DESCRIPTION

Remove a directory

POSARGS

0 str

KWARGS
force bool

recursive bool

SYNOPSIS
size(
file|str,
) -> int

DESCRIPTION

Get a file's size in bytes

POSARGS

0 file|str

SYNOPSIS
stem(
both_libs|build_tgt|custom_tgt|file|str,
) -> str

DESCRIPTION

Get the basename of a path with its extension removed

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

SYNOPSIS
suffix(
both_libs|build_tgt|custom_tgt|file|str,
) -> str

DESCRIPTION

The last dot-separated portion of the final component, if any

POSARGS

0 both_libs|build_tgt|custom_tgt|file|str

SYNOPSIS
without_ext(
str,
) -> str

DESCRIPTION

Get a path with its extension removed

POSARGS

0 str

SYNOPSIS
write(
file|str,
str,
)

DESCRIPTION

Write a file

POSARGS

0 file|str

1 str

SYNOPSIS
compile_resources(
str,
custom_tgt|file|generated_list|str,
build_by_default bool:,
c_name str:,
dependencies listify[custom_tgt|file]:,
export bool:,
extra_args listify[str]:,
gresource_bundle bool:,
install bool:,
install_dir str:,
install_header bool:,
source_dir listify[str]:,
) -> list[custom_tgt]

POSARGS

0 str

1 custom_tgt|file|generated_list|str

KWARGS
build_by_default bool

c_name str

dependencies listify[custom_tgt|file]

export bool

extra_args listify[str]

gresource_bundle bool

install bool

install_dir str

install_header bool

source_dir listify[str]

SYNOPSIS
compile_schemas(
build_by_default bool:,
depend_files listify[file|list[file|str]|str]:,
) -> custom_tgt

POSARGS

KWARGS
build_by_default bool

depend_files listify[file|list[file|str]|str]

SYNOPSIS
gdbus_codegen(
str,
glob[custom_tgt|file|generated_list|str],
annotations list[list[str]]:,
autocleanup str:,
build_by_default bool:,
docbook str:,
extra_args listify[str]:,
install_dir str:,
install_header bool:,
interface_prefix str:,
markdown str:,
namespace str:,
object_manager bool:,
rst str:,
sources listify[custom_tgt|file|str]:,
) -> list[custom_tgt]

POSARGS

0 str

1 glob[custom_tgt|file|generated_list|str]

KWARGS
annotations list[list[str]]

autocleanup str

build_by_default bool

docbook str

extra_args listify[str]

install_dir str

install_header bool

interface_prefix str

markdown str

namespace str

object_manager bool

rst str

sources listify[custom_tgt|file|str]

SYNOPSIS
generate_gir(
glob[exe],
build_by_default bool:,
dependencies listify[dep]:,
export_packages listify[str]:,
extra_args listify[str]:,
fatal_warnings bool:,
header listify[str]:,
identifier_prefix listify[str]:,
include_directories listify[inc]:,
includes listify[str]:,
install bool:,
install_dir_gir bool|str:,
install_dir_typelib bool|str:,
install_gir bool:,
install_typelib bool:,
link_with listify[both_libs|build_tgt]:,
namespace str:,
nsversion str:,
sources listify[custom_tgt|file|generated_list|str]:,
symbol_prefix listify[str]:,
) -> list[custom_tgt]

POSARGS

0 glob[exe]

KWARGS
build_by_default bool

dependencies listify[dep]

export_packages listify[str]

extra_args listify[str]

fatal_warnings bool

header listify[str]

identifier_prefix listify[str]

include_directories listify[inc]

includes listify[str]

install bool

install_dir_gir bool|str

install_dir_typelib bool|str

install_gir bool

install_typelib bool

link_with listify[both_libs|build_tgt]

namespace str

nsversion str

sources listify[custom_tgt|file|generated_list|str]

symbol_prefix listify[str]

SYNOPSIS
genmarshal(
str,
depend_files listify[file|str]:,
depends listify[build_tgt|custom_tgt]:,
extra_args listify[str]:,
install_dir str:,
install_header bool:,
internal bool:,
nostdinc bool:,
prefix str:,
skip_source bool:,
sources listify[file|str]:,
stdinc bool:,
valist_marshallers bool:,
) -> list[custom_tgt]

POSARGS

0 str

KWARGS
depend_files listify[file|str]

depends listify[build_tgt|custom_tgt]

extra_args listify[str]

install_dir str

install_header bool

internal bool

nostdinc bool

prefix str

skip_source bool

sources listify[file|str]

stdinc bool

valist_marshallers bool

SYNOPSIS
mkenums(
str,
c_template file|str:,
comments str:,
depends listify[build_tgt|custom_tgt]:,
eprod str:,
fhead str:,
fprod str:,
ftail str:,
h_template file|str:,
identifier_prefix str:,
install_dir str:,
install_header bool:,
sources listify[custom_tgt|file|generated_list|str]:,
symbol_prefix str:,
vhead str:,
vprod str:,
vtail str:,
) -> list[custom_tgt]

POSARGS

0 str

KWARGS
c_template file|str

comments str

depends listify[build_tgt|custom_tgt]

eprod str

fhead str

fprod str

ftail str

h_template file|str

identifier_prefix str

install_dir str

install_header bool

sources listify[custom_tgt|file|generated_list|str]

symbol_prefix str

vhead str

vprod str

vtail str

SYNOPSIS
mkenums_simple(
str,
body_prefix str:,
decorator str:,
function_prefix str:,
header_prefix str:,
identifier_prefix str:,
install_dir str:,
install_header bool:,
sources listify[file|str]:,
symbol_prefix str:,
) -> list[custom_tgt]

POSARGS

0 str

KWARGS
body_prefix str

decorator str

function_prefix str

header_prefix str

identifier_prefix str

install_dir str

install_header bool

sources listify[file|str]

symbol_prefix str

SYNOPSIS
post_install(
gio_querymodules listify[str]:,
glib_compile_schemas bool:,
gtk_update_icon_cache bool:,
update_desktop_database bool:,
update_mime_database bool:,
)

POSARGS

KWARGS
gio_querymodules listify[str]

glib_compile_schemas bool

gtk_update_icon_cache bool

update_desktop_database bool

update_mime_database bool

SYNOPSIS
gettext(
str,
args listify[str]:,
data_dirs listify[str]:,
install bool:,
install_dir str:,
languages listify[str]:,
preset str:,
) -> list[any]

DESCRIPTION

Sets up gettext localisation so that translations are built and placed into their proper locations during install.

This function also defines targets for maintainers to use: Note: These output to the source directory - <project_id>-pot: runs xgettext to regenerate the pot file - <project_id>-update-po: regenerates the .po files from current .pot file - <project_id>-gmo: builds the translations without installing

Returns a list containing: - a list of built .mo files - the maintainer -pot target - the maintainer -update-po target

POSARGS

0 str

the name of the gettext module

KWARGS
args listify[str]

list of extra arguments to pass to xgettext when generating the pot file

data_dirs listify[str]

list of directories to be set for GETTEXTDATADIRS env var (Requires gettext 0.19.8+), used for local its files

install bool


if false, do not install the built translations.

install_dir str

override default install location, default is localedir

languages listify[str]

list of languages that are to be generated. As of 0.37.0 this is optional and the [LINGUAS] file is read.

preset str

name of a preset list of arguments, current option is 'glib'

SYNOPSIS
itstool_join(
build_by_default bool:,
input listify[custom_tgt|file|str]:,
install bool:,
install_dir str:,
install_tag str:,
its_files listify[file|str]:,
mo_targets listify[custom_tgt]:,
output str:,
) -> custom_tgt

DESCRIPTION

This joins translations into a XML file using itstool

POSARGS

KWARGS
build_by_default bool

same as customtarget()

input listify[custom_tgt|file|str]

same as customtarget()

install bool

same as customtarget()

install_dir str

same as customtarget() but only accepts one item

install_tag str

same as customtarget() but only accepts one item

its_files listify[file|str]

filenames of ITS files that should be used explicitly (XML translation rules are autodetected otherwise).

mo_targets listify[custom_tgt]

required mo file generation targets as returned by i18n.gettext().

output str

same as customtarget() but only accepts one item

SYNOPSIS
merge_file(
args listify[str]:,
build_by_default bool:,
data_dirs listify[str]:,
input listify[custom_tgt|file|str]:,
install bool:,
install_dir str:,
install_tag str:,
output str:,
po_dir str:,
type str:,
) -> custom_tgt

DESCRIPTION

This merges translations into a text file using msgfmt.

POSARGS

KWARGS
args listify[str]

list of extra arguments to pass to msgfmt

build_by_default bool

same as customtarget()

data_dirs listify[str]

list of data directories see [gettext]

input listify[custom_tgt|file|str]

same as customtarget()

install bool

same as customtarget()

install_dir str

same as customtarget() but only accepts one item

install_tag str

same as customtarget() but only accepts one item

output str

same as customtarget() but only accepts one item

po_dir str

directory containing translations, relative to current directory

type str

type of file, valid options are 'xml' and 'desktop'

SYNOPSIS
xgettext(
str,
glob[build_tgt|custom_tgt|file|str],
install bool:,
install_dir str:,
install_tag str:,
recursive bool:,
) -> custom_tgt

DESCRIPTION

Invokes the xgettext program on given sources, to generate a .pot file. This function is to be used when the gettext function workflow is not suitable for your project. For example, it can be used to produce separate .pot files for each executable.

POSARGS

0 str

The name of the resulting pot file.

1 glob[build_tgt|custom_tgt|file|str]

Source files or targets. May be a list of string, File, buildtgt, or customtgt returned from other calls to this function.

KWARGS
install bool

if true, will add the resulting pot file to install targets.

install_dir str

directory where to install the resulting pot file.

install_tag str

install tag to use for the install target.

recursive bool

if true, will merge the resulting pot file with extracted pot files related to dependencies of the given source targets. For instance, if you build an executable, then you may want to merge the executable translations with the translations from the dependent libraries.

SYNOPSIS
load(
file|str,
) -> dict

POSARGS

0 file|str

SYNOPSIS
generate(
both_libs|build_tgt,
cflags_private listify[str]:,
conflicts listify[str]:,
dataonly bool:,
description str:,
extra_cflags listify[str]:,
filebase str:,
install_dir str:,
libraries listify[both_libs|build_tgt|custom_tgt|dep|file|str]:,
libraries_private listify[both_libs|build_tgt|custom_tgt|dep|file|str]:,
license str:,
name str:,
requires listify[both_libs|build_tgt|dep|str]:,
requires_private listify[both_libs|build_tgt|dep|str]:,
subdirs listify[str]:,
unescaped_uninstalled_variables dict|list|str:,
unescaped_variables dict|list|str:,
uninstalled_variables dict|list|str:,
url str:,
variables dict|list|str:,
version str:,
) -> file

POSARGS

0 both_libs|build_tgt

KWARGS
cflags_private listify[str]

conflicts listify[str]

dataonly bool

description str

extra_cflags listify[str]

filebase str

install_dir str

libraries listify[both_libs|build_tgt|custom_tgt|dep|file|str]

libraries_private listify[both_libs|build_tgt|custom_tgt|dep|file|str]

license str

name str

requires listify[both_libs|build_tgt|dep|str]

requires_private listify[both_libs|build_tgt|dep|str]

subdirs listify[str]

unescaped_uninstalled_variables dict|list|str

unescaped_variables dict|list|str

uninstalled_variables dict|list|str

url str

variables dict|list|str

version str

SYNOPSIS
parse_fragments(
listify[str],
compiler compiler:,
flags_key str:,
static bool:,
) -> dict

POSARGS

0 listify[str]

KWARGS
compiler compiler

flags_key str

static bool

SYNOPSIS
find_installation(
str,
disabler bool:,
modules listify[str]:,
pure bool:,
required bool|feature:,
) -> python_installation

POSARGS

0 str

KWARGS
disabler bool

modules listify[str]

pure bool

required bool|feature

SYNOPSIS
find_python(
str,
) -> external_program

POSARGS

0 str

SYNOPSIS
symbol_visibility_header(
str,
api str:,
compilation str:,
namespace str:,
static_compilation str:,
static_only bool:,
) -> file

DESCRIPTION

Generate a header file that defines macros to be used to mark all public APIs of a library. Depending on the platform, this will typically use declspec(dllexport), declspec(dllimport) or attribute((visibility("default"))). It is compatible with C, C++, ObjC and ObjC++ languages. The content of the header is static regardless of the compiler used.

POSARGS

0 str

KWARGS
api str

Name of the macro used to mark public APIs. Defaults to <NAMESPACE>API.

compilation str

Name of a macro defined only when compiling the library. Defaults to <NAMESPACE>COMPILATION.

namespace str

Prefix for generated macros, defaults to the current project name. It will be converted to upper case with all non-alphanumeric characters replaced by an underscore . It is only used for api, compilation and staticcompilation default values.

static_compilation str

Name of a macro defined only when compiling or using static library. Defaults to <NAMESPACE>STATICCOMPILATION.

static_only bool

If set to true, <NAMESPACE>STATICCOMPILATION is defined inside the generated header. In that case the header can only be used for building a static library. By default it is true when defaultlibrary=static, and false otherwise.

SYNOPSIS
source_set(
) -> source_set

SYNOPSIS
find_protocol(
str,
state str:,
version int:,
) -> file

DESCRIPTION

Find a wayland protocol file

POSARGS

0 str

The protocol name

KWARGS
state str

Optional arg that specifies the current state of the protocol. Either 'stable', 'staging', or 'unstable'. The default is 'stable'.

version int

The backwards incompatible version number as integer. Required for staging and unstable, but not allowed for stable.

SYNOPSIS
scan_xml(
listify[file|str],
client bool:,
include_core_only bool:,
public bool:,
server bool:,
) -> list[custom_tgt]

DESCRIPTION

Run wayland scanner to generate files based on a protocol

POSARGS

0 listify[file|str]

List of protocol files to process

KWARGS
client bool

Optional arg that specifies if client side header file is generated.

include_core_only bool

Optional arg that specifies that generated headers only include wayland-<client|server>-core.h instead of wayland-<client|server>.h.

public bool

Optional arg that specifies the scope of the generated code.

server bool

Optional arg that specifies if server side header file is generated.

SYNOPSIS
compile_resources(
glob[custom_tgt|file|str],
args listify[str]:,
depend_files listify[file|str]:,
depends listify[build_tgt|custom_tgt|file]:,
implicit_include_directories bool:,
include_directories list[inc|str]:,
) -> list[custom_tgt]

DESCRIPTION

Compiles Windows rc files specified in the positional arguments. Returns a list of custom_tgt objects that you put in the list of sources for the target you want to have the resources in.

POSARGS

0 glob[custom_tgt|file|str]

windows resource files

KWARGS
args listify[str]

extra arguments to pass to the resource compiler

depend_files listify[file|str]

files that the resource files depend on

depends listify[build_tgt|custom_tgt|file]

targets that the resource files depend on

implicit_include_directories bool

automatically add current build and source directories to includedirectories

include_directories list[inc|str]

lists directories to be both searched by the resource compiler for referenced resource files, and added to the preprocessor include search path

Documentation comes from muon (https://muon.build/) and the meson project (https://mesonbuild.com) and is released under Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). Code samples are released under CC0 1.0 Universal (CC0 1.0).

Meson is a registered trademark of Jussi Pakkanen.

muon 0.8.0-dev-8b3af496