diff --git a/meson.build b/meson.build index 4560cf5765..3f5d541a67 100644 --- a/meson.build +++ b/meson.build @@ -244,15 +244,11 @@ if netconf_opt.enabled() and NETCONF_DEP.get_variable( error('Dependency not found: NETCONF.') endif -# GTEST_DEP = dependency( -# 'gtest', -# required: TESTS_OPT.enabled() or FUZZ_OPT.enabled(), -# ) -GTEST_DEP = disabler() -if TESTS_OPT.enabled() or FUZZ_OPT.enabled() - gtest_proj = subproject('gtest') - GTEST_DEP = gtest_proj.get_variable('gtest_dep') -endif +GTEST_DEP = dependency( + 'gtest', + fallback: ['gtest', 'gtest_dep'], + required: TESTS_OPT.enabled() or FUZZ_OPT.enabled(), +) # Crypto if crypto_opt == 'botan' @@ -476,13 +472,16 @@ conf_data.set('HAVE_AFL', have_afl) if GTEST_DEP.found() # Wrap dependencies cannot be used in compiler checks: https://github.com/mesonbuild/meson/issues/11575 # We can safely assume that googletest 1.15.2 has CreateUnifiedDiff though. - # result = cpp.run( - # fs.read('compiler-checks/have-create-unified-diff.cc'), - # name: 'HAVE_CREATE_UNIFIED_DIFF', - # dependencies: [GTEST_DEP], - # ) - # conf_data.set('HAVE_CREATE_UNIFIED_DIFF', result.returncode() == 0) - conf_data.set('HAVE_CREATE_UNIFIED_DIFF', true) + if GTEST_DEP.type_name() == 'internal' + conf_data.set('HAVE_CREATE_UNIFIED_DIFF', true) + else + result = cpp.run( + fs.read('compiler-checks/have-create-unified-diff.cc'), + name: 'HAVE_CREATE_UNIFIED_DIFF', + dependencies: [GTEST_DEP], + ) + conf_data.set('HAVE_CREATE_UNIFIED_DIFF', result.returncode() == 0) + endif endif if KRB5_DEP.found()