qt_add_executable(sloposk
    main.cpp
    backend/TextBackend.h
    backend/InputMethodProtocol.h
    backend/KWinInputMethod.h backend/KWinInputMethod.cpp
    backend/KWinInputContext.h backend/KWinInputContext.cpp
    window/FloatingWindow.h window/FloatingWindow.cpp
)

qt6_generate_wayland_protocol_client_sources(sloposk PRIVATE_CODE FILES
    ${WAYLAND_PROTOCOLS_DIR}/unstable/input-method/input-method-unstable-v1.xml
)
# Generated code lacks the core-protocol include (see backend/InputMethodProtocol.h).
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/qwayland-input-method-unstable-v1.cpp
    PROPERTIES COMPILE_OPTIONS "-include;wayland-client-protocol.h")

# QML lives in the top-level qml/ dir; alias each file so the module sees it at its root.
set(SLOPOSK_QML_FILES
    Main.qml
)
list(TRANSFORM SLOPOSK_QML_FILES PREPEND ${PROJECT_SOURCE_DIR}/qml/ OUTPUT_VARIABLE sloposk_qml_paths)
foreach(file IN LISTS SLOPOSK_QML_FILES)
    set_source_files_properties(${PROJECT_SOURCE_DIR}/qml/${file} PROPERTIES QT_RESOURCE_ALIAS ${file})
endforeach()

qt_add_qml_module(sloposk
    URI Sloposk
    QML_FILES ${sloposk_qml_paths}
)

target_include_directories(sloposk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(sloposk PRIVATE
    Qt6::Gui
    Qt6::Quick
    Qt6::WaylandClient
    LayerShellQt::Interface
    PkgConfig::XKB
    PkgConfig::WAYLAND
)

install(TARGETS sloposk)
