From 398aed6e4991016c0bba4ee829bf65f98f1a6447 Mon Sep 17 00:00:00 2001 From: Nikita Churaev Date: Tue, 9 Jan 2018 22:32:25 +0300 Subject: [PATCH] Don't fail if we find an optional dependency but not the required information (#2652) --- mesonbuild/dependencies/base.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 46cce4339..b8787cccf 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -400,11 +400,22 @@ class PkgConfigDependency(ExternalDependency): m = 'Invalid version of dependency, need {!r} {!r} found {!r}.' raise DependencyException(m.format(name, not_found, self.version)) return - found_msg += [mlog.green('YES'), self.version] - # Fetch cargs to be used while using this dependency - self._set_cargs() - # Fetch the libraries and library paths needed for using this - self._set_libs() + + try: + # Fetch cargs to be used while using this dependency + self._set_cargs() + # Fetch the libraries and library paths needed for using this + self._set_libs() + found_msg += [mlog.green('YES'), self.version] + except DependencyException as e: + if self.required: + raise + else: + self.compile_args = [] + self.link_args = [] + self.is_found = False + found_msg += [mlog.red('NO'), '; reason: {}'.format(str(e))] + # Print the found message only at the very end because fetching cflags # and libs can also fail if other needed pkg-config files aren't found. if not self.silent: