From 6120d2600227f94b6a1d9b022c2a7d3960d2f1d4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 5 Feb 2026 08:51:42 -0500 Subject: [PATCH 1/2] feat: add option to use system-installed jwt-cpp Add ZM_USE_SYSTEM_JWT_CPP CMake option (default OFF) to allow using system-installed jwt-cpp instead of the vendored version. When enabled, CMake will search for jwt-cpp via find_package(jwt-cpp CONFIG). The vendored jwt-cpp in dep/ is only built when not using system version. Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 22 ++++++++++++++++++++++ dep/CMakeLists.txt | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fdea6da3..f3f68e536 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,10 @@ if(NOT ZM_JWT_BACKEND IN_LIST ZM_JWT_BACKEND_OPTIONS) message(FATAL_ERROR "Invalid value for ZM_JWT_BACKEND. Possible options: ${ZM_JWT_BACKEND_OPTIONS}") endif() +# Option to use system-installed jwt-cpp instead of vendored version +set(ZM_USE_SYSTEM_JWT_CPP "OFF" CACHE BOOL + "Set to ON to use system-installed jwt-cpp instead of the vendored version. default: OFF") + if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc")) set(ZM_RUNDIR "/run/zoneminder") set(ZM_SOCKDIR "/var/lib/zoneminder/sock") @@ -397,6 +401,24 @@ if (${ZM_JWT_BACKEND} STREQUAL "libjwt") endif() endif() +# jwt-cpp (system or vendored) +if (${ZM_JWT_BACKEND} STREQUAL "jwt_cpp") + if(ZM_USE_SYSTEM_JWT_CPP) + find_package(jwt-cpp CONFIG REQUIRED) + if(TARGET jwt-cpp::jwt-cpp) + set(HAVE_SYSTEM_JWT_CPP 1) + set(optlibsfound "${optlibsfound} jwt-cpp(system)") + message(STATUS "Using system-installed jwt-cpp") + else() + message(FATAL_ERROR "System jwt-cpp requested but jwt-cpp::jwt-cpp target not found") + endif() + else() + set(HAVE_SYSTEM_JWT_CPP 0) + set(optlibsfound "${optlibsfound} jwt-cpp(vendored)") + message(STATUS "Using vendored jwt-cpp") + endif() +endif() + # GnuTLS if (${ZM_CRYPTO_BACKEND} STREQUAL "gnutls") find_library(GNUTLS_LIBRARIES gnutls REQUIRED) diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 17197c820..e5b2cfaa5 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -1,4 +1,7 @@ -add_subdirectory(jwt-cpp) +# Only build vendored jwt-cpp if not using system-installed version +if(NOT HAVE_SYSTEM_JWT_CPP) + add_subdirectory(jwt-cpp) +endif() add_subdirectory(libbcrypt) add_subdirectory(RtspServer) add_subdirectory(span-lite) From ef7e986118e7a48b15d85acffca22173420ec2cd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 4 Mar 2026 21:37:16 -0500 Subject: [PATCH 2/2] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3f68e536..b0ba9ba8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,6 +251,9 @@ endif() set(ZM_USE_SYSTEM_JWT_CPP "OFF" CACHE BOOL "Set to ON to use system-installed jwt-cpp instead of the vendored version. default: OFF") +if(ZM_USE_SYSTEM_JWT_CPP AND NOT (ZM_JWT_BACKEND STREQUAL "jwt_cpp")) + message(WARNING "ZM_USE_SYSTEM_JWT_CPP is set but will be ignored because ZM_JWT_BACKEND is not jwt_cpp") +endif() if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc")) set(ZM_RUNDIR "/run/zoneminder") set(ZM_SOCKDIR "/var/lib/zoneminder/sock")