build: Fix cereal dependency
We should be using the CMake build provided by the project instead of
trying to work around the subproject system manually.
Change-Id: I074a8ec8b00a9884b092d11fbb6d09b1e76d2dee
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meson.build b/meson.build
index b2fe71e..3a121be 100644
--- a/meson.build
+++ b/meson.build
@@ -42,13 +42,21 @@
)
# Get Cereal dependency.
-if cpp.has_header('cereal/cereal.hpp')
- cereal_dep = declare_dependency()
-else
- subproject('cereal', required: false)
- cereal_dep = declare_dependency(
- include_directories: [ 'subprojects/cereal/include' ],
- )
+cereal_dep = dependency('cereal', required: false)
+has_cereal = cpp.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.get_variable('cm_cereal_dep')
endif
# Find the installed YAML directory, either from a configure option or