# streamer-tools OBS Camera Plugin - core library
#
# No OBS dependency by design (see docs/superpowers/specs/
# 2026-09-06-obs-camera-plugin-design.md in the streamer-tools repo) --
# this must build and test headlessly on every platform.

set(STPLUGIN_CORE_SOURCES
    src/core.cpp
    src/json.cpp
    src/http_common.cpp
    src/api_client.cpp
    src/session_types.cpp
    src/session.cpp
)

# HTTP backend, one per platform. See core/include/stplugin/http.h for why
# this is split rather than using libcurl everywhere.
if(WIN32)
    list(APPEND STPLUGIN_CORE_SOURCES src/http_winhttp.cpp)
else()
    list(APPEND STPLUGIN_CORE_SOURCES src/http_curl.cpp)
endif()

add_library(stplugin_core STATIC ${STPLUGIN_CORE_SOURCES})

target_include_directories(stplugin_core
    PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(stplugin_core
    PUBLIC
        LiveKit::livekit
)

if(WIN32)
    target_link_libraries(stplugin_core PRIVATE winhttp)
else()
    find_package(CURL REQUIRED)
    target_link_libraries(stplugin_core PRIVATE CURL::libcurl)
endif()

find_package(Threads REQUIRED)
target_link_libraries(stplugin_core PUBLIC Threads::Threads)

target_compile_definitions(stplugin_core PRIVATE
    STPLUGIN_CORE_VERSION="${PROJECT_VERSION}"
    STPLUGIN_LIVEKIT_SDK_VERSION="${LIVEKIT_SDK_VERSION_RESOLVED}"
)

set_target_properties(stplugin_core PROPERTIES
    POSITION_INDEPENDENT_CODE ON
)

add_subdirectory(tests)
