]> git.zndr.dk Git - meson-test.git/commitdiff
Final
authorJannik ZANDER <jannikz@gmail.com>
Tue, 17 Jul 2018 11:49:24 +0000 (13:49 +0200)
committerJannik ZANDER <jannikz@gmail.com>
Tue, 17 Jul 2018 11:49:24 +0000 (13:49 +0200)
meson.build

index f2c1c5b5495288639824507acd7f0827ded4272c..dd5e46dd157c60f0381daa0cc4cadda1f128cc7c 100644 (file)
@@ -1,22 +1,19 @@
 project('meson_test','cpp', 'c')
 
-gtest_sub = subproject('gtest')
+gtest = dependency('gtest', main : true, required : false)
 
-gtest_inc = gtest_sub.get_variable('gtest_incdir')
-gtest_src = [gtest_sub.get_variable('gtest_libsources'), 
-             gtest_sub.get_variable('gtest_mainsources')]
-#gtest_dep = [gtest_sub.get_variable('gtest_main_dep'),
-#             dependency('threads')]
+if not gtest.found()
+  gtest_sub = subproject('gtest')
+  gtest_src = [gtest_sub.get_variable('gtest_libsources'), 
+               gtest_sub.get_variable('gtest_mainsources')]
+  gtest_inc = gtest_sub.get_variable('gtest_incdir')
+  gtest_lib = static_library('gtest', sources: gtest_src,
+                                      include_directories: gtest_inc)
+  gtest = declare_dependency(link_with : gtest_lib,
+                             include_directories : gtest_inc,
+                             dependencies: dependency('threads'))
+endif
 
-gtest_lib = static_library('gtest_lib', sources: gtest_src,
-                                        include_directories: gtest_inc)
-#                                        dependencies : gtest_dep) 
-
-gtest = declare_dependency(include_directories : gtest_inc,
-                           link_with : gtest_lib,
-                           dependencies: dependency('threads'))
-
-subproject('gtest')
 subdir('folder1')
 subdir('folder1_test')
 subdir('folder2')