William A. Kennington III | bb25973 | 2021-05-05 12:35:01 -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 |
Patrick Williams | 58bd8ba | 2023-11-29 06:44:49 -0600 | [diff] [blame] | 19 | assert(not get_option('tests').allowed(), 'Googletest is required') |
William A. Kennington III | bb25973 | 2021-05-05 12:35:01 -0700 | [diff] [blame] | 20 | endif |
| 21 | endif |
| 22 | |
| 23 | tests = [ |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 24 | 'average_unittest', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 25 | 'env_unittest', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 26 | 'fanpwm_unittest', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 27 | 'hwmon_unittest', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 28 | 'hwmonio_default_unittest', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 29 | 'sensor_unittest', |
William A. Kennington III | bb25973 | 2021-05-05 12:35:01 -0700 | [diff] [blame] | 30 | ] |
| 31 | |
| 32 | foreach t : tests |
| 33 | test( |
| 34 | t, |
| 35 | executable( |
| 36 | t.underscorify(), |
| 37 | t + '.cpp', |
| 38 | 'gpio.cpp', |
| 39 | implicit_include_directories: false, |
| 40 | dependencies: [hwmon_dep, gtest, gmock])) |
| 41 | endforeach |