add_library(QSferaResources SHARED
    client.qrc
    core_theme.qrc
    loadresources.cpp
    resources.cpp
    qmlresources.cpp
    themewatcher.cpp
    template.cpp
    fonticon.cpp
)

generate_theme(QSferaResources QSFERA_SIDEBAR_ICONS)

# make them available to the whole project
set(QSFERA_SIDEBAR_ICONS ${QSFERA_SIDEBAR_ICONS} CACHE INTERNAL "Sidebar icons" FORCE)

target_link_libraries(QSferaResources PUBLIC Qt::Core Qt::Gui Qt::Quick)
apply_common_target_settings(QSferaResources)
target_include_directories(QSferaResources PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>)
target_compile_definitions(QSferaResources PRIVATE APPLICATION_SHORTNAME="${APPLICATION_SHORTNAME}")

set_target_properties(QSferaResources PROPERTIES
    OUTPUT_NAME "QSferaResources"
    AUTOUIC ON
    AUTORCC ON
    VERSION ${MIRALL_VERSION}
    SOVERSION ${MIRALL_SOVERSION}
)

generate_export_header(QSferaResources
        EXPORT_MACRO_NAME QSFERA_RESOURCES_EXPORT
        EXPORT_FILE_NAME qsferaresourceslib.h
        STATIC_DEFINE QSFERA_BUILT_AS_STATIC
)

# Handle Translations, pick all desktop_*.ts files from translations directory.
file(GLOB desktop_translations ${CMAKE_SOURCE_DIR}/translations/desktop_*.ts)
qt_add_lrelease(QSferaResources TS_FILES ${desktop_translations} QM_FILES_OUTPUT_VARIABLE desktop_compiled_translations)
add_resources_to_target(
    TARGET QSferaResources
    PREFIX translations
    FILES "${desktop_compiled_translations}"
)

ecm_add_qml_module(QSferaResources
        URI eu.QSfera.resources
        VERSION 1.0
        NAMESPACE OCC
        GENERATE_PLUGIN_SOURCE
)

ecm_finalize_qml_module(QSferaResources DESTINATION ${KDE_INSTALL_QMLDIR})

install(TARGETS QSferaResources EXPORT ${APPLICATION_SHORTNAME}Config ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
