1cmake = import('cmake') 2 3gtest = dependency('gtest', main: true, disabler: true, required: false) 4gmock = dependency('gmock', disabler: true, required: false) 5if not gtest.found() or not gmock.found() 6 gtest_proj = import('cmake').subproject('googletest', required: false) 7 if gtest_proj.found() 8 gtest = declare_dependency( 9 dependencies: [ 10 dependency('threads'), 11 gtest_proj.dependency('gtest'), 12 gtest_proj.dependency('gtest_main'), 13 ], 14 ) 15 gmock = gtest_proj.dependency('gmock') 16 else 17 assert( 18 not get_option('tests').allowed(), 19 'Googletest is required if tests are enabled', 20 ) 21 endif 22endif 23 24nlohmann_json_dep = dependency( 25 'nlohmann_json', 26 required: false, 27 version: '>=3.11.2', 28 include_type: 'system', 29) 30if not nlohmann_json_dep.found() 31 nlohmann_proj = subproject('nlohmann_json', required: true) 32 nlohmann_json_dep = nlohmann_proj.get_variable('nlohmann_json_dep') 33endif 34 35valijson_dep = dependency('valijson', required: false) 36if not valijson_dep.found() 37 valijson_proj = cmake.subproject('valijson') 38 valijson_dep = valijson_proj.get_variable('valijson_dep') 39endif 40 41sources = ['ir-tests.cpp', 'test-utils.cpp', 'base64_test.cpp'] 42 43test_include_dirs = ['.', '../include'] 44 45cper_tests = executable( 46 'cper-tests', 47 sources, 48 implicit_include_directories: false, 49 include_directories: include_directories(test_include_dirs), 50 cpp_args: '-fpermissive', 51 dependencies: [ 52 libcper_parse_dep, 53 libcper_generate_dep, 54 json_c_dep, 55 gtest, 56 gmock, 57 nlohmann_json_dep, 58 valijson_dep, 59 ], 60) 61test('test-cper-tests', cper_tests) 62