meson: Explicitly check for CLI11 dependency

Change-Id: Ifaf6e5aba783285c16e8aae278e34dde6aa9d52c
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/.gitignore b/.gitignore
index a0155cb..327ea97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 /build*/
+/subprojects/*/
diff --git a/meson.build b/meson.build
index 19dfc62..47cee55 100644
--- a/meson.build
+++ b/meson.build
@@ -73,12 +73,28 @@
     include_directories: hwmon_headers,
     link_with: hwmon_lib)
 
+# CLI11 might not have a pkg-config. It is header only so just make
+# sure we can access the needed symbols from the header.
+cli11_dep = dependency('cli11', required: false)
+has_cli11 = meson.get_compiler('cpp').has_header_symbol(
+    'CLI/CLI.hpp',
+    'CLI::App',
+    dependencies: cli11_dep,
+    required: false)
+if not has_cli11
+    cli11_proj = subproject('cli11', required: false)
+    assert(cli11_proj.found(), 'CLI11 is required')
+    cli11_dep = cli11_proj.get_variable('CLI11_dep')
+endif
+
 executable(
     'phosphor-hwmon-readd',
     'readd.cpp',
-    dependencies: hwmon_dep,
-    install: true,
-)
+    dependencies: [
+        cli11_dep,
+        hwmon_dep,
+    ],
+    install: true)
 
 subdir('msl')
 subdir('test')
diff --git a/subprojects/cli11.wrap b/subprojects/cli11.wrap
new file mode 100644
index 0000000..407409c
--- /dev/null
+++ b/subprojects/cli11.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11
+revision = HEAD