# SPDX-License-Identifier: MPL-2.0
#
# sequa::host_web : sert studio/ui/dist en HTTP local et ouvre le navigateur.
# Dépendance privée : ixwebsocket::ixwebsocket (serveur HTTP). ws2_32 sous Windows
# pour la vérification exclusive du port (voir core/src/server/server.cpp).

add_library(sequa_host_web
    src/ui_server.cpp
    src/urls.cpp
    src/browser.cpp)
add_library(sequa::host_web ALIAS sequa_host_web)

target_include_directories(sequa_host_web
    PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(sequa_host_web PUBLIC cxx_std_20)
target_link_libraries(sequa_host_web PRIVATE ixwebsocket::ixwebsocket)
if(WIN32)
    target_link_libraries(sequa_host_web PRIVATE ws2_32) # vérification exclusive du port
endif()
sequa_target_defaults(sequa_host_web)

if(SEQUA_BUILD_TESTS)
    add_executable(sequa_host_web_tests
        tests/main.cpp
        tests/test_ui_server.cpp
        tests/test_urls.cpp
        tests/test_browser.cpp)
    target_link_libraries(sequa_host_web_tests PRIVATE
        sequa::host_web doctest::doctest ixwebsocket::ixwebsocket)
    sequa_target_defaults(sequa_host_web_tests)
    doctest_discover_tests(sequa_host_web_tests)
endif()
