meson: add nlohmann-json wrapper and deps

A number of locations within the repository do not appropriately
specify the dependency on nlohmann-json.  Fix up the wrap file,
add appropriate dependency detection in the root meson, and add the
library as a dependency when needed.  This gets closer to allowing
full subproject-based builds.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If70888c6de5651ca355f84616e41408ddde9fc08
diff --git a/meson.build b/meson.build
index a7064a6..0aa7e91 100644
--- a/meson.build
+++ b/meson.build
@@ -92,6 +92,15 @@
 std_cpp_fs = cpp.find_library('stdc++fs', required: true)
 sdbusplus_dep = dependency('sdbusplus')
 
+if cpp.has_header_symbol(
+        'nlohmann/json.hpp',
+        'nlohmann::json::string_t',
+        required:false)
+    nlohmann_json_dep = declare_dependency()
+else
+    nlohmann_json_dep = dependency('nlohmann-json')
+endif
+
 # Subfolders
 subdir('libipmid')
 subdir('libipmid-host')
@@ -189,7 +198,7 @@
   'entity_map_json',
   'entity_map_json.cpp',
   include_directories: root_inc,
-  dependencies: [ipmid_dep],
+  dependencies: [ipmid_dep, nlohmann_json_dep],
   implicit_include_directories: false)
 
 entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
@@ -221,7 +230,7 @@
 ipmi20_lib = library(
   'ipmi20',
   libipmi20_src,
-  dependencies: [ipmid_pre, entity_map_json_dep],
+  dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
   include_directories: root_inc,
   install: true,
   install_dir: get_option('libdir') / 'ipmid-providers',