qt_add_executable(mithra-shell main.cpp src/iconprovider.h src/iconprovider.cpp
                  src/cursorcontrol.h src/cursorcontrol.cpp
                  src/vtguard.h src/vtguard.cpp
                  src/dockoutput.h src/dockoutput.cpp)
find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor GuiPrivate)
pkg_check_modules(WAYLAND_SERVER REQUIRED IMPORTED_TARGET wayland-server)
pkg_check_modules(UDEV REQUIRED IMPORTED_TARGET libudev)

qt_add_qml_module(mithra-shell
    URI MithraShell
    VERSION 1.0
    SOURCES
        src/appmodel.h src/appmodel.cpp
        src/appproxy.h src/appproxy.cpp
        src/artprovider.h src/artprovider.cpp
        src/statusinfo.h src/statusinfo.cpp
        src/windowpolicy.h src/windowpolicy.cpp
        src/notificationserver.h src/notificationserver.cpp
        src/stripshaper.h src/stripshaper.cpp
        src/wifimanager.h src/wifimanager.cpp
        src/powercontrol.h src/powercontrol.cpp
        src/bluetoothmanager.h src/bluetoothmanager.cpp
        src/audiomanager.h src/audiomanager.cpp
        src/clockcontrol.h src/clockcontrol.cpp
        src/inputtuning.h src/inputtuning.cpp
        src/volumekeys.h src/volumekeys.cpp
        src/sessioncontrol.h src/sessioncontrol.cpp
        src/idlewatcher.h src/idlewatcher.cpp
        src/screensaverservice.h src/screensaverservice.cpp
        src/taskmetrics.h src/taskmetrics.cpp
        src/xwaylandbridge.h src/xwaylandbridge.cpp
        src/clientsurfaceitem.h src/clientsurfaceitem.cpp
        src/keyboardforwarder.h src/keyboardforwarder.cpp
        ../lock/src/pamauthenticator.h ../lock/src/pamauthenticator.cpp
    QML_FILES
        Main.qml
        StatusBar.qml
        CirclesRow.qml
        CircleButton.qml
        AppGrid.qml
        HomePreview.qml
        NavGlyph.qml
        EdgeGestures.qml
        SettingsView.qml
        SettingSlider.qml
        QuickAccessPanel.qml
        QuickAction.qml
        ProfilePicker.qml
        TaskManager.qml
        BottomDrawer.qml
        TileMenu.qml
        PowerMenu.qml
        AppSwitcher.qml
        KeyboardPanel.qml
        LockScreen.qml
)

pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb xcb-shape xcb-screensaver xcb-composite)

qt_add_resources(mithra-shell "shellfonts"
    PREFIX "/fonts"
    BASE ${CMAKE_SOURCE_DIR}/kit/fonts
    FILES ${CMAKE_SOURCE_DIR}/kit/fonts/Cabin.ttf)
qt_add_resources(mithra-shell "shellassets"
    PREFIX "/"
    BASE ${CMAKE_CURRENT_SOURCE_DIR}
    FILES assets/gear.png assets/avatar.png)

target_include_directories(mithra-shell PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${CMAKE_SOURCE_DIR}/lock/src ${PAM_INCLUDE_DIR})
target_link_libraries(mithra-shell PRIVATE Qt6::Quick Qt6::DBus PkgConfig::XCB
                                           Qt6::WaylandCompositor Qt6::GuiPrivate PkgConfig::WAYLAND_SERVER PkgConfig::UDEV ${PAM_LIBRARIES}
                                           mithrakitplugin)

install(TARGETS mithra-shell RUNTIME DESTINATION bin)

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS WaylandHost.qml)
file(SHA256 "${CMAKE_CURRENT_SOURCE_DIR}/WaylandHost.qml" wayland_host_hash)
target_compile_definitions(mithra-shell PRIVATE
    MITHRA_WAYLAND_HOST_URL="qrc:/wayland/${wayland_host_hash}/WaylandHost.qml")
qt_add_resources(mithra-shell "waylandhost"
    PREFIX "/wayland/${wayland_host_hash}"
    BASE ${CMAKE_CURRENT_SOURCE_DIR}
    FILES WaylandHost.qml)
