meson: simplify dependencies

Leverage wrapfile `[provide]` directives to simplify the dependency
searching in the meson.build.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id97da97371cf4b8f526f0cc1ca4e4151c466fadf
diff --git a/.gitignore b/.gitignore
index 327ea97..6301280 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 /build*/
-/subprojects/*/
+/subprojects/*
+!/subprojects/*.wrap
diff --git a/meson.build b/meson.build
index ed2814a..6dee037 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,8 @@
     'cpp_std=c++20',
   ])
 
+cpp = meson.get_compiler('cpp')
+
 subdir('src')
 
 if not get_option('tests').disabled()
diff --git a/src/meson.build b/src/meson.build
index c93783c..42eef62 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,29 +1,17 @@
 watchdog_headers = include_directories('.')
 
-# 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')
+if cpp.has_header('CLI/CLI.hpp')
+    CLI11_dep = declare_dependency()
+else
+    CLI11_dep = dependency('CLI11')
 endif
 
 watchdog_deps = [
-  cli11_dep,
-  dependency(
-    'phosphor-dbus-interfaces',
-    fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep']),
-  dependency(
-    'phosphor-logging',
-    fallback: ['phosphor-logging', 'phosphor_logging_dep']),
-  dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep']),
-  dependency('sdeventplus', fallback: ['sdeventplus', 'sdeventplus_dep']),
+  CLI11_dep,
+  dependency('sdbusplus'),
+  dependency('sdeventplus'),
+  dependency('phosphor-dbus-interfaces'),
+  dependency('phosphor-logging'),
 ]
 
 watchdog_lib = static_library(
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
new file mode 100644
index 0000000..2e5a95b
--- /dev/null
+++ b/subprojects/CLI11.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11.git
+revision = HEAD
+
+[provide]
+CLI11 = CLI11_dep
diff --git a/subprojects/cli11.wrap b/subprojects/cli11.wrap
deleted file mode 100644
index 407409c..0000000
--- a/subprojects/cli11.wrap
+++ /dev/null
@@ -1,3 +0,0 @@
-[wrap-git]
-url = https://github.com/CLIUtils/CLI11
-revision = HEAD
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
index 0be70dd..346aa0c 100644
--- a/subprojects/phosphor-dbus-interfaces.wrap
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -1,3 +1,6 @@
 [wrap-git]
-url = https://github.com/openbmc/phosphor-dbus-interfaces
+url = https://github.com/openbmc/phosphor-dbus-interfaces.git
 revision = HEAD
+
+[provide]
+phosphor-dbus-interfaces = phosphor_dbus_interfaces_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
index 8db07b6..71eee8b 100644
--- a/subprojects/phosphor-logging.wrap
+++ b/subprojects/phosphor-logging.wrap
@@ -1,3 +1,6 @@
 [wrap-git]
-url = https://github.com/openbmc/phosphor-logging
+url = https://github.com/openbmc/phosphor-logging.git
 revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
index 7f736e7..7b076d0 100644
--- a/subprojects/sdbusplus.wrap
+++ b/subprojects/sdbusplus.wrap
@@ -1,3 +1,6 @@
 [wrap-git]
-url = https://github.com/openbmc/sdbusplus
+url = https://github.com/openbmc/sdbusplus.git
 revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep
diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
index 7503664..f871ac0 100644
--- a/subprojects/sdeventplus.wrap
+++ b/subprojects/sdeventplus.wrap
@@ -1,3 +1,6 @@
 [wrap-git]
-url = https://github.com/openbmc/sdeventplus
+url = https://github.com/openbmc/sdeventplus.git
 revision = HEAD
+
+[provide]
+sdeventplus = sdeventplus_dep