build: use nlohmann-json dependency
Many sources files want to use the 'json.hpp' file from nlohmann,
but when this is installed as a subproject it isn't in the default
search path, unless a dependency to it is explicitly added. In
most cases this is pulled in via the 'Thresholds.hpp' file which is
in-turn linked in by the thresholds static library.
In meson, static libraries shouldn't be linked against directly but
instead indirectly through a 'dependency' relationship, otherwise the
implicit header file needs are not able to be communicated up to users
of the library (such as Thresholds -> json.hpp here). Revamp the
static library relationships to use 'dependencies' rather than
'link_with' so that the header file needs are properly expressed.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id78aee6af03f10c555aa84edbe9ec44ac04ec342
diff --git a/meson.build b/meson.build
index 6c55635..90ce161 100644
--- a/meson.build
+++ b/meson.build
@@ -63,11 +63,16 @@
thresholds_a = static_library(
'thresholds_a',
'src/Thresholds.cpp',
- dependencies: [ sdbusplus ],
+ dependencies: [ sdbusplus, nlohmann_json ],
implicit_include_directories: false,
include_directories: 'include',
)
+thresholds_dep = declare_dependency(
+ link_with: [ thresholds_a ],
+ dependencies: [ nlohmann_json ],
+)
+
utils_a = static_library(
'utils_a',
['src/Utils.cpp', 'src/SensorPaths.cpp'],
@@ -76,14 +81,24 @@
include_directories: 'include',
)
+utils_dep = declare_dependency(
+ link_with: [ utils_a ],
+ dependencies: [ sdbusplus ],
+)
+
pwmsensor_a = static_library(
'pwmsensor_a',
'src/PwmSensor.cpp',
- dependencies: [ sdbusplus ],
+ dependencies: [ sdbusplus, thresholds_dep ],
implicit_include_directories: false,
include_directories: 'include',
)
+pwmsensor_dep = declare_dependency(
+ link_with: [ pwmsensor_a ],
+ dependencies: [ sdbusplus, thresholds_dep ],
+)
+
subdir('include')
subdir('service_files')
subdir('src')