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')