# Third-party dependency aggregation. Keep vendor projects under this layer so
# the root CMakeLists stays focused on the final executable.

add_subdirectory(mosquitto)

# Native WebRTC sender. Keep the dependency fully vendored and static so the
# Orange Pi does not need a separately installed libdatachannel package.
set(NO_WEBSOCKET ON CACHE BOOL "Disable libdatachannel WebSocket" FORCE)
set(NO_MEDIA OFF CACHE BOOL "Enable libdatachannel media transport" FORCE)
set(NO_EXAMPLES ON CACHE BOOL "Disable libdatachannel examples" FORCE)
set(NO_TESTS ON CACHE BOOL "Disable libdatachannel tests" FORCE)
set(PREFER_SYSTEM_LIB OFF CACHE BOOL "Use vendored libdatachannel dependencies" FORCE)
set(USE_NICE OFF CACHE BOOL "Use bundled libjuice ICE" FORCE)
set(USE_GNUTLS OFF CACHE BOOL "Use OpenSSL" FORCE)
set(USE_MBEDTLS OFF CACHE BOOL "Use OpenSSL" FORCE)
add_subdirectory(libdatachannel EXCLUDE_FROM_ALL)

file(GLOB THIRD_PARTY_ZLOG_SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/zlog/src/*.c
)

list(FILTER THIRD_PARTY_ZLOG_SOURCES EXCLUDE REGEX "zlog-chk-conf\\.c$")
list(FILTER THIRD_PARTY_ZLOG_SOURCES EXCLUDE REGEX "zlog_win\\.c$")

set(THIRD_PARTY_SOURCES
    ${THIRD_PARTY_ZLOG_SOURCES}
    ${CMAKE_CURRENT_SOURCE_DIR}/cjson/cJSON.c
    PARENT_SCOPE
)

set(THIRD_PARTY_INCLUDE_DIRS
    ${CMAKE_CURRENT_SOURCE_DIR}/zlog/src
    ${CMAKE_CURRENT_SOURCE_DIR}/mosquitto/include
    ${CMAKE_CURRENT_SOURCE_DIR}/mosquitto/lib
    ${CMAKE_CURRENT_SOURCE_DIR}/cjson
    PARENT_SCOPE
)
