project(macroeditor)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
find_package(KF6Wallet REQUIRED)
find_package(X11)

set(macroeditor_SRC
    macroeditor.cpp
    macroeditor.hpp
    macroeditor.qrc
    macroeditor.json
    ../../gscreen.cpp
)

# Create directories for resource files
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources)

# Create or copy necessary resources
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../shared/default_icon.png ${CMAKE_CURRENT_SOURCE_DIR}/resources/icon.png COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../shared/default_menu_icon.png ${CMAKE_CURRENT_SOURCE_DIR}/resources/menu_icon.png COPYONLY)

add_library(macroeditor SHARED ${macroeditor_SRC})

target_compile_definitions(macroeditor PRIVATE HAVE_KF6WALLET)
if(X11_FOUND)
    target_compile_definitions(macroeditor PRIVATE HAVE_X11)
    target_link_libraries(macroeditor ${X11_LIBRARIES})
endif()

target_link_libraries(macroeditor
    Qt6::Core
    Qt6::Gui
    Qt6::Widgets
    Qt6::DBus
    KF6::Wallet
)

install(TARGETS macroeditor DESTINATION lib/g19daemon/plugins)