John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [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_proj = import('cmake').subproject('googletest', required: false) |
| 5 | if gtest_proj.found() |
| 6 | gtest = declare_dependency( |
| 7 | dependencies: [ |
| 8 | dependency('threads'), |
| 9 | gtest_proj.dependency('gtest'), |
| 10 | gtest_proj.dependency('gtest_main'), |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 11 | ], |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 12 | ) |
| 13 | gmock = gtest_proj.dependency('gmock') |
| 14 | else |
| 15 | assert( |
| 16 | not get_option('tests').allowed(), |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 22 | sources = ['ir-tests.cpp', 'test-utils.cpp', 'base64_test.cpp'] |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 23 | |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 24 | test_include_dirs = ['.', '../include'] |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 25 | |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 26 | cper_tests = executable( |
| 27 | 'cper-tests', |
| 28 | sources, |
| 29 | implicit_include_directories: false, |
| 30 | include_directories: include_directories(test_include_dirs), |
| 31 | cpp_args: '-fpermissive', |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 32 | dependencies: [ |
| 33 | libcper_parse_dep, |
| 34 | libcper_generate_dep, |
| 35 | json_c_dep, |
| 36 | gtest, |
| 37 | gmock, |
| 38 | ], |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 39 | ) |
Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 40 | test('test-cper-tests', cper_tests) |