find_package(PkgConfig REQUIRED)
pkg_check_modules(WEBRTCPUSH_GST REQUIRED
    gstreamer-1.0>=1.18
    gstreamer-app-1.0
    gstreamer-webrtc-1.0
    gstreamer-sdp-1.0
    gstreamer-video-1.0
)
pkg_check_modules(WEBRTCPUSH_JSON REQUIRED json-glib-1.0)
pkg_check_modules(WEBRTCPUSH_SOUP REQUIRED libsoup-2.4)
pkg_check_modules(WEBRTCPUSH_JPEG REQUIRED libjpeg)

file(GLOB_RECURSE MODULES_SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/logger/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/delay/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/thread_pool/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/mqtt/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/http/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/browser/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/ipc/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/go_deploy/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/tailscale_deploy/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/webrtcpush/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/runtime_deps/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/wifi_config/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/device_debug/*.c
)

set(MODULES_SOURCES
    ${MODULES_SOURCES}
    PARENT_SCOPE
)

set(MODULES_INCLUDE_DIRS
    ${CMAKE_CURRENT_SOURCE_DIR}/logger
    ${CMAKE_CURRENT_SOURCE_DIR}/delay
    ${CMAKE_CURRENT_SOURCE_DIR}/thread_pool
    ${CMAKE_CURRENT_SOURCE_DIR}/mqtt
    ${CMAKE_CURRENT_SOURCE_DIR}/http
    ${CMAKE_CURRENT_SOURCE_DIR}/browser
    ${CMAKE_CURRENT_SOURCE_DIR}/ipc
    ${CMAKE_CURRENT_SOURCE_DIR}/go_deploy
    ${CMAKE_CURRENT_SOURCE_DIR}/tailscale_deploy
    ${CMAKE_CURRENT_SOURCE_DIR}/webrtcpush
    ${CMAKE_CURRENT_SOURCE_DIR}/runtime_deps
    ${CMAKE_CURRENT_SOURCE_DIR}/wifi_config
    ${CMAKE_CURRENT_SOURCE_DIR}/device_debug
    ${WEBRTCPUSH_GST_INCLUDE_DIRS}
    ${WEBRTCPUSH_JSON_INCLUDE_DIRS}
    ${WEBRTCPUSH_SOUP_INCLUDE_DIRS}
    ${WEBRTCPUSH_JPEG_INCLUDE_DIRS}
    PARENT_SCOPE
)

set(WEBRTCPUSH_LIBRARIES
    ${WEBRTCPUSH_GST_LIBRARIES}
    ${WEBRTCPUSH_JSON_LIBRARIES}
    ${WEBRTCPUSH_SOUP_LIBRARIES}
    ${WEBRTCPUSH_JPEG_LIBRARIES}
    PARENT_SCOPE
)

set(WEBRTCPUSH_CFLAGS
    ${WEBRTCPUSH_GST_CFLAGS_OTHER}
    ${WEBRTCPUSH_JSON_CFLAGS_OTHER}
    ${WEBRTCPUSH_SOUP_CFLAGS_OTHER}
    ${WEBRTCPUSH_JPEG_CFLAGS_OTHER}
    PARENT_SCOPE
)
