Patrick Williams | c3ab417 | 2025-02-01 08:38:42 -0500 | [diff] [blame^] | 1 | gtest = dependency( |
| 2 | 'gtest', |
| 3 | main: true, |
| 4 | disabler: true, |
| 5 | required: get_option('tests'), |
| 6 | ) |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 7 | gmock = dependency('gmock', disabler: true, required: get_option('tests')) |
| 8 | |
| 9 | if not gtest.found() or not gmock.found() |
Patrick Williams | c3ab417 | 2025-02-01 08:38:42 -0500 | [diff] [blame^] | 10 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 11 | if gtest_proj.found() |
| 12 | gtest = declare_dependency( |
| 13 | dependencies: [ |
| 14 | gtest_proj.dependency('gtest'), |
| 15 | gtest_proj.dependency('gtest_main'), |
| 16 | ], |
| 17 | ) |
| 18 | gmock = gtest_proj.dependency('gmock') |
| 19 | else |
| 20 | assert(not get_option('tests').allowed(), 'Googletest is required') |
| 21 | endif |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 22 | endif |
| 23 | |
| 24 | gtests = [ |
Patrick Williams | c3ab417 | 2025-02-01 08:38:42 -0500 | [diff] [blame^] | 25 | 'bej_decoder', |
| 26 | 'bej_common', |
| 27 | 'bej_dictionary', |
| 28 | 'bej_tree', |
| 29 | 'bej_encoder', |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 30 | ] |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 31 | |
Konstantin Aladyshev | 2bc745a | 2024-04-01 17:13:40 +0300 | [diff] [blame] | 32 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
| 33 | |
Nikhil Namjoshi | da6e557 | 2023-03-13 10:52:53 -0700 | [diff] [blame] | 34 | libbej_test_incs = include_directories('include') |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 35 | foreach t : gtests |
Patrick Williams | c3ab417 | 2025-02-01 08:38:42 -0500 | [diff] [blame^] | 36 | test( |
| 37 | t, |
| 38 | executable( |
| 39 | t.underscorify(), |
| 40 | t + '_test.cpp', |
| 41 | build_by_default: false, |
| 42 | implicit_include_directories: false, |
| 43 | include_directories: libbej_test_incs, |
| 44 | dependencies: [libbej, gtest, gmock, nlohmann_json_dep], |
| 45 | ), |
| 46 | ) |
kasunath | 7ffd30a | 2022-05-10 18:11:34 -0700 | [diff] [blame] | 47 | endforeach |