Andrew Jeffery | 2f20c5a | 2021-05-27 14:52:49 +0930 | [diff] [blame] | 1 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 3 | if not gtest_dep.found() or not gmock_dep.found() |
| 4 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 5 | if gtest_proj.found() |
| 6 | gtest_dep = declare_dependency( |
| 7 | dependencies: [ |
| 8 | dependency('threads'), |
| 9 | gtest_proj.dependency('gtest'), |
| 10 | gtest_proj.dependency('gtest_main'), |
| 11 | ] |
| 12 | ) |
| 13 | gmock_dep = gtest_proj.dependency('gmock') |
| 14 | else |
| 15 | assert( |
Patrick Williams | 5bc307f | 2023-11-29 06:44:23 -0600 | [diff] [blame] | 16 | not get_option('tests').allowed(), |
Andrew Jeffery | 2f20c5a | 2021-05-27 14:52:49 +0930 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
Brad Bishop | feb19ef | 2019-11-07 18:02:16 -0500 | [diff] [blame] | 21 | |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 22 | ut_deps_list = [ |
| 23 | gtest_dep, |
| 24 | ] |
| 25 | |
| 26 | ut_deps_list += default_deps |
| 27 | |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 28 | test( |
| 29 | 'test_utils', |
| 30 | executable( |
| 31 | 'test_utils', |
| 32 | 'test_Utils.cpp', |
| 33 | '../src/Utils.cpp', |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 34 | dependencies: ut_deps_list, |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 35 | implicit_include_directories: false, |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 36 | include_directories: '../src', |
Lei YU | d320414 | 2021-11-16 14:57:27 +0800 | [diff] [blame] | 37 | ) |
| 38 | ) |