Add googletest wrap
Add the wrap so tests can be done standalone.
The "'BUILD_SHARED_LIBS': 'ON'" option is needed or else stdplus, which
is indirectly pulled in as a subproject, fails with:
```
subprojects/stdplus/src/meson.build:207:22: ERROR: Can't link non-PIC static library 'gtest' into shared library 'stdplus-gtest'.
Use the 'pic' option to static_library to build with PIC.
```
Change-Id: Ia1847cab885e2b6adb72bec08621f5d154990e79
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meson.build b/meson.build
index de73ee8..7f7ed0b 100644
--- a/meson.build
+++ b/meson.build
@@ -32,8 +32,32 @@
endif
-gmock = dependency('gmock', disabler: true, required: build_tests)
-gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+gmock = dependency('gmock', disabler: true, required: false)
+gtest = dependency('gtest', main: true, disabler: true, required: false)
+if (not gtest.found() or not gmock.found()) and build_tests.enabled()
+ gtest_opts = import('cmake').subproject_options()
+ gtest_opts.add_cmake_defines({
+ 'BUILD_SHARED_LIBS': 'ON'
+ })
+ gtest_proj = import('cmake').subproject('googletest',
+ options: gtest_opts,
+ 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(false, 'Googletest is required if tests are enabled')
+ endif
+endif
+
+
+
phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
phosphor_logging = dependency('phosphor-logging')
prog_python = import('python').find_installation('python3')
diff --git a/subprojects/googletest.wrap b/subprojects/googletest.wrap
new file mode 100644
index 0000000..56da9ef
--- /dev/null
+++ b/subprojects/googletest.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/google/googletest
+revision = HEAD