From: Jannik ZANDER Date: Tue, 17 Jul 2018 11:49:24 +0000 (+0200) Subject: Final X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=d2d567421ae077153868cf6ed3f004e9a0d9def5;p=meson-test.git Final --- diff --git a/meson.build b/meson.build index f2c1c5b..dd5e46d 100644 --- a/meson.build +++ b/meson.build @@ -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')