xref: /openbmc/phosphor-modbus/tests/meson.build (revision a32d241b08af236b5ea1d4e18a390bdc561b435b)
19695bd28SJagpal Singh Gillgtest_dep = dependency('gtest', main: true, disabler: true, required: false)
29695bd28SJagpal Singh Gillgmock_dep = dependency('gmock', disabler: true, required: false)
39695bd28SJagpal Singh Gillif not gtest_dep.found() or not gmock_dep.found()
49695bd28SJagpal Singh Gill    gtest_proj = import('cmake').subproject('googletest', required: false)
59695bd28SJagpal Singh Gill    if gtest_proj.found()
69695bd28SJagpal Singh Gill        gtest_dep = declare_dependency(
79695bd28SJagpal Singh Gill            dependencies: [
89695bd28SJagpal Singh Gill                dependency('threads'),
99695bd28SJagpal Singh Gill                gtest_proj.dependency('gtest'),
109695bd28SJagpal Singh Gill                gtest_proj.dependency('gtest_main'),
119695bd28SJagpal Singh Gill            ],
129695bd28SJagpal Singh Gill        )
139695bd28SJagpal Singh Gill        gmock_dep = gtest_proj.dependency('gmock')
149695bd28SJagpal Singh Gill    else
159695bd28SJagpal Singh Gill        assert(
169695bd28SJagpal Singh Gill            not get_option('tests').enabled(),
179695bd28SJagpal Singh Gill            'Googletest is required if tests are enabled',
189695bd28SJagpal Singh Gill        )
199695bd28SJagpal Singh Gill    endif
209695bd28SJagpal Singh Gillendif
210fffb59bSJagpal Singh Gill
229695bd28SJagpal Singh Gilltest(
239695bd28SJagpal Singh Gill    'test_modbus_commands',
249695bd28SJagpal Singh Gill    executable(
259695bd28SJagpal Singh Gill        'test_modbus_commands',
269695bd28SJagpal Singh Gill        'test_modbus_commands.cpp',
279695bd28SJagpal Singh Gill        dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep],
289695bd28SJagpal Singh Gill        include_directories: ['.'],
299695bd28SJagpal Singh Gill    ),
309695bd28SJagpal Singh Gill)
31*a32d241bSJagpal Singh Gill
32*a32d241bSJagpal Singh Gilltest(
33*a32d241bSJagpal Singh Gill    'test_modbus',
34*a32d241bSJagpal Singh Gill    executable(
35*a32d241bSJagpal Singh Gill        'test_modbus',
36*a32d241bSJagpal Singh Gill        'test_modbus.cpp',
37*a32d241bSJagpal Singh Gill        'modbus_server_tester.cpp',
38*a32d241bSJagpal Singh Gill        dependencies: [gtest_dep, gmock_dep, default_deps, modbus_rtu_dep],
39*a32d241bSJagpal Singh Gill        include_directories: ['.'],
40*a32d241bSJagpal Singh Gill    ),
41*a32d241bSJagpal Singh Gill)
42