]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3732] Meson: Make gtest simple dependency + fallback
authorAndrei Pavel <andrei@isc.org>
Fri, 25 Apr 2025 10:01:40 +0000 (13:01 +0300)
committerAndrei Pavel <andrei@isc.org>
Fri, 25 Apr 2025 15:45:15 +0000 (18:45 +0300)
The gtest.cc compiler check misleadingly fails on some systems...

compiler-checks/gtest.cc [deleted file]
meson.build

diff --git a/compiler-checks/gtest.cc b/compiler-checks/gtest.cc
deleted file mode 100644 (file)
index 1881afe..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <gtest/gtest.h>
-
-// musl's mallocng memory allocator stupidly crash for test names that are
-// lengthier than 16 characters. Hence the long test name.
-TEST(Fixture, testWithLongLongLongName) {
-    EXPECT_LT(1, 2);
-}
-
-int main(int argc, char* argv[]) {
-    testing::InitGoogleTest(&argc, argv);
-    return RUN_ALL_TESTS();
-}
index 436f46d4a12605fc18a4e40e0b98bec604e7c9ea..41175494564ee9df4a49fb1cdfa993bd9d2b5587 100644 (file)
@@ -249,33 +249,11 @@ if netconf_opt.enabled() and NETCONF_DEP.get_variable(
 endif
 
 # Google Test
-GTEST_DEP = disabler()
-if FUZZ_OPT.enabled() or TESTS_OPT.enabled()
-    GTEST_DEP = dependency('gtest', required: false)
-    if GTEST_DEP.found()
-        # Wrap dependencies cannot be used in compiler checks: https://github.com/mesonbuild/meson/issues/11575
-        # Should never be a wrap dependency at this point, but somehow it happens on Alpine systems.
-        if GTEST_DEP.type_name() != 'internal'
-            result = cpp.run(
-                fs.read('compiler-checks/gtest.cc'),
-                name: 'Check if a simple GTest test runs.',
-                dependencies: [GTEST_DEP, threads_dep],
-            )
-            if result.returncode() != 0
-                GTEST_DEP = disabler()
-            endif
-        endif
-    endif
-    if not GTEST_DEP.found()
-        gtest_subproject = subproject('gtest', required: false)
-        if gtest_subproject.found()
-            GTEST_DEP = gtest_subproject.get_variable('gtest_dep')
-        endif
-    endif
-    if not GTEST_DEP.found()
-        error('Dependency not found: GTest.')
-    endif
-endif
+GTEST_DEP = dependency(
+    'gtest',
+    fallback: ['gtest', 'gtest_dep'],
+    required: FUZZ_OPT.enabled() or TESTS_OPT.enabled(),
+)
 
 # Crypto
 if crypto_opt == 'botan'