kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [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 |
Patrick Williams | 6eb945f | 2023-11-29 06:45:26 -0600 | [diff] [blame] | 14 | assert(not get_option('tests').allowed(), 'Googletest is required') |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 15 | endif |
| 16 | endif |
| 17 | |
| 18 | gtests = [ |
kasunath | e8946af | 2022-05-23 12:32:09 -0700 | [diff] [blame] | 19 | 'bej_decoder', |
kasunath | 0aa36d8 | 2022-11-23 14:24:15 -0800 | [diff] [blame] | 20 | 'bej_common', |
kasunath | d073aa1 | 2022-05-12 16:08:49 -0700 | [diff] [blame] | 21 | 'bej_dictionary', |
kasunath | 2ebe82f | 2023-01-31 13:59:22 -0800 | [diff] [blame] | 22 | 'bej_tree', |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 23 | 'bej_encoder' |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 24 | ] |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 25 | |
Konstantin Aladyshev | 2bc745a | 2024-04-01 17:13:40 +0300 | [diff] [blame] | 26 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
| 27 | |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 28 | libbej_test_incs = include_directories('include') |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 29 | foreach t : gtests |
| 30 | test(t, executable(t.underscorify(), t + '_test.cpp', |
| 31 | build_by_default: false, |
| 32 | implicit_include_directories: false, |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 33 | include_directories: libbej_test_incs, |
Konstantin Aladyshev | 2bc745a | 2024-04-01 17:13:40 +0300 | [diff] [blame] | 34 | dependencies: [libbej, gtest, gmock, nlohmann_json_dep])) |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 35 | endforeach |