Skip to content

Commit ad614db

Browse files
author
Raghuveer Devulapalli
committed
Build tests and benchmarks only if configured in meson
1 parent 207e3f2 commit ad614db

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
meson:
2-
meson setup --warnlevel 2 --werror --buildtype release builddir
2+
meson setup -Dbuild_tests=true -Dbuild_benchmarks=true --warnlevel 2 --werror --buildtype release builddir
33
cd builddir && ninja
44

55
mesondebug:
6-
meson setup --warnlevel 2 --werror --buildtype debug debug
6+
meson setup -Dbuild_tests=true -Dbuild_benchmarks=true --warnlevel 2 --werror --buildtype debug debug
77
cd debug && ninja
88

99
clean:
10-
$(RM) -rf $(TESTOBJS) $(BENCHOBJS) $(UTILOBJS) testexe benchexe builddir
10+
$(RM) -rf $(TESTOBJS) $(BENCHOBJS) $(UTILOBJS) testexe benchexe builddir debug

meson.build

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ lib = include_directories('lib')
88
bench = include_directories('benchmarks')
99
utils = include_directories('utils')
1010
tests = include_directories('tests')
11-
gtest_dep = dependency('gtest_main', required : false, static: false)
12-
gbench_dep = dependency('benchmark', required : false, static: false)
1311

1412
fp16code = '''#include<immintrin.h>
1513
int main() {
@@ -29,7 +27,9 @@ libsimdsort = shared_library('x86simdsort',
2927
cpp_args : [flags_hide_symbols],
3028
)
3129

32-
if gtest_dep.found()
30+
# Build test suite if option build_tests set to true
31+
if get_option('build_tests')
32+
gtest_dep = dependency('gtest_main', required : true, static: false)
3333
subdir('tests')
3434
testexe = executable('testexe',
3535
include_directories : [lib, utils],
@@ -39,7 +39,9 @@ if gtest_dep.found()
3939
)
4040
endif
4141

42-
if gbench_dep.found()
42+
# Build benchmarking suite if option build_benchmarks is set to true
43+
if get_option('build_benchmarks')
44+
gbench_dep = dependency('benchmark', required : true, static: false)
4345
subdir('benchmarks')
4446
benchexe = executable('benchexe',
4547
include_directories : [src, lib, utils, bench],
@@ -52,8 +54,8 @@ endif
5254

5355
summary({
5456
'Can compile AVX-512 FP16 ISA': cancompilefp16,
55-
'Built test content': gtest_dep.found(),
56-
'Built benchmarks': gbench_dep.found(),
57+
'Build test content': get_option('build_tests'),
58+
'Build benchmarks': get_option('build_benchmarks'),
5759
},
5860
section: 'Configuration',
5961
bool_yn: true

meson_options.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
option('buildtests', type : 'boolean', value : false, description : 'Build test suite (default: "false").')
2-
option('buildbenchmarks', type : 'boolean', value : false, description : 'Build benchmarking suite (default: "false").')
1+
option('build_tests', type : 'boolean', value : false,
2+
description : 'Build test suite (default: "false").')
3+
option('build_benchmarks', type : 'boolean', value : false,
4+
description : 'Build benchmarking suite (default: "false").')

0 commit comments

Comments
 (0)