xref: /openbmc/libcper/tests/meson.build (revision c833a3ac)
1197ea120SJohn Chunggtest = dependency('gtest', main: true, disabler: true, required: false)
2197ea120SJohn Chunggmock = dependency('gmock', disabler: true, required: false)
3197ea120SJohn Chungif not gtest.found() or not gmock.found()
4197ea120SJohn Chung    gtest_proj = import('cmake').subproject('googletest', required: false)
5197ea120SJohn Chung    if gtest_proj.found()
6197ea120SJohn Chung        gtest = declare_dependency(
7197ea120SJohn Chung            dependencies: [
8197ea120SJohn Chung                dependency('threads'),
9197ea120SJohn Chung                gtest_proj.dependency('gtest'),
10197ea120SJohn Chung                gtest_proj.dependency('gtest_main'),
11*c833a3acSEd Tanous            ],
12197ea120SJohn Chung        )
13197ea120SJohn Chung        gmock = gtest_proj.dependency('gmock')
14197ea120SJohn Chung    else
15197ea120SJohn Chung        assert(
16197ea120SJohn Chung            not get_option('tests').allowed(),
17*c833a3acSEd Tanous            'Googletest is required if tests are enabled',
18197ea120SJohn Chung        )
19197ea120SJohn Chung    endif
20197ea120SJohn Chungendif
21197ea120SJohn Chung
22197ea120SJohn Chungsources = [
23197ea120SJohn Chung    'ir-tests.cpp',
24197ea120SJohn Chung    'test-utils.cpp',
25197ea120SJohn Chung]
26197ea120SJohn Chung
27197ea120SJohn Chungtest_include_dirs = ['.', '..']
28197ea120SJohn Chung
29197ea120SJohn Chungrun_command('cp', '-r', '../specification/json/', meson.current_build_dir())
30*c833a3acSEd Tanousrun_command(
31*c833a3acSEd Tanous    'mv',
32*c833a3acSEd Tanous    meson.current_build_dir() / 'json',
33*c833a3acSEd Tanous    meson.current_build_dir() / 'specification',
34*c833a3acSEd Tanous)
35197ea120SJohn Chung
36197ea120SJohn Chungtests = ['cper-tests']
37197ea120SJohn Chung
38*c833a3acSEd Tanoustest(
39*c833a3acSEd Tanous    'test-cper-tests',
40*c833a3acSEd Tanous    executable(
41*c833a3acSEd Tanous        'cper-tests',
42197ea120SJohn Chung        sources,
43197ea120SJohn Chung        implicit_include_directories: false,
44197ea120SJohn Chung        include_directories: include_directories(test_include_dirs),
45197ea120SJohn Chung        cpp_args: '-fpermissive',
46*c833a3acSEd Tanous        dependencies: [libcper_parse, libcper_generate, json_c_dep, gtest, gmock],
47*c833a3acSEd Tanous    ),
48197ea120SJohn Chung)
49