aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/Wrap-dependency-system-manual.md
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-10-08 12:05:51 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-10-08 12:24:07 +0200
commit726b82205492a9e1f2dfd0fba96b237b51eeb428 (patch)
treedf49508fe8547d69b232e90fa2cf6fc17dcc8b2b /docs/markdown/Wrap-dependency-system-manual.md
parent1eec5cf41f905c988af4be003a03d29fca7baef4 (diff)
downloadmeson-726b82205492a9e1f2dfd0fba96b237b51eeb428.zip
meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.gz
meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.bz2
dependency: support boolean argument "allow_fallback"
Sometimes, distros want to configure a project so that it does not use any bundled library. In this case, meson.build might want to do something like this, where slirp is a combo option with values auto/system/internal: slirp = dependency('', required: false) if get_option('slirp') != 'internal' slirp = dependency('slirp', required: get_option('slirp') == 'system') endif if not slirp.found() slirp = subproject('libslirp', ...) .variable('...') endif and we cannot use "fallback" because the "system" value should never look for a subproject. This worked until 0.54.x, but in 0.55.x this breaks because of the automatic subproject search. Note that the desired effect here is backwards compared to the policy of doing an automatic search on "required: true"; we only want to do the search if "required" is false! It would be possible to look for the dependency with `required: false` and issue the error manually, but it's ugly and it may produce an error message that looks "different" from Meson's. Instead, with this change it is possible to achieve this effect in an even simpler way: slirp = dependency('slirp', required: get_option('slirp') != 'auto', allow_fallback: get_option('slirp') == 'system' ? false : ['slirp', 'libslirp_dep']) The patch also adds support for "allow_fallback: true", which is simple and enables automatic fallback to a wrap even for non-required dependencies.
Diffstat (limited to 'docs/markdown/Wrap-dependency-system-manual.md')
-rw-r--r--docs/markdown/Wrap-dependency-system-manual.md10
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md
index 8e6282e..4189709 100644
--- a/docs/markdown/Wrap-dependency-system-manual.md
+++ b/docs/markdown/Wrap-dependency-system-manual.md
@@ -182,10 +182,12 @@ endif
`dependency('foo-1.0', required: get_option('foo_opt'))` will only fallback
when the user sets `foo_opt` to `enabled` instead of `auto`.
-If it is desired to fallback for an optional dependency, the `fallback` keyword
-argument must be passed explicitly. For example
-`dependency('foo-1.0', required: get_option('foo_opt'), fallback: 'foo')` will
-use the fallback even when `foo_opt` is set to `auto`.
+If it is desired to fallback for an optional dependency, the `fallback`
+or `allow_fallback` keyword arguments must be passed explicitly. *Since
+0.56.0*, `dependency('foo-1.0', required: get_option('foo_opt'),
+allow_fallback: true)` will use the fallback even when `foo_opt` is set
+to `auto`. On version *0.55.0* the same effect could be achieved with
+`dependency('foo-1.0', required: get_option('foo_opt'), fallback: 'foo')`.
This mechanism assumes the subproject calls `meson.override_dependency('foo-1.0', foo_dep)`
so Meson knows which dependency object should be used as fallback. Since that