William A. Kennington III | 48d6b06 | 2023-07-26 14:38:56 -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 get_option('tests').enabled(), 'Googletest is required') |
| 20 | endif |
| 21 | endif |
Patrick Williams | eb88701 | 2023-07-21 10:00:49 -0500 | [diff] [blame] | 22 | |
William A. Kennington III | 48d6b06 | 2023-07-26 14:38:56 -0700 | [diff] [blame] | 23 | gtests = { |
| 24 | 'ethstats': [ethstats_dep, gmock, gtest], |
| 25 | } |
| 26 | |
| 27 | foreach t, deps : gtests |
| 28 | test( |
| 29 | t, |
| 30 | executable( |
| 31 | t.underscorify(), t + '.cpp', |
| 32 | build_by_default: false, |
| 33 | implicit_include_directories: false, |
| 34 | cpp_args: '-Wno-missing-braces', |
| 35 | dependencies: deps)) |
| 36 | endforeach |