]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3732] Meson: Fix GTest detection
authorAndrei Pavel <andrei@isc.org>
Thu, 24 Apr 2025 11:30:16 +0000 (14:30 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 24 Apr 2025 13:04:31 +0000 (16:04 +0300)
compiler-checks/gtest.cc
meson.build

index eb1bcea6ecf0c679242ef4c5bbd2d4a9d2a2e081..1881afe3449f2108ec06cb457aa42a5423a028ef 100644 (file)
@@ -6,7 +6,7 @@ TEST(Fixture, testWithLongLongLongName) {
     EXPECT_LT(1, 2);
 }
 
-int main() {
-    testing::InitGoogleTest();
+int main(int argc, char* argv[]) {
+    testing::InitGoogleTest(&argc, argv);
     return RUN_ALL_TESTS();
 }
index 0cb74caa051eb124589072254fd0fc01ae9a5e7e..436f46d4a12605fc18a4e40e0b98bec604e7c9ea 100644 (file)
@@ -249,20 +249,32 @@ if netconf_opt.enabled() and NETCONF_DEP.get_variable(
 endif
 
 # Google Test
-GTEST_DEP = dependency('gtest', required: TESTS_OPT.enabled() or FUZZ_OPT.enabled())
-if GTEST_DEP.found()
-    result = cpp.run(
-        fs.read('compiler-checks/gtest.cc'),
-        name: 'Check if a simple GTest test runs.',
-        dependencies: [GTEST_DEP],
-    )
-    if result.returncode() != 0
-        GTEST_DEP = disabler()
+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
 
 # Crypto