From 4f6a57a138e901084f8f0f638e04be2e0a2b37b0 Mon Sep 17 00:00:00 2001 From: Benjamin Redelings Date: Sat, 30 Dec 2017 10:52:50 -0800 Subject: [PATCH] Use new strategy for finding libraries on Linux & Mac. --- mesonbuild/dependencies/misc.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 926be5b94..7f4c52a03 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -80,6 +80,21 @@ from .base import ( # Furthermore, the boost documentation for unix above uses examples from windows like # "libboost_regex-vc71-mt-d-x86-1_34.lib", so apparently the abi tags may be more aimed at windows. # +# Probably we should use the linker search path to decide which libraries to use. This will +# make it possible to find the macports boost libraries without setting BOOST_ROOT, and will +# also mean that it would be possible to use user-installed boost libraries when official +# packages are installed. +# +# We thus follow the following strategy: +# 1. Look for libraries using compiler.find_library( ) +# 1.1 On Linux, just look for boost_ +# 1.2 On other systems (e.g. Mac) look for boost_-mt if multithreading. +# 1.3 Otherwise look for boost_ +# 2. Fall back to previous approach +# 2.1. Search particular directories. +# 2.2. Find boost libraries with unknown suffixes using file-name globbing. + + class BoostDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('boost', environment, 'cpp', kwargs) @@ -343,6 +358,24 @@ class BoostDependency(ExternalDependency): self.lib_modules[self.modname_from_filename(fname)] = [fname] def detect_lib_modules_nix(self): + all_found = True + for module in self.requested_modules: + args = None + libname = 'boost_'+module + if self.is_multithreading and not mesonlib.for_linux(self.want_cross, self.env): + # - Linux leaves off -mt but libraries are multithreading-aware. + # - Mac requires -mt for multithreading, so should not fall back to non-mt libraries. + libname = libname + '-mt' + args = self.compiler.find_library(libname, self.env, self.extra_lib_dirs()) + if args is None: + mlog.debug('Couldn\'t find library "{}" for boost module "{}"'.format(module, libname)) + all_found = False + else: + mlog.debug('Link args for boost module "{}" are {}'.format(module, args)) + self.lib_modules['boost_' + module] = args + if all_found: + return + if self.static: libsuffix = 'a' elif mesonlib.is_osx() and not self.want_cross: