build: add wrapfiles for dependencies

Add wrapfiles for all dependencies and update meson.build
files to ensure dependencies are requested in all cases.
This enables out-of-bitbake/out-of-sdk builds for this
repository and enables it to be used as a meson subproject.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I0f2f7eed98f7f7555cafefc2605e1031a7f0adaf
diff --git a/.gitignore b/.gitignore
index c3d0974..8ad1400 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+subprojects/*
+!subprojects/*.wrap
+
 # Template from
 # https://github.com/github/gitignore/blob/master/Autotools.gitignore
 
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index 952b702..7e52c3d 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -1,5 +1,6 @@
 deps = [
   phosphor_dbus_interfaces,
+  nlohmann_json,
   sdbusplus,
   sdeventplus,
   libpldm_dep,
diff --git a/meson.build b/meson.build
index 63bb198..2e32367 100644
--- a/meson.build
+++ b/meson.build
@@ -48,11 +48,44 @@
   configuration: conf_data
 )
 
-phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
-sdbusplus = dependency('sdbusplus')
-sdeventplus = dependency('sdeventplus')
+phosphor_dbus_interfaces = dependency(
+  'phosphor-dbus-interfaces',
+  fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
+)
+sdbusplus = dependency(
+  'sdbusplus',
+  fallback: ['sdbusplus', 'sdbusplus_dep'],
+)
+sdeventplus = dependency(
+  'sdeventplus',
+  fallback: ['sdeventplus', 'sdeventplus_dep'],
+)
 systemd = dependency('systemd')
 
+cpp = meson.get_compiler('cpp')
+
+if cpp.has_header('nlohmann/json.hpp')
+  nlohmann_json = declare_dependency()
+else
+  subproject('nlohmann-json')
+  nlohmann_json = declare_dependency(
+    include_directories: [
+      'subprojects/nlohmann-json/single_include',
+      'subprojects/nlohmann-json/single_include/nlohmann',
+    ]
+  )
+endif
+
+if cpp.has_header('CLI/CLI.hpp')
+  CLI11_dep = declare_dependency()
+else
+  CLI11_dep = dependency(
+    'CLI11',
+    fallback: [ 'CLI11', 'CLI11_dep' ],
+  )
+endif
+
+
 subdir('libpldm')
 
 if get_option('libpldm-only').disabled()
@@ -65,6 +98,7 @@
   dependencies: [
       libpldm_dep,
       phosphor_dbus_interfaces,
+      nlohmann_json,
       sdbusplus,
   ],
   install: true,
@@ -81,6 +115,7 @@
   libpldmutils,
   libpldmresponder,
   libpldmutils,
+  nlohmann_json,
   sdbusplus,
   sdeventplus,
   phosphor_dbus_interfaces
diff --git a/pldmtool/meson.build b/pldmtool/meson.build
index 857ca24..865e9f0 100644
--- a/pldmtool/meson.build
+++ b/pldmtool/meson.build
@@ -20,6 +20,13 @@
   sources,
   implicit_include_directories: false,
   include_directories: include_directories(libpldm_headers),
-  dependencies: [libpldm_dep, libpldmutils, sdbusplus],
+  dependencies: [
+    CLI11_dep,
+    libpldm_dep,
+    libpldmutils,
+    nlohmann_json,
+    phosphor_dbus_interfaces,
+    sdbusplus,
+  ],
   install: true,
   install_dir: get_option('bindir'))
diff --git a/softoff/meson.build b/softoff/meson.build
index 12c7e00..5580d4a 100644
--- a/softoff/meson.build
+++ b/softoff/meson.build
@@ -1,6 +1,7 @@
 deps = [
     libpldm_dep,
     libpldmutils,
+    nlohmann_json,
     sdeventplus,
     sdbusplus,
     phosphor_dbus_interfaces,
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
new file mode 100644
index 0000000..e695a9d
--- /dev/null
+++ b/subprojects/CLI11.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11.git
+revision = HEAD
diff --git a/subprojects/nlohmann-json.wrap b/subprojects/nlohmann-json.wrap
new file mode 100644
index 0000000..9096612
--- /dev/null
+++ b/subprojects/nlohmann-json.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/nlohmann/json.git
+revision = HEAD
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
new file mode 100644
index 0000000..935a8b2
--- /dev/null
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-dbus-interfaces.git
+revision = HEAD
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..d470130
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus.git
+revision = HEAD
diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
new file mode 100644
index 0000000..085bb5e
--- /dev/null
+++ b/subprojects/sdeventplus.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/openbmc/sdeventplus.git
+revision = HEAD
diff --git a/test/meson.build b/test/meson.build
index d778deb..e9290f7 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -58,6 +58,7 @@
                          libpldmutils,
                          gtest,
                          gmock,
+                         nlohmann_json,
                          pldmd,
                          phosphor_dbus_interfaces,
                          sdeventplus,
diff --git a/utilities/meson.build b/utilities/meson.build
index c94be0d..c7200c1 100644
--- a/utilities/meson.build
+++ b/utilities/meson.build
@@ -1,4 +1,4 @@
-deps = [ libpldm_dep, sdeventplus ]
+deps = [ CLI11_dep, libpldm_dep, sdeventplus ]
 
 executable('set-state-effecter', 'requester/set_state_effecter.cpp',
            implicit_include_directories: false,