[build] Don't rebuild gtest for every single unit test target

This causes some truly amazing issues due to -I flag hygine in some
rules. This is only relevant for Meson, but it's amazing it hasn't
broken things up until now.

Signed-off-by: Miguel Young de la Sota <mcyoung@google.com>
diff --git a/sw/vendor/meson.build b/sw/vendor/meson.build
index 8b9e7fb..b61785c 100644
--- a/sw/vendor/meson.build
+++ b/sw/vendor/meson.build
@@ -50,11 +50,19 @@
     sw_vendor_gtest_googletest_inc_dir,
     sw_vendor_gtest_googlemock_inc_dir,
   ],
-  sources: [
-    sw_vendor_gtest_googletest_libsources,
-    sw_vendor_gtest_googlemock_libsources,
-    sw_vendor_gtest_googlemock_mainsources,
-  ],
+  link_with: static_library(
+    'gtest_cc_main',
+    include_directories: [
+      sw_vendor_gtest_googletest_inc_dir,
+      sw_vendor_gtest_googlemock_inc_dir,
+    ],
+    sources: [
+      sw_vendor_gtest_googletest_libsources,
+      sw_vendor_gtest_googlemock_libsources,
+      sw_vendor_gtest_googlemock_mainsources,
+    ],
+    native: true,
+  ),
   dependencies: thread_dep,
 )
 # End googletest and googlemock build definitions