add_executable(phonecast-support-tests support_tests.cpp)
target_link_libraries(phonecast-support-tests PRIVATE phonecast-network phonecast-support phonecast-vr)
phonecast_enable_warnings(phonecast-support-tests)
if(WIN32)
    target_link_libraries(phonecast-support-tests PRIVATE ws2_32)
endif()
if(MINGW)
    target_link_options(phonecast-support-tests PRIVATE -static -static-libgcc -static-libstdc++)
endif()
if(NOT CMAKE_CROSSCOMPILING)
    add_test(NAME phonecast-support-tests COMMAND phonecast-support-tests)
endif()

add_executable(phonecast-tests phonecast_tests.cpp)
target_compile_features(phonecast-tests PRIVATE cxx_std_17)
target_link_libraries(phonecast-tests PRIVATE phonecast-receiver-lib)
phonecast_enable_warnings(phonecast-tests)
add_test(NAME phonecast-unit-tests COMMAND phonecast-tests)

add_executable(phonecast-audio-tests audio_tests.cpp)
target_compile_features(phonecast-audio-tests PRIVATE cxx_std_17)
target_link_libraries(phonecast-audio-tests PRIVATE phonecast-core phonecast-vr phonecast-network)
phonecast_enable_warnings(phonecast-audio-tests)
if(MINGW)
    target_link_options(phonecast-audio-tests PRIVATE -static -static-libgcc -static-libstdc++)
endif()
if(NOT CMAKE_CROSSCOMPILING)
    add_test(NAME phonecast-audio-tests COMMAND phonecast-audio-tests)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND TARGET phonecast-steam-frame)
    add_executable(phonecast-pulse-audio-tests pulse_audio_tests.cpp)
    target_link_libraries(phonecast-pulse-audio-tests PRIVATE phonecast-steam-frame)
    phonecast_enable_warnings(phonecast-pulse-audio-tests)
    add_executable(phonecast-standalone-runtime-tests standalone_runtime_tests.cpp)
    target_link_libraries(phonecast-standalone-runtime-tests PRIVATE phonecast-steam-frame)
    phonecast_enable_warnings(phonecast-standalone-runtime-tests)
    if(NOT CMAKE_CROSSCOMPILING)
        add_test(NAME phonecast-standalone-runtime-tests
            COMMAND phonecast-standalone-runtime-tests)
    endif()
endif()

if(WIN32 AND TARGET phonecast-windows-streaming)
    add_executable(phonecast-mf-decoder-tests mf_decoder_tests.cpp)
    target_link_libraries(phonecast-mf-decoder-tests PRIVATE phonecast-windows-streaming)
    phonecast_enable_warnings(phonecast-mf-decoder-tests)
    if(MINGW)
        target_link_options(phonecast-mf-decoder-tests PRIVATE -static -static-libgcc -static-libstdc++)
    endif()
    add_test(NAME phonecast-mf-sparse-frame-latency
        COMMAND phonecast-mf-decoder-tests "${CMAKE_CURRENT_SOURCE_DIR}/fixtures/sparse-screen.h264")
endif()
