Konstantin Aladyshev | 5d234dd | 2024-04-22 17:52:41 +0300 | [diff] [blame] | 1 | gmock_dep = dependency('gmock', disabler: true, required: build_tests) |
| 2 | gtest_dep = dependency('gtest', main: true, disabler: true, required: build_tests) |
| 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( |
| 16 | not get_option('tests').enabled(), |
| 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 21 | |
| 22 | test( |
| 23 | 'utest', |
| 24 | executable( |
| 25 | 'utest', 'utest.cpp', |
| 26 | dependencies: [ |
Konstantin Aladyshev | 5d234dd | 2024-04-22 17:52:41 +0300 | [diff] [blame] | 27 | gmock_dep, |
| 28 | gtest_dep, |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 29 | libevdev, |
Patrick Williams | 0172969 | 2023-06-01 09:11:32 -0500 | [diff] [blame] | 30 | sdbusplus, |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 31 | ], |
| 32 | implicit_include_directories: false, |
| 33 | include_directories: '..', |
| 34 | link_with: [ |
| 35 | libevdev_o, |
| 36 | libmonitor_o, |
| 37 | ] |
| 38 | ) |
| 39 | ) |