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