From 4c5bae17d723d3a183421b0edc9d414637b70a88 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 19 Jul 2025 19:00:17 -0400 Subject: [PATCH] Make nlohmann_json optional --- CMakeLists.txt | 8 +++++++- src/zm_packet.h | 4 ++++ zoneminder-config.cmake | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ffa4399c..421615d05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -591,7 +591,13 @@ if(HAVE_LIBPCRE AND HAVE_PCRE_H) set(ZM_PCRE 1) endif() -find_package(nlohmann_json) +find_package(nlohmann_json CONFIG) +if(nlohmann_json_FOUND) + set(ZM_HAS_NLOHMANN_JSON 1) +else() + set(ZM_HAS_NLOHMANN_JSON 0) + message(AUTHOR_WARNING "nlohmann_json headers weren't found - AI results will not be available") +endif() # Check for mmap and enable in all components set(ZM_MEM_MAPPED 0) diff --git a/src/zm_packet.h b/src/zm_packet.h index fbfa27809..0f5c52a2d 100644 --- a/src/zm_packet.h +++ b/src/zm_packet.h @@ -29,7 +29,9 @@ #include #include +#if HAS_NLOHMANN_JSON #include +#endif extern "C" { #include @@ -61,7 +63,9 @@ class ZMPacket { bool decoded; std::vector zone_stats; std::string alarm_cause; +#if HAS_NLOHMANN_JSON nlohmann::json detections; +#endif public: AVPacket *av_packet() { return packet.get(); } diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 028762d3e..490718a86 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -47,6 +47,7 @@ /* Few ZM options that are needed by the source code */ #cmakedefine ZM_MEM_MAPPED 1 #cmakedefine ZM_HAS_V4L2 1 +#cmakedefine ZM_HAS_NLOHMANN_JSON 1 /* Its safe to assume that signal return type is void. This is a fix for zm_signal.h */ #define RETSIGTYPE void