From 9154a6473b28f4cb60d23a7bc15ab8b1d223c1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wikli=C5=84ski?= Date: Sat, 19 Aug 2017 03:13:29 +0200 Subject: [PATCH] Find Boost dep when there is an extra lib to link There are several components in Boost which must be linked with extra libraries. Boost Log is one of them and in special circumstances needs linking with boost_log_setup. http://www.boost.org/doc/libs/1_64_0/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.setup This fix covers the case when there is no source file corresponding to the additional library. --- mesonbuild/dependencies/misc.py | 2 +- test cases/frameworks/1 boost/extralib.cpp | 25 ++++++++++++++++++++++ test cases/frameworks/1 boost/meson.build | 7 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test cases/frameworks/1 boost/extralib.cpp diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index e9effc608..0112fd3cf 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -142,7 +142,7 @@ class BoostDependency(ExternalDependency): def validate_requested(self): for m in self.requested_modules: - if m not in self.src_modules: + if m not in self.src_modules and m not in self.lib_modules and m + '-mt' not in self.lib_modules_mt: msg = 'Requested Boost module {!r} not found' raise DependencyException(msg.format(m)) diff --git a/test cases/frameworks/1 boost/extralib.cpp b/test cases/frameworks/1 boost/extralib.cpp new file mode 100644 index 000000000..6a3e9e4d1 --- /dev/null +++ b/test cases/frameworks/1 boost/extralib.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +using namespace std; +namespace logging = boost::log; + +void InitLogger() { + logging::add_common_attributes(); + logging::register_simple_formatter_factory("Severity"); + string log_format = "%TimeStamp% [%Severity%] - %Message%"; + + logging::add_console_log( + cout, + logging::keywords::format = log_format + ); +} + +int main(int argc, char **argv) { + InitLogger(); + BOOST_LOG_TRIVIAL(trace) << "SOMETHING"; + return 0; +} diff --git a/test cases/frameworks/1 boost/meson.build b/test cases/frameworks/1 boost/meson.build index 338dd78ec..6f25f8bb2 100644 --- a/test cases/frameworks/1 boost/meson.build +++ b/test cases/frameworks/1 boost/meson.build @@ -1,6 +1,10 @@ project('boosttest', 'cpp', default_options : ['cpp_std=c++11']) +add_project_arguments(['-DBOOST_LOG_DYN_LINK'], + language : 'cpp' +) + # We want to have multiple separate configurations of Boost # within one project. The need to be independent of each other. # Use one without a library dependency and one with it. @@ -10,15 +14,18 @@ linkdep = dependency('boost', modules : ['thread', 'system']) staticdep = dependency('boost', modules : ['thread', 'system'], static : true) testdep = dependency('boost', modules : 'test') nomoddep = dependency('boost') +extralibdep = dependency('boost', modules : ['thread', 'system', 'log_setup', 'log']) nolinkexe = executable('nolinkedexe', 'nolinkexe.cc', dependencies : nolinkdep) linkexe = executable('linkedexe', 'linkexe.cc', dependencies : linkdep) staticexe = executable('staticlinkedexe', 'linkexe.cc', dependencies : staticdep) unitexe = executable('utf', 'unit_test.cpp', dependencies: testdep) nomodexe = executable('nomod', 'nomod.cpp', dependencies : nomoddep) +extralibexe = executable('extralibexe', 'extralib.cpp', dependencies : extralibdep) test('Boost nolinktest', nolinkexe) test('Boost linktest', linkexe) test('Boost statictest', staticexe) test('Boost UTF test', unitexe) test('Boost nomod', nomodexe) +test('Boost extralib test', extralibexe)