# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.22)

project(plasma-task-group-shortcuts VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)

find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

include(GNUInstallDirs)
include(CTest)

find_package(Qt6 REQUIRED COMPONENTS DBus Gui WaylandClient)
find_package(KF6 REQUIRED COMPONENTS Config GlobalAccel Service)
find_package(LibTaskManager REQUIRED)
find_package(PlasmaWaylandProtocols REQUIRED)
find_package(XKB REQUIRED)

add_executable(plasma-task-group-shortcuts
    keyboardlayout.cpp
    main.cpp
    taskselection.cpp
)
qt6_generate_wayland_protocol_client_sources(plasma-task-group-shortcuts
    PRIVATE_CODE
    FILES ${PLASMA_WAYLAND_PROTOCOLS_DIR}/keystate.xml
)
target_link_libraries(plasma-task-group-shortcuts PRIVATE
    Qt6::Gui
    Qt6::DBus
    Qt6::WaylandClient
    KF6::ConfigCore
    KF6::GlobalAccel
    KF6::Service
    PW::LibTaskManager
    XKB::XKB
)

install(TARGETS plasma-task-group-shortcuts DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES se.ajpanton.plasma-task-group-shortcuts.desktop
    DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES se.ajpanton.plasma-task-group-shortcuts-autostart.desktop
    DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/autostart)

if(BUILD_TESTING)
    find_package(Qt6 REQUIRED COMPONENTS Test)
    add_executable(test-taskselection
        tests/test-taskselection.cpp
        taskselection.cpp
    )
    target_link_libraries(test-taskselection PRIVATE
        Qt6::Test
        KF6::ConfigCore
        KF6::Service
        PW::LibTaskManager
    )
    add_test(NAME taskselection COMMAND test-taskselection)

    add_executable(test-keyboardlayout
        tests/test-keyboardlayout.cpp
        keyboardlayout.cpp
    )
    target_link_libraries(test-keyboardlayout PRIVATE
        Qt6::Test
        Qt6::Gui
        Qt6::DBus
        XKB::XKB
    )
    add_test(NAME keyboardlayout COMMAND test-keyboardlayout)
endif()
