Zane Shelley | fefc016 | 2021-12-20 17:29:46 -0600 | [diff] [blame^] | 1 | # Get the gtest/gmock dependencies. |
| 2 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 3 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 4 | if not gtest_dep.found() or not gmock_dep.found() |
| 5 | cmake = import('cmake') |
| 6 | gtest_proj = cmake.subproject('googletest', |
| 7 | required: false) |
| 8 | if gtest_proj.found() |
| 9 | gtest_dep = declare_dependency( |
| 10 | dependencies: [ |
| 11 | dependency('threads'), |
| 12 | gtest_proj.dependency('gtest'), |
| 13 | gtest_proj.dependency('gtest_main'), |
| 14 | ] |
| 15 | ) |
| 16 | gmock_dep = gtest_proj.dependency('gmock') |
| 17 | else |
| 18 | assert(not get_option('tests').enabled(), |
| 19 | 'Googletest is required if tests are enabled') |
| 20 | endif |
| 21 | endif |
| 22 | |
Zane Shelley | ad103b9 | 2019-07-31 15:57:54 -0500 | [diff] [blame] | 23 | # build simulator |
| 24 | subdir('simulator') |
| 25 | |
Ben Tyner | a8126fd | 2019-08-01 19:40:07 -0500 | [diff] [blame] | 26 | # supporting files that need compiled/linked |
Ben Tyner | 032bf9e | 2020-05-06 21:27:54 -0500 | [diff] [blame] | 27 | test_src = ['../src/util/hei_bit_string.cpp', |
Zane Shelley | 7649b8b | 2020-05-08 20:12:35 -0500 | [diff] [blame] | 28 | 'sim_tracing.cpp'] |
Ben Tyner | a8126fd | 2019-08-01 19:40:07 -0500 | [diff] [blame] | 29 | |
| 30 | # build g-test framework unit tests |
Zane Shelley | 200c345 | 2019-09-26 11:46:30 -0500 | [diff] [blame] | 31 | gtests = [ |
| 32 | 'bit_string_test', |
Zane Shelley | 6eb6190 | 2020-05-15 22:25:58 -0500 | [diff] [blame] | 33 | 'flyweight_test', |
| 34 | 'operator_register_test', |
Zane Shelley | 200c345 | 2019-09-26 11:46:30 -0500 | [diff] [blame] | 35 | ] |
Ben Tyner | a8126fd | 2019-08-01 19:40:07 -0500 | [diff] [blame] | 36 | |
Zane Shelley | fefc016 | 2021-12-20 17:29:46 -0600 | [diff] [blame^] | 37 | foreach g : gtests |
| 38 | test(g, executable(g.underscorify(), g + '.cpp', test_src, |
| 39 | dependencies : gtest_dep, |
| 40 | include_directories : incdir)) |
| 41 | endforeach |
Paul Greenwood | dc47e0a | 2019-11-01 16:22:57 -0500 | [diff] [blame] | 42 | |