blob: 9beb66f438963aaf4610d8f2de8a6c758cc6b109 [file] [log] [blame]
William A. Kennington IIIa2d67e22020-02-19 12:17:39 -08001gtest = dependency('gtest', main: true, disabler: true, required: false)
2gmock = dependency('gmock', disabler: true, required: false)
3if 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'),
11 ])
12 gmock = gtest_proj.dependency('gmock')
13 else
14 assert(not build_tests.enabled(), 'Googletest is required')
15 endif
16endif
William A. Kennington III15982f62019-01-31 14:43:41 -080017
William A. Kennington III245495e2020-02-13 13:07:30 -080018gtests = [
William A. Kennington III15982f62019-01-31 14:43:41 -080019 'signal',
William A. Kennington IIIe847ef82018-11-02 17:29:15 -070020 'handle/copyable',
William A. Kennington III7a5e2322018-11-02 17:28:35 -070021 'handle/managed',
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -080022 'util/cexec',
William A. Kennington III4ef36e72019-06-27 12:48:59 -070023 'util/string',
William A. Kennington III15982f62019-01-31 14:43:41 -080024]
25
William A. Kennington III245495e2020-02-13 13:07:30 -080026foreach t : gtests
William A. Kennington III15982f62019-01-31 14:43:41 -080027 test(t, executable(t.underscorify(), t + '.cpp',
William A. Kennington III31422352020-02-19 13:21:56 -080028 build_by_default: false,
William A. Kennington III15982f62019-01-31 14:43:41 -080029 implicit_include_directories: false,
William A. Kennington III97e39472019-04-03 13:22:32 -070030 dependencies: [stdplus, gtest, gmock]))
William A. Kennington III15982f62019-01-31 14:43:41 -080031endforeach
William A. Kennington III245495e2020-02-13 13:07:30 -080032
33# catch2 might not have a pkg-config. It is header only so just make
34# sure we can access the needed symbols from the header.
35catch2_dep = dependency('Catch2', required: false)
36has_catch2 = meson.get_compiler('cpp').has_header_symbol(
37 'catch2/catch.hpp',
38 'Approx',
39 dependencies: catch2_dep,
40 required: false)
41if not has_catch2
42 catch2_proj = import('cmake').subproject(
43 'Catch2',
44 cmake_options: [
45 '-DBUILD_TESTING=OFF'
46 ],
47 required: false)
48 if catch2_proj.found()
49 catch2_dep = catch2_proj.dependency('Catch2')
50 has_catch2 = true
51 else
52 assert(not build_tests.enabled(), 'Catch2 is required')
53 endif
54endif
55
56catch2_tests = [
57]
58
59if has_catch2
60 libcatch2 = static_library(
61 'catch2', 'catch2_main.cpp',
62 implicit_include_directories: false,
63 build_by_default: false,
64 dependencies: catch2_dep)
65
66 foreach t : catch2_tests
67 test(t, executable(t.underscorify(), t + '.cpp',
William A. Kennington III31422352020-02-19 13:21:56 -080068 build_by_default: false,
William A. Kennington III245495e2020-02-13 13:07:30 -080069 implicit_include_directories: false,
70 link_with: libcatch2,
71 dependencies: [stdplus, catch2_dep]))
72 endforeach
73endif