blob: 7462334871912fd1dc81b1e8b38c36ef9a7fa4eb [file] [log] [blame]
Patrick Williamsc3ab4172025-02-01 08:38:42 -05001gtest = dependency(
2 'gtest',
3 main: true,
4 disabler: true,
5 required: get_option('tests'),
6)
kasunath7ffd30a2022-05-10 18:11:34 -07007gmock = dependency('gmock', disabler: true, required: get_option('tests'))
8
9if not gtest.found() or not gmock.found()
Patrick Williamsc3ab4172025-02-01 08:38:42 -050010 gtest_proj = import('cmake').subproject('googletest', required: false)
11 if gtest_proj.found()
12 gtest = declare_dependency(
13 dependencies: [
14 gtest_proj.dependency('gtest'),
15 gtest_proj.dependency('gtest_main'),
16 ],
17 )
18 gmock = gtest_proj.dependency('gmock')
19 else
20 assert(not get_option('tests').allowed(), 'Googletest is required')
21 endif
kasunath7ffd30a2022-05-10 18:11:34 -070022endif
23
24gtests = [
Patrick Williamsc3ab4172025-02-01 08:38:42 -050025 'bej_decoder',
26 'bej_common',
27 'bej_dictionary',
28 'bej_tree',
29 'bej_encoder',
kasunath7ffd30a2022-05-10 18:11:34 -070030]
Nikhil Namjoshida6e5572023-03-13 10:52:53 -070031
Konstantin Aladyshev2bc745a2024-04-01 17:13:40 +030032nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
33
Nikhil Namjoshida6e5572023-03-13 10:52:53 -070034libbej_test_incs = include_directories('include')
kasunath7ffd30a2022-05-10 18:11:34 -070035foreach t : gtests
Patrick Williamsc3ab4172025-02-01 08:38:42 -050036 test(
37 t,
38 executable(
39 t.underscorify(),
40 t + '_test.cpp',
41 build_by_default: false,
42 implicit_include_directories: false,
43 include_directories: libbej_test_incs,
44 dependencies: [libbej, gtest, gmock, nlohmann_json_dep],
45 ),
46 )
kasunath7ffd30a2022-05-10 18:11:34 -070047endforeach