add_executable(scarchat
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    connection/client_connection.cpp
    connection/client_connection.h
    config/client_config.cpp
    config/client_config.h
    ui/login_dialog.cpp
    ui/login_dialog.h
    ui/chat_widget.cpp
    ui/chat_widget.h
    ui/user_list_widget.cpp
    ui/user_list_widget.h
    ui/video_grid_widget.cpp
    ui/video_grid_widget.h
    media/camera_capture.cpp
    media/camera_capture.h
    media/screen_capture.cpp
    media/screen_capture.h
    media/video_encoder.cpp
    media/video_encoder.h
    media/video_decoder.cpp
    media/video_decoder.h
    resources/resources.qrc
)

target_include_directories(scarchat PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(scarchat PRIVATE
    scarchat_shared
    Qt6::Core
    Qt6::Gui
    Qt6::Widgets
    Qt6::Network
    Qt6::Sql
    Boost::system
    OpenSSL::SSL
    OpenSSL::Crypto
)

# Platform-specific media libraries
if(UNIX AND NOT APPLE)
    # Find sdbus-c++ for xdg-desktop-portal communication
    find_package(PkgConfig REQUIRED)
    pkg_check_modules(SDBUS REQUIRED IMPORTED_TARGET sdbus-c++)
    pkg_check_modules(PIPEWIRE REQUIRED IMPORTED_TARGET libpipewire-0.3)
    pkg_check_modules(LIBAVCODEC REQUIRED IMPORTED_TARGET libavcodec)
    pkg_check_modules(LIBAVUTIL REQUIRED IMPORTED_TARGET libavutil)
    pkg_check_modules(LIBSWSCALE REQUIRED IMPORTED_TARGET libswscale)
    
    target_link_libraries(scarchat PRIVATE
        PkgConfig::SDBUS
        PkgConfig::PIPEWIRE
        PkgConfig::LIBAVCODEC
        PkgConfig::LIBAVUTIL
        PkgConfig::LIBSWSCALE
    )
endif()

if(WIN32)
    target_link_libraries(scarchat PRIVATE
        avcodec
        avformat
        avutil
    )
endif()

# Install
install(TARGETS scarchat
    RUNTIME DESTINATION bin
)
