1gtest = dependency('gtest', main: true, disabler: true, required: get_option('tests')) 2gmock = dependency('gmock', disabler: true, required: get_option('tests')) 3 4if not gtest.found() or not gmock.found() 5 gtest_proj = import('cmake').subproject('googletest', required: false) 6 if gtest_proj.found() 7 gtest = declare_dependency( 8 dependencies: [ 9 gtest_proj.dependency('gtest'), 10 gtest_proj.dependency('gtest_main'), 11 ]) 12 gmock = gtest_proj.dependency('gmock') 13 else 14 assert(not get_option('tests').allowed(), 'Googletest is required') 15 endif 16endif 17 18gtests = [ 19 'bej_decoder', 20 'bej_common', 21 'bej_dictionary', 22 'bej_tree', 23 'bej_encoder' 24] 25 26nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 27 28libbej_test_incs = include_directories('include') 29foreach t : gtests 30 test(t, executable(t.underscorify(), t + '_test.cpp', 31 build_by_default: false, 32 implicit_include_directories: false, 33 include_directories: libbej_test_incs, 34 dependencies: [libbej, gtest, gmock, nlohmann_json_dep])) 35endforeach 36