blob: 2cadb5c544500b99124ff6e3c12e21036230a5f3 [file] [log] [blame]
Jason M. Billsd6087ae2023-10-09 11:54:13 -07001gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2gmock_dep = dependency('gmock', disabler: true, required: false)
3if not gtest_dep.found() or not gmock_dep.found()
4 gtest_proj = import('cmake').subproject('googletest', required: false)
5 if gtest_proj.found()
6 gtest_dep = declare_dependency(
7 dependencies: [
8 dependency('threads'),
9 gtest_proj.dependency('gtest'),
10 gtest_proj.dependency('gtest_main'),
Jason M. Bills28836072024-05-17 12:47:15 -070011 ],
Jason M. Billsd6087ae2023-10-09 11:54:13 -070012 )
13 gmock_dep = gtest_proj.dependency('gmock')
Jason M. Bills28836072024-05-17 12:47:15 -070014 else
Jason M. Billsd6087ae2023-10-09 11:54:13 -070015 assert(
16 not get_option('tests').enabled(),
Jason M. Bills28836072024-05-17 12:47:15 -070017 'Googletest is required if tests are enabled',
Jason M. Billsd6087ae2023-10-09 11:54:13 -070018 )
Jason M. Bills28836072024-05-17 12:47:15 -070019 endif
Jason M. Billsd6087ae2023-10-09 11:54:13 -070020endif
21
Jason M. Bills28836072024-05-17 12:47:15 -070022unit_tests = []
Jason M. Billsd6087ae2023-10-09 11:54:13 -070023
24if get_option('tests').enabled()
25 # generate the test executable
26 foreach unit_test : unit_tests
Jason M. Bills28836072024-05-17 12:47:15 -070027 test(
Jason M. Billsd6087ae2023-10-09 11:54:13 -070028 unit_test,
Jason M. Bills28836072024-05-17 12:47:15 -070029 executable(
30 unit_test,
31 unit_test + '.cpp',
Jason M. Bills5fe348b2024-05-15 09:13:26 -070032 '../src/host_error_monitor.cpp',
33 cpp_args: '-DUNIT_TEST',
Jason M. Bills28836072024-05-17 12:47:15 -070034 include_directories: incs,
35 dependencies: deps
36 + [
37 gtest_dep,
38 gmock_dep,
39 ],
40 ),
Jason M. Billsd6087ae2023-10-09 11:54:13 -070041 )
42 endforeach
Jason M. Bills28836072024-05-17 12:47:15 -070043endif