Commit a8ad1877 authored by Alexander Lohnau's avatar Alexander Lohnau 💬 Committed by Nate Graham
Browse files

Avoid compiling source files for tests multiple times

Instead use a static lib for the files and link against that.
parent 6befb657
......@@ -8,26 +8,27 @@ set(systemtray_SRCS
systemtraysettings.cpp
systemtraymodel.cpp
sortedsystemtraymodel.cpp
systemtray.cpp
)
ecm_qt_declare_logging_category(systemtray_SRCS HEADER debug.h
IDENTIFIER SYSTEM_TRAY
CATEGORY_NAME kde.systemtray
DEFAULT_SEVERITY Info)
add_library(org.kde.plasma.private.systemtray MODULE ${systemtray_SRCS})
add_library(systemtraymodel_static STATIC ${systemtray_SRCS})
target_link_libraries(systemtraymodel_static
Qt::Gui
Qt::Quick
Qt::DBus
KF5::XmlGui
KF5::I18n
KF5::ItemModels
KF5::Plasma)
add_library(org.kde.plasma.private.systemtray MODULE systemtray.cpp)
kcoreaddons_desktop_to_json(org.kde.plasma.private.systemtray package/metadata.desktop)
target_link_libraries(org.kde.plasma.private.systemtray
Qt::Gui
Qt::Quick
Qt::DBus
KF5::Plasma
KF5::XmlGui
KF5::I18n
KF5::ItemModels)
target_link_libraries(org.kde.plasma.private.systemtray systemtraymodel_static)
install(TARGETS org.kde.plasma.private.systemtray DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
......
include(ECMAddTests)
set(systemtraymodel_test_SRCS
../dbusserviceobserver.cpp
../plasmoidregistry.cpp
../systemtraysettings.cpp
../systemtraymodel.cpp
../sortedsystemtraymodel.cpp
)
ecm_qt_declare_logging_category(systemtraymodel_test_SRCS HEADER debug.h
IDENTIFIER SYSTEM_TRAY
CATEGORY_NAME kde.systemtray
DEFAULT_SEVERITY Info)
add_library(systemtraymodel_test STATIC ${systemtraymodel_test_SRCS})
target_link_libraries(systemtraymodel_test
Qt::Core
Qt::DBus
Qt::Quick
KF5::CoreAddons
KF5::I18n
KF5::ItemModels
KF5::Plasma
KF5::XmlGui
)
ecm_add_tests(systemtraymodeltest.cpp
LINK_LIBRARIES systemtraymodel_test
LINK_LIBRARIES systemtraymodel_static
Qt::Test
)
......@@ -29,11 +29,8 @@ configure_file(config-klipper.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-klipper
ki18n_wrap_ui(libklipper_common_SRCS generalconfig.ui actionsconfig.ui editactiondialog.ui)
kconfig_add_kcfg_files(libklipper_common_SRCS klippersettings.kcfgc)
set(klipper_SRCS ${libklipper_common_SRCS} main.cpp tray.cpp)
add_executable(klipper ${klipper_SRCS})
target_link_libraries(klipper
add_library(libklipper_common_static STATIC ${libklipper_common_SRCS})
target_link_libraries(libklipper_common_static
Qt::Concurrent
KF5::ConfigGui
KF5::CoreAddons
......@@ -48,12 +45,16 @@ target_link_libraries(klipper
KF5::WidgetsAddons
KF5::XmlGui
${ZLIB_LIBRARY}
systemclipboard
)
systemclipboard)
if (X11_FOUND)
target_link_libraries(klipper XCB::XCB Qt::X11Extras)
target_link_libraries(libklipper_common_static XCB::XCB Qt::X11Extras)
endif()
add_executable(klipper main.cpp tray.cpp)
target_link_libraries(klipper
libklipper_common_static
)
install(TARGETS klipper ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES org.kde.klipper.desktop DESTINATION ${KDE_INSTALL_APPDIR})
......
add_definitions(-DKLIPPER_UNIT_TEST)
include(ECMMarkAsTest)
########################################################
# Test History
########################################################
set(libklipper_test_SRCS)
ecm_qt_declare_logging_category(libklipper_test_SRCS HEADER klipper_debug.h IDENTIFIER KLIPPER_LOG CATEGORY_NAME org.kde.klipper)
set(testHistory_SRCS
${libklipper_test_SRCS}
historytest.cpp
../history.cpp
../historyimageitem.cpp
../historyitem.cpp
../historystringitem.cpp
../historyurlitem.cpp
../historymodel.cpp
)
add_executable(testHistory ${testHistory_SRCS})
# Test History
add_executable(testHistory historytest.cpp)
target_link_libraries(testHistory
Qt::Test
Qt::Widgets # QAction
KF5::CoreAddons # KUrlMimeData
KF5::I18n
libklipper_common_static
)
add_test(NAME klipper-testHistory COMMAND testHistory)
ecm_mark_as_test(testHistory)
########################################################
# Test History Model
########################################################
set(testHistoryModel_SRCS
historymodeltest.cpp
../historymodel.cpp
../historyimageitem.cpp
../historyitem.cpp
../historystringitem.cpp
../historyurlitem.cpp
${libklipper_test_SRCS}
)
add_executable(testHistoryModel ${testHistoryModel_SRCS})
add_executable(testHistoryModel historymodeltest.cpp)
target_link_libraries(testHistoryModel
Qt::Test
Qt::Widgets # QAction
KF5::CoreAddons # KUrlMimeData
KF5::I18n
libklipper_common_static
)
add_test(NAME klipper-testHistoryModel COMMAND testHistoryModel)
ecm_mark_as_test(testHistoryModel)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment