diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-04-15 16:42:21 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-01 09:51:57 -0400 |
commit | 288d1ae5a5de13c8844635023caf27378df4919b (patch) | |
tree | d31d973fff07d6b9181959ff15104bc7573f4a30 | |
parent | 71804e56eb3612eabc51887fe4d46961684a3ecc (diff) | |
download | meson-288d1ae5a5de13c8844635023caf27378df4919b.zip meson-288d1ae5a5de13c8844635023caf27378df4919b.tar.gz meson-288d1ae5a5de13c8844635023caf27378df4919b.tar.bz2 |
wrap: Do not fallback implicitly on optional dependency
This fix the following common pattern, we don't want to implicitly
fallback on the first line:
foo_dep = dependency('foo', required: false)
if not foo_dep.found()
foo_dep = cc.find_library('foo', required : false)
if not foo_dep.found()
foo_dep = dependency('foo', fallback: 'foo')
endif
endif
-rw-r--r-- | mesonbuild/interpreter.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7c55932..89c9daa 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3552,8 +3552,11 @@ external dependencies (including libraries) must go to "dependencies".''') return self.notfound_dependency() has_fallback = 'fallback' in kwargs - if not has_fallback and name: - # Add an implicit fallback if we have a wrap file or a directory with the same name. + if not has_fallback and name and required: + # Add an implicit fallback if we have a wrap file or a directory with the same name, + # but only if this dependency is required. It is common to first check for a pkg-config, + # then fallback to use find_library() and only afterward check again the dependency + # with a fallback. provider = self.environment.wrap_resolver.find_provider(name) if provider: kwargs['fallback'] = provider |