meson: add missing dependencies and wraps
There were a number of headers used by the repository that were
missing explicit dependency information in the `meson.build`. Add
these (CLI11, cereal, nlohmann-json) and the corresponding meson
wrap files so that the whole project can be built freestanding.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib54d18bc81690450116391fecdce996048f6ab39
diff --git a/meson.build b/meson.build
index 1b8ff14..87fd97b 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,7 @@
license: 'Apache-2.0',
version: '0.1',
)
+cpp = meson.get_compiler('cpp')
build_host_gpios = get_option('host-gpios')
@@ -71,6 +72,42 @@
libgpiod = dependency('libgpiod', version : '>=1.4.1')
fmt = dependency('fmt')
+if cpp.has_header('nlohmann/json.hpp')
+ nlohmann_json = declare_dependency()
+else
+ subproject('nlohmann-json')
+ nlohmann_json = declare_dependency(
+ include_directories: [
+ 'subprojects/nlohmann-json/single_include',
+ 'subprojects/nlohmann-json/single_include/nlohmann',
+ ]
+ )
+endif
+
+if cpp.has_header('CLI/CLI.hpp')
+ CLI11 = declare_dependency()
+else
+ CLI11 = dependency('CLI11')
+endif
+
+# Get Cereal dependency.
+cereal = dependency('cereal', required: false)
+has_cereal = cpp.has_header_symbol(
+ 'cereal/cereal.hpp',
+ 'cereal::specialize',
+ dependencies: cereal,
+ 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 = cereal_proj.dependency('cereal')
+endif
+
executable('phosphor-host-state-manager',
'host_state_manager.cpp',
'host_state_manager_main.cpp',
@@ -78,8 +115,13 @@
'host_check.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging,
- phosphordbusinterfaces, libgpiod, fmt
+ cereal,
+ fmt,
+ libgpiod,
+ phosphordbusinterfaces,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -90,8 +132,10 @@
'hypervisor_state_manager_main.cpp',
'settings.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging,
- phosphordbusinterfaces,
+ phosphordbusinterfaces,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -102,8 +146,14 @@
'chassis_state_manager_main.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging,
- phosphordbusinterfaces, libgpiod, fmt
+ cereal,
+ fmt,
+ libgpiod,
+ nlohmann_json,
+ phosphordbusinterfaces,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -113,8 +163,10 @@
'chassis_check_power_status.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, phosphorlogging,
- phosphordbusinterfaces, libgpiod
+ libgpiod,
+ phosphordbusinterfaces,
+ phosphorlogging,
+ sdbusplus,
],
implicit_include_directories: true,
install: true
@@ -125,8 +177,11 @@
'bmc_state_manager_main.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging,
- phosphordbusinterfaces, libgpiod
+ libgpiod,
+ phosphordbusinterfaces,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -137,7 +192,10 @@
'settings.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, phosphorlogging, libgpiod
+ cereal,
+ libgpiod,
+ phosphorlogging,
+ sdbusplus,
],
implicit_include_directories: true,
install: true
@@ -149,7 +207,11 @@
'systemd_target_parser.cpp',
'systemd_target_signal.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging
+ CLI11,
+ nlohmann_json,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -160,7 +222,11 @@
'scheduled_host_transition.cpp',
'utils.cpp',
dependencies: [
- sdbusplus, sdeventplus, phosphorlogging, libgpiod
+ cereal,
+ libgpiod,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
install: true
@@ -169,7 +235,8 @@
executable('phosphor-host-reset-recovery',
'host_reset_recovery.cpp',
dependencies: [
- sdbusplus, phosphorlogging
+ phosphorlogging,
+ sdbusplus,
],
implicit_include_directories: true,
install: true
@@ -210,6 +277,7 @@
'systemd_target_parser.cpp',
dependencies: [
gtest,
+ nlohmann_json,
],
implicit_include_directories: true,
include_directories: '../'
@@ -222,7 +290,11 @@
'./test/systemd_signal.cpp',
'systemd_target_signal.cpp',
dependencies: [
- gtest, sdbusplus, sdeventplus, phosphorlogging,
+ gtest,
+ nlohmann_json,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
include_directories: '../'
@@ -236,7 +308,13 @@
'scheduled_host_transition.cpp',
'utils.cpp',
dependencies: [
- gtest, gmock, sdbusplus, sdeventplus, phosphorlogging, libgpiod
+ cereal,
+ gmock,
+ gtest,
+ libgpiod,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
include_directories: '../'
@@ -249,7 +327,10 @@
'./test/hypervisor_state.cpp',
'hypervisor_state_manager.cpp',
dependencies: [
- gtest, sdbusplus, sdeventplus, phosphorlogging,
+ gtest,
+ phosphorlogging,
+ sdbusplus,
+ sdeventplus,
],
implicit_include_directories: true,
include_directories: '../'
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/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
diff --git a/subprojects/nlohmann-json.wrap b/subprojects/nlohmann-json.wrap
new file mode 100644
index 0000000..9096612
--- /dev/null
+++ b/subprojects/nlohmann-json.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/nlohmann/json.git
+revision = HEAD