cmake: use ecm_add_test more

avoid manually adding tests when possible
This commit is contained in:
Pino Toscano 2017-06-06 14:45:10 +02:00
parent 6c03c15c08
commit 8b92058d97

View File

@ -20,22 +20,17 @@ endif()
MACRO(PLASMA_UNIT_TESTS) MACRO(PLASMA_UNIT_TESTS)
FOREACH(_testname ${ARGN}) FOREACH(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp) set(libs Qt5::Qml Qt5::Test KF5::Plasma KF5::PlasmaQuick
target_include_directories(${_testname} PRIVATE "$<BUILD_INTERFACE:$<TARGET_PROPERTY:KF5PlasmaQuick,INCLUDE_DIRECTORIES>>;") KF5::Archive KF5::CoreAddons KF5::ConfigGui KF5::I18n
target_link_libraries(${_testname} Qt5::Qml Qt5::Test KF5::KIOCore KF5::Service KF5::IconThemes
KF5::Plasma KF5::PlasmaQuick KF5::Declarative)
KF5::Archive KF5::CoreAddons
KF5::ConfigGui
KF5::I18n
KF5::KIOCore
KF5::Service
KF5::IconThemes
KF5::Declarative)
if(QT_QTOPENGL_FOUND) if(QT_QTOPENGL_FOUND)
target_link_libraries(${_testname} Qt5::OpenGL) list(APPEND libs Qt5::OpenGL)
endif() endif()
add_test(plasma-${_testname} ${_testname}) ecm_add_test(${_testname}.cpp
ecm_mark_as_test(${_testname}) LINK_LIBRARIES ${libs}
NAME_PREFIX "plasma-")
target_include_directories(${_testname} PRIVATE "$<BUILD_INTERFACE:$<TARGET_PROPERTY:KF5PlasmaQuick,INCLUDE_DIRECTORIES>>;")
ENDFOREACH(_testname) ENDFOREACH(_testname)
ENDMACRO(PLASMA_UNIT_TESTS) ENDMACRO(PLASMA_UNIT_TESTS)
@ -53,8 +48,12 @@ PLASMA_UNIT_TESTS(
# plasmoidpackagetest # plasmoidpackagetest
) )
add_executable(storagetest storagetest.cpp ../src/plasma/private/storage.cpp ../src/plasma/private/storagethread.cpp ../src/plasma/debug_p.cpp) set(storagetest_libs Qt5::Gui Qt5::Test Qt5::Sql KF5::KIOCore KF5::Plasma KF5::CoreAddons)
target_link_libraries(storagetest Qt5::Gui Qt5::Test Qt5::Sql KF5::KIOCore KF5::Plasma KF5::CoreAddons) if(QT_QTOPENGL_FOUND)
list(APPEND storagetest_libs Qt5::OpenGL)
endif()
set(storagetest_srcs storagetest.cpp ../src/plasma/private/storage.cpp ../src/plasma/private/storagethread.cpp ../src/plasma/debug_p.cpp)
ecm_add_test(${storagetest_srcs} TEST_NAME plasma-storagetest LINK_LIBRARIES ${storagetest_libs})
if(HAVE_X11) if(HAVE_X11)
set(dialognativetest_srcs dialognativetest.cpp) set(dialognativetest_srcs dialognativetest.cpp)
@ -65,30 +64,12 @@ set(coronatest_srcs coronatest.cpp)
qt5_add_resources(coronatest_srcs coronatestresources.qrc) qt5_add_resources(coronatest_srcs coronatestresources.qrc)
ecm_add_test(${coronatest_srcs} TEST_NAME coronatest LINK_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Test KF5::KIOCore KF5::Plasma KF5::CoreAddons KF5::XmlGui) ecm_add_test(${coronatest_srcs} TEST_NAME coronatest LINK_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Test KF5::KIOCore KF5::Plasma KF5::CoreAddons KF5::XmlGui)
add_test(plasma-storagetest storagetest) set(sortfiltermodeltest_srcs
ecm_mark_as_test(storagetest)
add_executable(sortfiltermodeltest
sortfiltermodeltest.cpp sortfiltermodeltest.cpp
../src/declarativeimports/core/datamodel.cpp ../src/declarativeimports/core/datamodel.cpp
../src/declarativeimports/core/datasource.cpp ../src/declarativeimports/core/datasource.cpp
) )
ecm_add_test(${sortfiltermodeltest_srcs} TEST_NAME plasma-sortfiltermodeltest LINK_LIBRARIES KF5::Plasma Qt5::Gui Qt5::Test KF5::I18n KF5::Service Qt5::Qml)
target_link_libraries(sortfiltermodeltest
KF5::Plasma
Qt5::Gui
Qt5::Test
KF5::I18n
KF5::Service
Qt5::Qml
)
add_test(plasma-sortfiltermodeltest sortfiltermodeltest)
ecm_mark_as_test(sortfiltermodeltest)
if(QT_QTOPENGL_FOUND)
target_link_libraries(storagetest Qt5::OpenGL)
endif()
#Add a test that i18n is not used directly in any import. #Add a test that i18n is not used directly in any import.