William A. Kennington III | a2d67e2 | 2020-02-19 12:17:39 -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() |
William A. Kennington III | 83af3fa | 2021-01-31 15:22:54 -0800 | [diff] [blame] | 4 | gtest_proj = import('cmake').subproject( |
| 5 | 'googletest', |
| 6 | cmake_options: [ |
| 7 | '-DCMAKE_CXX_FLAGS=-Wno-pedantic', |
| 8 | ], |
| 9 | required: false) |
William A. Kennington III | a2d67e2 | 2020-02-19 12:17:39 -0800 | [diff] [blame] | 10 | if gtest_proj.found() |
| 11 | gtest = declare_dependency( |
| 12 | dependencies: [ |
| 13 | dependency('threads'), |
| 14 | gtest_proj.dependency('gtest'), |
| 15 | gtest_proj.dependency('gtest_main'), |
| 16 | ]) |
| 17 | gmock = gtest_proj.dependency('gmock') |
| 18 | else |
| 19 | assert(not build_tests.enabled(), 'Googletest is required') |
| 20 | endif |
| 21 | endif |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 22 | |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 23 | gtests = [ |
William A. Kennington III | e847ef8 | 2018-11-02 17:29:15 -0700 | [diff] [blame] | 24 | 'handle/copyable', |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 25 | 'handle/managed', |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 26 | 'util/cexec', |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 27 | 'util/string', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 28 | ] |
| 29 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame^] | 30 | if has_fd |
| 31 | gtests += [ |
| 32 | 'fd/dupable', |
| 33 | 'fd/managed', |
| 34 | 'fd/intf', |
| 35 | 'fd/impl', |
| 36 | 'fd/mock', |
| 37 | 'fd/ops', |
| 38 | ] |
| 39 | else |
| 40 | warning('Not testing file descriptor feature') |
| 41 | endif |
| 42 | |
William A. Kennington III | 83af3fa | 2021-01-31 15:22:54 -0800 | [diff] [blame] | 43 | if gtest.found() and gmock.found() |
| 44 | foreach t : gtests |
| 45 | test(t, executable(t.underscorify(), t + '.cpp', |
| 46 | build_by_default: false, |
| 47 | implicit_include_directories: false, |
| 48 | dependencies: [stdplus, gtest, gmock])) |
| 49 | endforeach |
| 50 | endif |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 51 | |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 52 | # Switch to `catch2-with-main.pc` when 2.x supports it |
| 53 | catch2 = dependency('catch2-with-main', required: false) |
| 54 | if not catch2.found() |
| 55 | catch2 = dependency('catch2', required: false) |
| 56 | if catch2.found() |
| 57 | catch2_main = meson.get_compiler('cpp').find_library( |
| 58 | 'Catch2WithMain', required: false) |
| 59 | if catch2_main.found() |
| 60 | catch2 = declare_dependency( |
| 61 | dependencies: [ |
| 62 | catch2, |
| 63 | catch2_main, |
| 64 | ]) |
| 65 | else |
| 66 | catch2 = declare_dependency( |
| 67 | link_with: static_library( |
| 68 | 'catch2', 'catch2_main.cpp', |
| 69 | implicit_include_directories: false, |
| 70 | build_by_default: false, |
| 71 | dependencies: catch2), |
| 72 | dependencies: catch2) |
| 73 | endif |
| 74 | endif |
| 75 | endif |
| 76 | if not catch2.found() |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 77 | catch2_proj = import('cmake').subproject( |
| 78 | 'Catch2', |
| 79 | cmake_options: [ |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 80 | '-DBUILD_TESTING=OFF', |
| 81 | '-DCMAKE_CXX_FLAGS=-Wno-non-virtual-dtor', |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 82 | ], |
| 83 | required: false) |
| 84 | if catch2_proj.found() |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 85 | catch2 = declare_dependency( |
| 86 | dependencies: [ |
| 87 | catch2_proj.dependency('Catch2'), |
| 88 | catch2_proj.dependency('Catch2WithMain'), |
| 89 | ]) |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 90 | else |
| 91 | assert(not build_tests.enabled(), 'Catch2 is required') |
| 92 | endif |
| 93 | endif |
| 94 | |
| 95 | catch2_tests = [ |
William A. Kennington III | 770c556 | 2020-02-13 13:07:42 -0800 | [diff] [blame] | 96 | 'signal', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 97 | 'raw', |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 98 | ] |
| 99 | |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 100 | if catch2.found() |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 101 | foreach t : catch2_tests |
| 102 | test(t, executable(t.underscorify(), t + '.cpp', |
William A. Kennington III | 3142235 | 2020-02-19 13:21:56 -0800 | [diff] [blame] | 103 | build_by_default: false, |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 104 | implicit_include_directories: false, |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 105 | dependencies: [stdplus, span_dep, catch2])) |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 106 | endforeach |
| 107 | endif |