meson: add missing cereal dependency

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie9d814f17a1089ccbbbd9888efe1ca272a62297d
diff --git a/meson.build b/meson.build
index f99ed64..7dc0752 100644
--- a/meson.build
+++ b/meson.build
@@ -63,6 +63,23 @@
 deps = []
 sources = []
 
+cereal_dep = dependency('cereal', required: false)
+has_cereal = cxx.has_header_symbol(
+    'cereal/cereal.hpp',
+    'cereal::specialize',
+    dependencies: cereal_dep,
+    required: false)
+if not has_cereal
+    cereal_opts = import('cmake').subproject_options()
+    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
+    cereal_proj = import('cmake').subproject(
+        'cereal',
+        options: cereal_opts,
+        required: false)
+    assert(cereal_proj.found(), 'cereal is required')
+    cereal_dep = cereal_proj.dependency('cereal')
+endif
+
 nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
 sdeventplus_dep = dependency(
     'sdeventplus',
@@ -87,6 +104,7 @@
 )
 
 deps += [
+    cereal_dep,
     nlohmann_json_dep,
     phosphor_dbus_interfaces_dep,
     phosphor_logging_dep,
diff --git a/subprojects/cereal.wrap b/subprojects/cereal.wrap
new file mode 100644
index 0000000..a4cb7ec
--- /dev/null
+++ b/subprojects/cereal.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+url = https://github.com/USCiLab/cereal.git
+revision = HEAD
+# need at least for C++20 fixes 3e4d1b84cab4891368d2179a61a7ba06a5693e7f