1# this test requires the following on Ubuntu: libboost-{system,python,log,thread,test}-dev 2project('boosttest', 'cpp', 3 default_options : ['cpp_std=c++14']) 4 5s = get_option('static') 6 7dep = dependency('boost', static: s, required: false) 8if not dep.found() 9 error('MESON_SKIP_TEST boost not found.') 10endif 11 12# We want to have multiple separate configurations of Boost 13# within one project. The need to be independent of each other. 14# Use one without a library dependency and one with it. 15 16linkdep = dependency('boost', static: s, modules : ['thread', 'system', 'date_time']) 17testdep = dependency('boost', static: s, modules : ['unit_test_framework']) 18nomoddep = dependency('boost', static: s) 19extralibdep = dependency('boost', static: s, modules : ['thread', 'system', 'date_time', 'log_setup', 'log', 'filesystem', 'regex']) 20notfound = dependency('boost', static: s, modules : ['this_should_not_exist_on_any_systen'], required: false) 21 22assert(not notfound.found()) 23 24pymod = import('python') 25python2 = pymod.find_installation('python2', required: false , disabler: true) 26python3 = pymod.find_installation('python3', required: host_machine.system() == 'linux', disabler: true) 27python2dep = python2.dependency(required: false , embed: true, disabler: true) 28python3dep = python3.dependency(required: host_machine.system() == 'linux', embed: true, disabler: true) 29 30# compile python 2/3 modules only if we found a corresponding python version 31if(python2dep.found() and host_machine.system() == 'linux' and not s) 32 bpython2dep = dependency('boost', static: s, modules : ['python'], required: false, disabler: true) 33else 34 python2dep = disabler() 35 bpython2dep = disabler() 36endif 37 38if(python3dep.found() and host_machine.system() == 'linux' and not s) 39 bpython3dep = dependency('boost', static: s, modules : ['python3']) 40else 41 python3dep = disabler() 42 bpython3dep = disabler() 43endif 44 45linkexe = executable('linkedexe', 'linkexe.cc', dependencies : linkdep) 46unitexe = executable('utf', 'unit_test.cpp', dependencies: testdep) 47nomodexe = executable('nomod', 'nomod.cpp', dependencies : nomoddep) 48extralibexe = executable('extralibexe', 'extralib.cpp', dependencies : extralibdep) 49 50# python modules are shared libraries 51python2module = shared_library('python2_module', ['python_module.cpp'], dependencies: [python2dep, bpython2dep], name_prefix: '', cpp_args: ['-DMOD_NAME=python2_module']) 52python3module = shared_library('python3_module', ['python_module.cpp'], dependencies: [python3dep, bpython3dep], name_prefix: '', cpp_args: ['-DMOD_NAME=python3_module']) 53 54test('Boost linktest', linkexe, timeout: 60) 55test('Boost UTF test', unitexe, timeout: 60) 56test('Boost nomod', nomodexe) 57if host_machine.system() != 'darwin' or s 58 # Segfaults on macOS with dynamic linking since Boost 1.73 59 # https://github.com/mesonbuild/meson/issues/7535 60 test('Boost extralib test', extralibexe) 61endif 62 63# explicitly use the correct python interpreter so that we don't have to provide two different python scripts that have different shebang lines 64python2interpreter = find_program(python2.path(), required: false, disabler: true) 65test('Boost Python2', python2interpreter, args: ['./test_python_module.py', meson.current_build_dir()], workdir: meson.current_source_dir(), depends: python2module) 66python3interpreter = find_program(python3.path(), required: false, disabler: true) 67test('Boost Python3', python3interpreter, args: ['./test_python_module.py', meson.current_build_dir()], workdir: meson.current_source_dir(), depends: python3module) 68 69subdir('partial_dep') 70 71# check we can apply a version constraint 72dependency('boost', static: s, version: '>=@0@'.format(dep.version())) 73