Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ZM_USE_SYSTEM_JWT_CPP option is only meaningful when ZM_JWT_BACKEND is set to "jwt_cpp". If a user sets ZM_USE_SYSTEM_JWT_CPP to ON but uses the libjwt backend, the option is silently ignored, which could be confusing.

Consider adding a warning message after line 252 to inform users about this:
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()

This helps users understand the relationship between these options.

Suggested change
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()

Copilot uses AI. Check for mistakes.
if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
set(ZM_RUNDIR "/run/zoneminder")
set(ZM_SOCKDIR "/var/lib/zoneminder/sock")
Expand Down Expand Up @@ -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()
Comment on lines +404 to +420
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable HAVE_SYSTEM_JWT_CPP is only set when ZM_JWT_BACKEND equals "jwt_cpp", but it's used unconditionally in dep/CMakeLists.txt. When ZM_JWT_BACKEND is set to "libjwt", HAVE_SYSTEM_JWT_CPP will be undefined, which could cause CMake to either error or treat it as false.

To fix this, initialize HAVE_SYSTEM_JWT_CPP to 0 before the jwt-cpp backend check. Add this line before line 404:
set(HAVE_SYSTEM_JWT_CPP 0)

This ensures the variable is always defined regardless of which JWT backend is selected.

Copilot uses AI. Check for mistakes.

# GnuTLS
if (${ZM_CRYPTO_BACKEND} STREQUAL "gnutls")
find_library(GNUTLS_LIBRARIES gnutls REQUIRED)
Expand Down
5 changes: 4 additions & 1 deletion dep/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Loading