| 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].
Adds global arguments to the compiler command line.
POSARGS
The compiler arguments to add
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.
Adds global arguments to the linker command line.
Like [addglobalarguments] but the arguments are passed to the linker.
POSARGS
The linker arguments to add
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.
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
The languages to add
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.
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
The compiler arguments to add
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.
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
The dependencies to add; if internal dependencies are included, they must not include any built object.
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.
Adds project specific arguments to the linker command line.
Like [addprojectarguments] but the arguments are passed to the linker.
POSARGS
The linker arguments to add
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.
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
The name of the test setup
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.
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
The name of the alias target
1 glob[alias_tgt|both_libs|build_tgt|custom_tgt]
The targets to depend on
Abort with an error message if condition evaluates to false.
POSARGS
Abort if this evaluates to false
1 str
The error message to print.
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:
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
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.
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:
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
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
The name for this build target, followed by an optional list of sources.
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.
Creates a build target whose type can be set dynamically with the target_type keyword argument.
target_type may be set to one of:
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
The name for this build target, followed by an optional list of sources.
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.
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
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.
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
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.
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
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:
(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
The unique id of the custom target
This posarg is optional since 0.60.0. It defaults to the basename of the first output.
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
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
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.
Write the argument string to the meson build log.
POSARGS
The message to print
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 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.
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.
Dependencies can also be resolved in two other ways:
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
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.
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.
Returns a [@disabler] object.
Returns an empty [@env] object.
POSARGS
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.
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.
Print the argument string and halts the build process.
POSARGS
The message to print
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
The name for this build target, followed by an optional list of sources.
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.
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
Path to the file.
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
The name of the program to search, or a [@file] object to be used without searching.
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.
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:
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:
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
Executable for the command to run
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.
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
Name of the option to query
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
Name of the variable to get
1 any
Fallback value to return when the variable does not exist
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
Name of the module to import.
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.
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
Include paths to add.
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).
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
Files to install.
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.
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
Directory to create during installation.
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.
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
Header files to install.
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.
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
Man pages to install.
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.
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
The sub-directory to install
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.
Installs a symbolic link to pointing_to target under installdir.
POSARGS
Name of the created link under install_dir. It cannot contain path separators. Those should go in install_dir.
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.
Returns true if a variable is a disabler and false otherwise.
POSARGS
The variable to test
POSARGS
Returns true if a variable of the given name exists and false otherwise.
POSARGS
The variable to test
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
The path parts to join.
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
The name for this build target, followed by an optional list of sources.
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.
This function prints its argument to stdout.
POSARGS
The message to print.
POSARGS
deprecated bool|str|dict[str]|list[str]
description str
max int
min int
type str
value any
yield bool
POSARGS
pretty bool
POSARGS
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
The name of the project.
1 glob[str]
The languages that Meson should initialize.
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.
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>
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
The start of the range
1 int
The end of the range
2 int
The loop increment
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
The command to execute during the setup process.
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
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
The name of the run target
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.
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
The name of the variable to set
1 any
The value to set the variable to
Builds a shared library with the given sources.
POSARGS
The name for this build target, followed by an optional list of sources.
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.
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
The name for this build target, followed by an optional list of sources.
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.
Builds a static library with the given sources.
POSARGS
The name for this build target, followed by an optional list of sources.
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.
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
Directory relative to the current meson.build to enter.
Cannot contain ..
Only enter the subdir if all [dep.found] methods return true.
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.
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.
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
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.
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.
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:
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
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.
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.
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
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.
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:
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
POSARGS
Unsets a variable. Referencing a variable which has been unset is an error until it has been set again.
POSARGS
The variable to unset.
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
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.
This function prints its argument to stdout prefixed with WARNING:.
POSARGS
The message to print.
Returns 1 if true and 0 if false
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
The string to return when the boolean is true
1 str
The string to return when the boolean is false
KWARGS
POSARGS
Returns the stored shared library
Returns the stored static library
Returns a more specific CPU name, such as i686, armv8l, etc.
Returns the CPU family name. [This table] contains all known CPU families. These are guaranteed to continue working.
Returns 'big' on big-endian systems and 'little' on little-endian systems.
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.
POSARGS
accepted properties: .nf
str
POSARGS
accepted properties: .nf
setproperties
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.
Returns the operating system name. [This table] lists all of the currently known operating system names. These are guaranteed to continue working.
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
Also return objects passed to the objects argument of this target.
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
Source filenames for which the built objects should be extracted.
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].
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.
Returns the name of the target.
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.
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.
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
The name of the variable to query
1 any
The default value to return when varname does not exist
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
The name of the variable to query
1 any
The default value to return when varname does not exist
returns true if the specified variable is set
POSARGS
The name of the variable to query
Returns an array of keys of the configuration data object.
You can iterate over this array with the [foreach statement].
Takes as argument a different configuration data object and copies all entries from that object to the current.
POSARGS
The other [@cfgdata] object to merge into this one.
Sets a variable to a given value
POSARGS
The name of the variable to set
1 bool|int|str
The value to set
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.
Is the same as [cfgdata.set] but the value is either true or false and will be written as 1 or 0, respectively
POSARGS
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.
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.
Is same as [cfgdata.set] but quotes the value in double quotes (")
POSARGS
The name of the variable to set
1 str
The value to set
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.
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
The name of the type to check.
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
Returns true if the specified header is usable with the specified prefix, dependencies, and arguments.
POSARGS
The header to check.
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
Returns an array containing the command(s) for the compiler.
Returns true if the code compiles.
POSARGS
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.
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.
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
The expression to compute.
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
POSARGS
handlers dict[bool|function|list[str]]
libdirs listify[str]
overwrite bool
version str
Tries to find the library specified in the positional argument.
POSARGS
The library to find.
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.
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
The arguments to check.
Given an array of strings, returns the first argument that passes the [compiler.haslinkargument] test or an empty array if none pass.
POSARGS
The link arguments to check.
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.
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
The define to check.
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
Returns a string identifying the compiler. For example, gcc, msvc, [and more].
Returns a string identifying the linker. For example, ld.bfd, link, [and more].
Returns an array containing only the arguments supported by the compiler, as if [compiler.hasargument] were called on them individually.
POSARGS
The arguments to check.
Returns an array containing any names that are supported GCC style attributes. Equivalent to [compiler.hasfunctionattribute] was called on each of them individually.
POSARGS
Returns an array containing only the arguments supported by the compiler, as if [compiler.haslinkargument] were called on them individually.
POSARGS
The link arguments to check.
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
The argument to check.
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.
Returns true if the given preprocessor symbol is defined.
POSARGS
The define to check.
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
Returns true if the given function is provided by the standard library or a library passed in with the args keyword.
POSARGS
The function to check.
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
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
The attribute name to check.
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.
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
The header to check.
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
Detects whether a particular symbol is declared in the specified header.
Symbols here include function, variable, #define, type definition, etc.
POSARGS
The header to check.
1 str
The symbol to check.
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
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
The argument to check.
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.
Returns true if the type has the specified member.
POSARGS
The type to check.
1 str
The member to check.
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
Returns true if the type has all the specified members.
POSARGS
The type to check.
1 glob[str]
The members to check
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
the same as [compiler.hasargument] but takes multiple arguments and uses them all in a single compiler invocation.
POSARGS
The arguments to check.
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.
the same as [compiler.haslinkargument] but takes multiple arguments and uses them all in a single compiler invocation.
POSARGS
The link arguments to check.
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.
Returns true if the specified token is a type.
POSARGS
The type to check.
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
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
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.
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.
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
Input source to preprocess. The following types are supported:
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.
Attempts to compile and execute the given code fragment.
POSARGS
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.
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.
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
The type to compute.
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
Returns true if the C symbol mangling is one underscore (_) prefixed to the symbol.
Returns the compiler's version number as a string.
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().
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.
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.
Only for dependencies created with [declaredependency], returns a copy of the dependency object that prefer the shared version of [bothlibraries].
KWARGS
If true, this is recursively applied to dependencies
Only for dependencies created with [declaredependency], returns a copy of the dependency object that prefer the static version of [bothlibraries].
KWARGS
If true, this is recursively applied to dependencies
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
The new value. See [dependency] for supported values.
Returns whether the dependency was found.
Gets the command line argument from the config tool (with -- prepended), or, if invoked on a non config-tool dependency, error out.
POSARGS
Name of the variable to query
Gets the pkg-config variable specified, or, if invoked on a non pkg-config dependency, error out.
POSARGS
Name of the variable to query
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.
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
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').
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
Returns the value set by the include_type kwarg.
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
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:
KWARGS
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
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.
the version number as a string, for example 1.2.8. unknown if the dependency provider doesn't support determining the version.
Delete a key from a dictionary. Note that this mutates the underlying dictionary and also may reorder its keys.
POSARGS
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
The key to query.
1 any
Fallback value that is returned if the key is not in the [@dict].
Returns true if the dictionary contains the key given as argument, false otherwise.
POSARGS
The key to query.
Returns an array of keys in the dictionary, sorted in ascending order.
POSARGS
1 any
Returns an array of values in the dictionary, sorted by the corresponding keys in ascending order.
Always returns false
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
The variable to modify
1 glob[str]
The values to append
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.
Same as append except that it writes to the beginning of the variable.
POSARGS
The variable to modify
1 glob[str]
The values to prepend
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.
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
The variable to modify
1 glob[str]
The values to set
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.
Unset the specified environment variable. If this variable does not exist, nothing happens.
POSARGS
The name to unset
Returns an array containing the command(s) for the program.
Returns whether the executable was found.
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
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
The version number as a string, for example 1.2.8.
unknown if the program cannot determine the version via a --version argument.
Returns whether the feature was set to 'enabled' or 'auto'
Returns whether the feature was set to 'auto'
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
See the table above
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
The value to check
The error message to print if the check fails
Returns whether the feature was set to 'disabled'
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
See the table above
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
The value to check
The error message to print if the check fails
Returns whether the feature was set to 'enabled'
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
The value to check
The error message to print if the check fails
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.
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
sources to process.
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.
Returns true if the number is even.
Returns true if the number is odd
Returns the value of the number as a string.
KWARGS
Returns true if the array contains the object given as argument, false otherwise
POSARGS
The item to check
POSARGS
Returns a flattened copy of the array, with all nested arrays removed.
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
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.
Returns the current size of the array.
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
The lower bound of the slice
1 int
The upper bound of the slice
The step size
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
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.
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.
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
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.
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
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.
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.
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
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.
returns the argv[0] that was used to invoke muon itself
Returns a string representing the current backend:
Returns a string with the configuration line used to set the current project up.
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.
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.
Returns a string with the absolute path to the current build directory.
Returns a string to the current source directory.
POSARGS
1 module
Returns a [@compiler] object describing a compiler.
POSARGS
The language of the compiler to return.
See our [list of supported languages].
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.
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
Name of the property in the cross / native file.
1 any
Value to return if propname is not set in the machine file.
Returns the given property from a native or cross file. The optional fallbackvalue is returned if the given property is not found.
POSARGS
Name of the property in the cross / native file.
1 any
Value to return if propname is not set in the machine file.
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.
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].
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].
returns whether or not a compiler for the given language has been configured
POSARGS
Use [meson.canrunhostbinaries] instead.
Checks whether the given property exist in a native or cross file.
POSARGS
Name of the property in the cross / native file.
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.
Returns true if the current build is a [cross build] and false otherwise.
Returns true if the current project is being built as a subproject of some other project and false otherwise.
Returns true when doing a [unity build] (multiple sources are combined before compilation to reduce build time) and false otherwise.
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
The name of the dependency to override.
1 dep
The dependency to set as the override for name.
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.
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
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.
Controls whether the target is compiled for the build or host machines.
returns the path to muon's private directory in the build folder
return a dict containing read-only properties of the current project
Returns a string with the absolute path to the build root directory of the current (sub)project.
Returns the array of licenses specified in [project] function call.
Returns the array of license files specified in the [project] function call.
Returns the project name specified in the [project] function call.
Returns a string with the absolute path to the source root directory of the current (sub)project.
Returns the version string specified in [project] function call.
register custom callbacks to run when a specific dependency lookup is invoked
POSARGS
config_tool function
order listify[str]
pkgconfig function
system function
set properties to be accessed by meson.getcrossproperty() and meson.getexternalproperty()
POSARGS
set the value of an option as if it were set on the commandline
POSARGS
1 bool|feature|int|list|str
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.
Return a string with the version of Meson.
Returns true if the module was successfully imported, otherwise false.
KWARGS
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]
POSARGS
1 glob[both_libs|build_tgt|custom_tgt|file|generated_list|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
KWARGS
subdir str
POSARGS
1 str
POSARGS
1 any
POSARGS
POSARGS
POSARGS
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
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.
The return code of executing the compiled binary
The standard error produced when the command was run.
The standard out produced when the command was run.
POSARGS
if_true listify[custom_tgt|dep|file|generated_list|str]
when listify[dep|str]
POSARGS
when listify[dep|str]
POSARGS
Returns true if string contains the string specified as the argument.
POSARGS
The string fragment to check
Returns true if string ends with the string specified as the argument.
POSARGS
The string fragment to check
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
The string to format.
The formatting works by replacing placeholders of type @number@ with the corresponding varargs.
The opposite of split, for example '.'.join(['a', 'b', 'c']) yields 'a.b.c'.
POSARGS
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]].
Search all occurrences of old and replace it with new
POSARGS
The substring to search
1 str
The replacement string
KWARGS
KWARGS
Splits the string at the specified character (or whitespace if not set) and returns the parts in an array.
POSARGS
Specifies the character / substring where to split the string.
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.
Returns true if string starts with the string specified as the argument.
POSARGS
The string fragment to check
Removes leading/ending characters from the string.
By default the characters to remove are spaces and newlines.
POSARGS
Instead of whitespace, strip all the characters in this string.
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
The start position
1 int
The end position
Converts the string to an int and throws an error if it can't be
Converts all characters to lower case
Converts all characters to upper case
Creates a string where every non-alphabetical non-number character is replaced with _.
Does semantic version comparison.
POSARGS
The string to compare to.
Returns whether the subproject was successfully setup.
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
The name of the variable to query
1 any
The fallback value to return if var_name does not exist.
POSARGS
Fetch url(s) using libcurl. Only available if libcurl support is enabeld.
POSARGS
the url(s) to fetch
Batch size
progress bool|feature
Show progress output
Parse command line arguments using getopt. Returns the array of trailing positional args.
POSARGS
the array of arguments to parse
1 dict[dict]
A dict of opt -> handler.
- 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.
Parse a json string into an object
POSARGS
the json to parse
Convert an object into a json string
POSARGS
the object to stringify
Clean subprojects with .wrap files
POSARGS
A list of subprojects to operate on.
Force the operation.
Fetch a project using a .wrap file
POSARGS
The wrap file to fetch.
1 str
The directory to fetch into
List subprojects with .wrap files and their status.
POSARGS
A list of subprojects to operate on.
Print out a formatted list of subprojects as well as returning it.
Load a wrap file into a dict
POSARGS
The wrap file to load.
Update subprojects with .wrap files
POSARGS
A list of subprojects to operate on.
Fail if any update would have been skipped (e.g. if the destination is dirty).
POSARGS
POSARGS
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
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
Retrieve a previously defined handler
POSARGS
1 str
2 str
parse a target triple
POSARGS
Register a new static linker type
POSARGS
The id of this component
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.
Register a new compiler type
POSARGS
The id of this component
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.
Register a new linker type
POSARGS
The id of this component
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.
POSARGS
return a string representing the passed object
POSARGS
POSARGS
1 any
POSARGS
Append a suffix to a path
POSARGS
1 str
Convert backslashes to /
POSARGS
Make a path absolute and replace ..
POSARGS
Copy a file to a destination at configure time
POSARGS
1 str
Creates a custom target that copies a file at build time
POSARGS
1 str
install_dir listify[bool|str]
install_mode listify[bool|int|str]
install_tag str
Return the muon's current working directory
Recursively delete all files with a matching suffix
POSARGS
1 str
Prepend ./ to a path if it is a basename
POSARGS
Check if a file or directory exists
POSARGS
Expand a path that starts with a ~ into an absolute path
POSARGS
Gather a list of files matching a glob expression
POSARGS
Calculate the content hash of a file
POSARGS
1 str
Check if a path is absolute
POSARGS
Check if a path is a basename
POSARGS
Check if a directory exists
POSARGS
Check if a file exists
POSARGS
Check if two paths point to the same object
POSARGS
1 file|str
Check if a path is a subpath of another path
POSARGS
1 str
Check if a symlink exists
POSARGS
Make a path absolute by prepending the current working directory
POSARGS
Create a directory
POSARGS
Get the basename of a path
POSARGS
Get the dirname of a path
POSARGS
Read a file from disk
POSARGS
Get a path relative to another path
POSARGS
1 both_libs|build_tgt|custom_tgt|file|str
Replace a path's suffix
POSARGS
1 str
Remove a directory
POSARGS
recursive bool
Get a file's size in bytes
POSARGS
Get the basename of a path with its extension removed
POSARGS
The last dot-separated portion of the final component, if any
POSARGS
Get a path with its extension removed
POSARGS
Write a file
POSARGS
1 str
POSARGS
1 custom_tgt|file|generated_list|str
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]
POSARGS
KWARGSdepend_files listify[file|list[file|str]|str]
POSARGS
1 glob[custom_tgt|file|generated_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]
POSARGS
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]
POSARGS
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
POSARGS
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
POSARGS
decorator str
function_prefix str
header_prefix str
identifier_prefix str
install_dir str
install_header bool
sources listify[file|str]
symbol_prefix str
POSARGS
KWARGSglib_compile_schemas bool
gtk_update_icon_cache bool
update_desktop_database bool
update_mime_database bool
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
the name of the gettext module
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'
This joins translations into a XML file using itstool
POSARGS
KWARGSsame 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
This merges translations into a text file using msgfmt.
POSARGS
KWARGSlist 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'
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
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.
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.
POSARGS
POSARGS
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
POSARGS
flags_key str
static bool
POSARGS
modules listify[str]
pure bool
required bool|feature
POSARGS
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
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.
Find a wayland protocol file
POSARGS
The protocol name
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.
Run wayland scanner to generate files based on a protocol
POSARGS
List of protocol files to process
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.
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
windows resource files
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 |