William A. Kennington III | a8f5911 | 2021-04-20 16:21:25 -0700 | [diff] [blame] | 1 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock = dependency('gmock', disabler: true, required: false) |
| 3 | if not gtest.found() or not gmock.found() |
| 4 | gtest_opts = import('cmake').subproject_options() |
| 5 | gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'}) |
| 6 | gtest_proj = import('cmake').subproject( |
| 7 | 'googletest', |
| 8 | options: gtest_opts, |
| 9 | required: false) |
| 10 | if gtest_proj.found() |
| 11 | gtest = declare_dependency( |
| 12 | dependencies: [ |
| 13 | dependency('threads'), |
| 14 | gtest_proj.dependency('gtest'), |
| 15 | gtest_proj.dependency('gtest_main'), |
| 16 | ]) |
| 17 | gmock = gtest_proj.dependency('gmock') |
| 18 | else |
| 19 | assert(not build_tests.enabled(), 'Googletest is required') |
| 20 | endif |
| 21 | endif |
| 22 | |
William A. Kennington III | b933771 | 2019-01-15 18:27:13 -0800 | [diff] [blame] | 23 | |
| 24 | tests = [ |
| 25 | 'watchdog', |
| 26 | ] |
| 27 | |
| 28 | foreach t : tests |
William A. Kennington III | 0b3c389 | 2021-04-20 16:00:55 -0700 | [diff] [blame] | 29 | test( |
| 30 | t, |
| 31 | executable( |
| 32 | t.underscorify(), |
| 33 | t + '.cpp', |
| 34 | implicit_include_directories: false, |
William A. Kennington III | 080ffd7 | 2021-04-20 16:45:24 -0700 | [diff] [blame] | 35 | dependencies: [watchdog_dep, gtest, gmock])) |
William A. Kennington III | b933771 | 2019-01-15 18:27:13 -0800 | [diff] [blame] | 36 | endforeach |