build: Add wrapfiles for dependencies

- Update meson.build and add wrapfiles so that all dependencies are
  handled as subprojects.

- This allows builds completely outside of bitbake or an SDK.
  refer: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-virtual-sensor/+/42349

Tested: built ledManager repo successfully using `meson build`.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I35db603d4aa9c2eee41c3cfb27eba6953950fe44
diff --git a/test/meson.build b/test/meson.build
index feb6578..059d13c 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,3 +1,24 @@
+gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
+gmock_dep = dependency('gmock', disabler: true, required: false)
+if not gtest_dep.found() or not gmock_dep.found()
+    gtest_proj = import('cmake').subproject('googletest', required: false)
+    if gtest_proj.found()
+        gtest_dep = declare_dependency(
+            dependencies: [
+                dependency('threads'),
+                gtest_proj.dependency('gtest'),
+                gtest_proj.dependency('gtest_main'),
+            ]
+        )
+        gmock_dep = gtest_proj.dependency('gmock')
+  else
+        assert(
+            not get_option('tests').enabled(),
+            'Googletest is required if tests are enabled'
+        )
+  endif
+endif
+
 test_sources = [
   '../manager.cpp',
   '../serialize.cpp',
@@ -18,8 +39,8 @@
                      test_sources,
                      include_directories: ['..'],
                      dependencies: [
-                         gtest,
-                         gmock,
+                         gtest_dep,
+                         gmock_dep,
                          deps
                          ]),
        workdir: meson.current_source_dir())