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 | |
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')
-rw-r--r-- | docs/markdown/Reference-manual.md | 5 | ||||
-rw-r--r-- | docs/markdown/snippets/static_fallback_override.md | 46 |
2 files changed, 51 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index fd156f9..8ef36de 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -568,6 +568,8 @@ This function supports the following keyword arguments: - `static`: tells the dependency provider to try to get static libraries instead of dynamic ones (note that this is not supported by all dependency backends) + *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. - `version` *(since 0.37.0)*: 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. @@ -2151,6 +2153,9 @@ the following methods. `native` keyword arguments. 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)`. + *Since 0.60.0* `static` boolean keyword argument can be specified to override + static and/or shared dependencies separately. If not specified it is assumed + `dep_object` follows `default_library` option value. - `project_version()`: returns the version string specified in `project` function call. 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'])`. |