blob: 21c443d9b65d8011a13e2f40d642f3981646846c [file] [log] [blame]
John Chung197ea122024-05-03 19:57:55 +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'),
Ed Tanousc833a3a2024-07-15 11:53:53 -070011 ],
John Chung197ea122024-05-03 19:57:55 +080012 )
13 gmock = gtest_proj.dependency('gmock')
14 else
15 assert(
16 not get_option('tests').allowed(),
Ed Tanousc833a3a2024-07-15 11:53:53 -070017 'Googletest is required if tests are enabled',
John Chung197ea122024-05-03 19:57:55 +080018 )
19 endif
20endif
21
22sources = [
Ed Tanousc833a3a2024-07-15 11:53:53 -070023 'ir-tests.cpp',
24 'test-utils.cpp',
John Chung197ea122024-05-03 19:57:55 +080025]
26
27test_include_dirs = ['.', '..']
28
29run_command('cp', '-r', '../specification/json/', meson.current_build_dir())
Ed Tanousc833a3a2024-07-15 11:53:53 -070030run_command(
31 'mv',
32 meson.current_build_dir() / 'json',
33 meson.current_build_dir() / 'specification',
34)
John Chung197ea122024-05-03 19:57:55 +080035
36tests = ['cper-tests']
37
Ed Tanousc833a3a2024-07-15 11:53:53 -070038test(
39 'test-cper-tests',
40 executable(
41 'cper-tests',
42 sources,
43 implicit_include_directories: false,
44 include_directories: include_directories(test_include_dirs),
45 cpp_args: '-fpermissive',
46 dependencies: [libcper_parse, libcper_generate, json_c_dep, gtest, gmock],
47 ),
John Chung197ea122024-05-03 19:57:55 +080048)