From 2fd838d62dc16af0687b4be7da4ffb28cb6a9725 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 22 May 2020 14:59:00 +0200 Subject: boost: Try extracting BOOST_ROOT from boost.pc This is especially useful for Conan, where only the boost.pc file is provided and manually setting BOOST_ROOT is not a good solution since it is in a private cache directory. See #5438 --- mesonbuild/dependencies/boost.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 3849704..907c0c2 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -22,7 +22,7 @@ from .. import mlog from .. import mesonlib from ..environment import Environment -from .base import (DependencyException, ExternalDependency) +from .base import DependencyException, ExternalDependency, PkgConfigDependency from .misc import threads_factory # On windows 3 directory layouts are supported: @@ -605,6 +605,17 @@ class BoostDependency(ExternalDependency): roots += paths return roots # Do not add system paths if BOOST_ROOT is present + # Try getting the BOOST_ROOT from a boost.pc if it exists. This primarely + # allows BoostDependency to find boost from Conan. See #5438 + try: + boost_pc = PkgConfigDependency('boost', self.env, {'required': False}) + if boost_pc.found(): + boost_root = boost_pc.get_pkgconfig_variable('prefix', {'default': None}) + if boost_root: + roots += [Path(boost_root)] + except DependencyException: + pass + # Add roots from system paths inc_paths = [Path(x) for x in self.clib_compiler.get_default_include_dirs()] inc_paths = [x.parent for x in inc_paths if x.exists()] -- cgit v1.1