Skip to content

Commit 8d15921

Browse files
meson: add option to disable tests (#78)
1 parent 3141a2c commit 8d15921

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

meson.build

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
# Copyright (c) 2019 Maxim Egorushkin. MIT License. See the full licence in file LICENSE.
22

3-
# (rm -rf build; meson build; cd build; time ninja -v)
3+
# (rm -rf build; meson setup build; time ninja -C build -v)
44

55
project(
66
'atomic_queue', 'cpp',
77
license : 'MIT License',
88
default_options : ['cpp_std=gnu++14', 'buildtype=release', 'b_ndebug=if-release']
99
)
1010

11-
cxx = meson.get_compiler('cpp')
12-
dl = cxx.find_library('dl', required : true)
13-
threads = dependency('threads')
14-
unit_test_framework = dependency('boost', modules : ['unit_test_framework'])
15-
if get_option('benchmarks')
16-
tbb = cxx.find_library('tbb', required : true)
17-
xenium = declare_dependency(include_directories : '../xenium')
18-
moodycamel = declare_dependency(include_directories : '../')
19-
endif
11+
threads_dep = dependency('threads')
2012

21-
atomic_queue = declare_dependency(include_directories : ['include'], dependencies : threads)
13+
atomic_queue_dep = declare_dependency(include_directories : ['include'], dependencies : threads_dep)
2214

23-
tests_exe = executable(
24-
'tests',
25-
'src/tests.cc',
26-
dependencies : [atomic_queue, unit_test_framework]
27-
)
28-
test('tests', tests_exe)
15+
if get_option('tests')
16+
unit_test_framework_dep = dependency('boost', modules : ['unit_test_framework'])
2917

30-
example_exe = executable(
31-
'example',
32-
'src/example.cc',
33-
dependencies : [atomic_queue]
34-
)
18+
tests_exe = executable(
19+
'tests',
20+
'src/tests.cc',
21+
dependencies : [atomic_queue_dep, unit_test_framework_dep],
22+
)
23+
test('tests', tests_exe)
24+
25+
example_exe = executable(
26+
'example',
27+
'src/example.cc',
28+
dependencies : [atomic_queue_dep],
29+
)
30+
test('example', example_exe)
31+
endif
3532

3633
if get_option('benchmarks')
37-
benchmarks_exe = executable(
34+
cxx = meson.get_compiler('cpp')
35+
dl_dep = cxx.find_library('dl')
36+
xenium_dep = declare_dependency(include_directories : '../xenium')
37+
boost_dep = dependency('boost')
38+
tbb_dep = cxx.find_library('tbb')
39+
moodycamel_dep = declare_dependency(include_directories : '../')
40+
41+
executable(
3842
'benchmarks',
3943
['src/benchmarks.cc', 'src/cpu_base_frequency.cc', 'src/huge_pages.cc'],
40-
dependencies : [atomic_queue, xenium, moodycamel, tbb, dl]
44+
include_directories : ['src'],
45+
dependencies : [atomic_queue_dep, dl_dep, xenium_dep, boost_dep, tbb_dep, moodycamel_dep],
4146
)
4247
endif

meson_options.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
option('benchmarks', type : 'boolean', value : true,
2-
description : 'Do not build benchmarks; ignore their dependencies')
2+
description : 'Build benchmarks (requires Boost, TBB, Xenium and moodycamel)')
3+
option('tests', type : 'boolean', value : true,
4+
description : 'Build tests and example (requires Boost)')

0 commit comments

Comments
 (0)