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 <noreply@anthropic.com>
pull/4596/head
Isaac Connor 2026-02-05 08:51:42 -05:00
parent 94f3a5771b
commit 6120d26002
2 changed files with 26 additions and 1 deletions

View File

@ -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)

View File

@ -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)