diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-08-04 11:30:27 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-08-23 10:52:18 -0400 |
commit | e646130ef1a703a3624cff4ca11f926703a6fcf4 (patch) | |
tree | afc6527bdd1e01de853fa4ecdab66ee2a8baf75b /docs/markdown/snippets | |
parent | 0063eb251e836e777b427cbe59b43ab937ac1924 (diff) | |
download | meson-e646130ef1a703a3624cff4ca11f926703a6fcf4.zip meson-e646130ef1a703a3624cff4ca11f926703a6fcf4.tar.gz meson-e646130ef1a703a3624cff4ca11f926703a6fcf4.tar.bz2 |
interpreter: Fix dependency(..., static: true) fallback
It should build the fallback subprject with default_library=static and
override the dependency for both static=True and static kwarg not given.
Fixes: #8050.
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r-- | docs/markdown/snippets/static_fallback_override.md | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/docs/markdown/snippets/static_fallback_override.md b/docs/markdown/snippets/static_fallback_override.md new file mode 100644 index 0000000..1a6faaf --- /dev/null +++ b/docs/markdown/snippets/static_fallback_override.md @@ -0,0 +1,46 @@ +## `static` keyword argument to `meson.override_dependency()` + +It is now possible to override shared and/or static dependencies separately. +When the `static` keyword argument is not specified in `dependency()`, the first +override will be used (`static_dep` in the example below). +```meson +static_lib = static_library() +static_dep = declare_dependency(link_with: static_lib) +meson.override_dependency('foo', static_dep, static: true) + +shared_lib = shared_library() +shared_dep = declare_dependency(link_with: shared_lib) +meson.override_dependency('foo', shared_dep, static: false) + +# Returns static_dep +dependency('foo') + +# Returns static_dep +dependency('foo', static: true) + +# Returns shared_dep +dependency('foo', static: false) +``` + +When the `static` keyword argument is not specified in `meson.override_dependency()`, +the dependency is assumed to follow the value of `default_library` option. +```meson +dep = declare_dependency(...) +meson.override_dependency('foo', dep) + +# Always works +dependency('foo') + +# Works only if default_library is 'static' or 'both' +dependency('foo', static: true) + +# Works only if default_library is 'shared' or 'both' +dependency('foo', static: false) +``` + +## `dependency()` sets `default_library` on fallback subproject + +When the `static` keyword argument is set but `default_library` is missing in +`default_options`, `dependency()` will set it when configuring fallback +subproject. `dependency('foo', static: true)` is now equivalent to +`dependency('foo', static: true, default_options: ['default_library=static'])`. |