John Chung | e2fae4b | 2024-11-13 18:10:31 -0600 | [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_opts = import('cmake').subproject_options() |
| 5 | gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'}) |
| 6 | gtest_proj = import('cmake').subproject( |
| 7 | 'googletest', |
| 8 | options: gtest_opts, |
Patrick Williams | ce3e487 | 2025-03-03 11:07:48 -0500 | [diff] [blame] | 9 | required: false, |
John Chung | e2fae4b | 2024-11-13 18:10:31 -0600 | [diff] [blame] | 10 | ) |
| 11 | if gtest_proj.found() |
| 12 | gtest = declare_dependency( |
| 13 | dependencies: [ |
| 14 | dependency('threads'), |
| 15 | gtest_proj.dependency('gtest'), |
| 16 | gtest_proj.dependency('gtest_main'), |
Patrick Williams | ce3e487 | 2025-03-03 11:07:48 -0500 | [diff] [blame] | 17 | ], |
| 18 | ) |
John Chung | e2fae4b | 2024-11-13 18:10:31 -0600 | [diff] [blame] | 19 | gmock = gtest_proj.dependency('gmock') |
| 20 | else |
| 21 | assert(not get_option('tests').enabled(), 'Googletest is required') |
| 22 | endif |
| 23 | endif |
| 24 | |
| 25 | # Build/add serial_unittest to test suite |
Patrick Williams | ce3e487 | 2025-03-03 11:07:48 -0500 | [diff] [blame] | 26 | test( |
| 27 | 'transport_serial', |
John Chung | e2fae4b | 2024-11-13 18:10:31 -0600 | [diff] [blame] | 28 | executable( |
| 29 | 'transport_serial_unittest', |
| 30 | 'serial_unittest.cpp', |
| 31 | '../serialcmd.cpp', |
| 32 | include_directories: root_inc, |
| 33 | build_by_default: false, |
| 34 | implicit_include_directories: false, |
| 35 | dependencies: [ |
| 36 | sdbusplus_dep, |
| 37 | stdplus_dep, |
| 38 | phosphor_logging_dep, |
| 39 | sdeventplus_dep, |
| 40 | gtest, |
Patrick Williams | ce3e487 | 2025-03-03 11:07:48 -0500 | [diff] [blame] | 41 | gmock, |
| 42 | ], |
| 43 | ), |
John Chung | e2fae4b | 2024-11-13 18:10:31 -0600 | [diff] [blame] | 44 | ) |