meson: Make googletest vendorable
This is a quality of life improvement so that users trying to work with
the project don't need to have an external install of the googletest
dependency for the tests to build.
Change-Id: I44b4cbae14c5006eaef0a5b42a1f6b753b07b405
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/README.md b/README.md
index a557fc1..028b4cf 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,6 @@
gpioplus is a c++ wrapper around the linux gpio ioctl interface.
It aims to provide c++ ergonomics to the usage.
-## Dependencies
-
-Test cases require google{test,mock}, valgrind, and lcov.
-
## Building
For a standard release build, you want something like:
```
diff --git a/meson.build b/meson.build
index ae55b6a..d69fee3 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
project('gpioplus', '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 15e5e7b..51993de 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 = [
'chip',