add_library(test-plugin SHARED test-plugin.cpp test-plugin.h)
target_link_libraries(test-plugin LomiriSystemSettings Qt::Core Qt::Qml)

add_library(test-plugin2 SHARED test-plugin2.cpp test-plugin2.h)
target_link_libraries(test-plugin2 LomiriSystemSettings Qt::Core Qt::Qml)

add_executable(tst_plugins
    tst_plugins.cpp
    ${CMAKE_SOURCE_DIR}/src/debug.cpp
    ${CMAKE_SOURCE_DIR}/src/item-model.cpp
    ${CMAKE_SOURCE_DIR}/src/plugin-manager.cpp
    ${CMAKE_SOURCE_DIR}/src/plugin.cpp
    ${CMAKE_SOURCE_DIR}/src/debug.h
    ${CMAKE_SOURCE_DIR}/src/item-model.h
    ${CMAKE_SOURCE_DIR}/src/plugin-manager.h
    ${CMAKE_SOURCE_DIR}/src/plugin.h
)
target_include_directories(tst_plugins PRIVATE
    ${CMAKE_SOURCE_DIR}/src
    ${GLIB_INCLUDE_DIRS}
)
target_compile_definitions(tst_plugins PRIVATE
    MANIFEST_DIR="data"
    PLUGIN_MODULE_DIR="${CMAKE_CURRENT_BINARY_DIR}"
    QML_DIR="${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(tst_plugins Qt::Core Qt::Qml Qt::Test LomiriSystemSettings ${GLIB_LDFLAGS})
add_test(tst_plugins tst_plugins)
set_tests_properties(tst_plugins PROPERTIES ENVIRONMENT
    "QT_QPA_PLATFORM=minimal;XDG_DATA_DIRS=${CMAKE_CURRENT_SOURCE_DIR}"
)
