test: Allow optional usage of vendored googletest
Change-Id: I2646b01eefa954b1afc70ecc04791d53b99d96d7
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/.clang-ignore b/.clang-ignore
new file mode 100644
index 0000000..36f17f2
--- /dev/null
+++ b/.clang-ignore
@@ -0,0 +1 @@
+./subprojects
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..025c6c9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/subprojects/*/
diff --git a/meson.build b/meson.build
index 4f7bc49..585fc72 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
project('stdplus', 'cpp',
- version: '0.1', meson_version: '>=0.49.0',
+ version: '0.1', meson_version: '>=0.53.2',
default_options: [
'warning_level=3',
'werror=true',
diff --git a/subprojects/googletest.wrap b/subprojects/googletest.wrap
new file mode 100644
index 0000000..fb55947
--- /dev/null
+++ b/subprojects/googletest.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/google/googletest
+revision = release-1.10.0
diff --git a/test/meson.build b/test/meson.build
index c8fddf0..4f77a56 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,5 +1,19 @@
-gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
-gmock = dependency('gmock', disabler: true, required: build_tests)
+gtest = dependency('gtest', main: true, disabler: true, required: false)
+gmock = dependency('gmock', disabler: true, required: false)
+if not gtest.found() or not gmock.found()
+ gtest_proj = import('cmake').subproject('googletest', required: false)
+ if gtest_proj.found()
+ gtest = declare_dependency(
+ dependencies: [
+ dependency('threads'),
+ gtest_proj.dependency('gtest'),
+ gtest_proj.dependency('gtest_main'),
+ ])
+ gmock = gtest_proj.dependency('gmock')
+ else
+ assert(not build_tests.enabled(), 'Googletest is required')
+ endif
+endif
tests = [
'signal',