1*5d234dd1SKonstantin Aladyshevgmock_dep = dependency('gmock', disabler: true, required: build_tests) 2*5d234dd1SKonstantin Aladyshevgtest_dep = dependency('gtest', main: true, disabler: true, required: build_tests) 3*5d234dd1SKonstantin Aladyshevif not gtest_dep.found() or not gmock_dep.found() 4*5d234dd1SKonstantin Aladyshev gtest_proj = import('cmake').subproject('googletest', required: false) 5*5d234dd1SKonstantin Aladyshev if gtest_proj.found() 6*5d234dd1SKonstantin Aladyshev gtest_dep = declare_dependency( 7*5d234dd1SKonstantin Aladyshev dependencies: [ 8*5d234dd1SKonstantin Aladyshev dependency('threads'), 9*5d234dd1SKonstantin Aladyshev gtest_proj.dependency('gtest'), 10*5d234dd1SKonstantin Aladyshev gtest_proj.dependency('gtest_main'), 11*5d234dd1SKonstantin Aladyshev ] 12*5d234dd1SKonstantin Aladyshev ) 13*5d234dd1SKonstantin Aladyshev gmock_dep = gtest_proj.dependency('gmock') 14*5d234dd1SKonstantin Aladyshev else 15*5d234dd1SKonstantin Aladyshev assert( 16*5d234dd1SKonstantin Aladyshev not get_option('tests').enabled(), 17*5d234dd1SKonstantin Aladyshev 'Googletest is required if tests are enabled' 18*5d234dd1SKonstantin Aladyshev ) 19*5d234dd1SKonstantin Aladyshev endif 20*5d234dd1SKonstantin Aladyshevendif 212d66b517SBrad Bishop 222d66b517SBrad Bishoptest( 232d66b517SBrad Bishop 'utest', 242d66b517SBrad Bishop executable( 252d66b517SBrad Bishop 'utest', 'utest.cpp', 262d66b517SBrad Bishop dependencies: [ 27*5d234dd1SKonstantin Aladyshev gmock_dep, 28*5d234dd1SKonstantin Aladyshev gtest_dep, 292d66b517SBrad Bishop libevdev, 300172969cSPatrick Williams sdbusplus, 312d66b517SBrad Bishop ], 322d66b517SBrad Bishop implicit_include_directories: false, 332d66b517SBrad Bishop include_directories: '..', 342d66b517SBrad Bishop link_with: [ 352d66b517SBrad Bishop libevdev_o, 362d66b517SBrad Bishop libmonitor_o, 372d66b517SBrad Bishop ] 382d66b517SBrad Bishop ) 392d66b517SBrad Bishop) 40