Brandon Kim | 0d13663 | 2022-07-14 00:06:09 +0000 | [diff] [blame] | 1 | gtest = dependency('gtest', main: true, disabler: true, required: get_option('tests')) |
| 2 | gmock = dependency('gmock', disabler: true, required: get_option('tests')) |
| 3 | |
| 4 | if not gtest.found() or not gmock.found() |
| 5 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 6 | if gtest_proj.found() |
| 7 | gtest = declare_dependency( |
| 8 | dependencies: [ |
| 9 | gtest_proj.dependency('gtest'), |
| 10 | gtest_proj.dependency('gtest_main'), |
| 11 | ]) |
| 12 | gmock = gtest_proj.dependency('gmock') |
| 13 | else |
| 14 | assert(not get_option('tests').enabled(), 'Googletest is required') |
| 15 | endif |
| 16 | endif |
| 17 | |
| 18 | gtests = [ |
| 19 | 'crc', |
| 20 | 'tools_blob', |
| 21 | 'tools_ipmi_error', |
| 22 | 'tools_ipmi', |
| 23 | ] |
| 24 | |
| 25 | foreach t : gtests |
| 26 | test(t, executable(t.underscorify(), t + '_unittest.cpp', |
| 27 | build_by_default: false, |
| 28 | implicit_include_directories: false, |
| 29 | dependencies: [ipmiblob, gtest, gmock])) |
| 30 | endforeach |
| 31 | |