From c0aa4d1692a6b7b8c00b8d9203379469cf3be531 Mon Sep 17 00:00:00 2001 From: Andreas Pakulat Date: Sun, 17 Jun 2007 21:13:37 +0000 Subject: As discussed on kde-buildsystem rename kde4_add_test to kde4_add_test_executable and introduce kde4_add_unit_test for unittests, which combines kde4_add_test_executable and cmake's add_test. Port the kdelibs module, the other modules will be comitted shortly. CCMAIL: kde-core-devel@kde.org svn path=/trunk/KDE/kdelibs/; revision=676857 --- modules/FindKDE4Internal.cmake | 15 +++++++++++++++ modules/KDE4Macros.cmake | 22 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index bfcd1f07..1857f0cc 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -178,6 +178,21 @@ # Equivalent to ADD_LIBRARY(), but additionally it supports KDE4_ENABLE_FINAL # and under Windows it adds a -DMAKE__LIB definition to the compilation. # +# KDE4_ADD_UNIT_TEST (testname [TESTNAME targetname] file1 ... fileN) +# add a unit test, which is executed when running make test +# it will be built with RPATH poiting to the build dir +# The targets are always created, but only built for the "all" +# target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target +# are created but not built by default. You can build them by manually building the target. +# The name of the target can be specified using TESTNAME , if it is not given +# the macro will default to the +# +# KDE4_ADD_TEST_EXECUTABLE (name file1 ... fileN) +# add an test executable +# it will be built with RPATH poiting to the build dir +# The targets are always created, but only built for the "all" +# target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target +# are created but not built by default. You can build them by manually building the target. # KDE4_INSTALL_ICONS( path theme) # Installs all png and svgz files in the current directory to the icon # directoy given in path, in the subdirectory for the given icon theme. diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake index 0988291b..9e5494a6 100644 --- a/modules/KDE4Macros.cmake +++ b/modules/KDE4Macros.cmake @@ -742,13 +742,31 @@ macro (KDE4_ADD_KDEINIT_EXECUTABLE _target_NAME ) endmacro (KDE4_ADD_KDEINIT_EXECUTABLE) +# add a unit test, which is executed when running make test +# it will be built with RPATH poiting to the build dir +# The targets are always created, but only built for the "all" +# target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target +# are created but not built by default. You can build them by manually building the target. +# The name of the target can be specified using TESTNAME , if it is not given +# the macro will default to the +macro (KDE4_ADD_UNIT_TEST _test_NAME) + set(_srcList ${ARGN}) + set(_targetName ${_test_NAME}) + if( ${ARGV1} STREQUAL "TESTNAME" ) + set(_targetName ${ARGV2}) + LIST(REMOVE_AT _srcList 0 1) + endif( ${ARGV1} STREQUAL "TESTNAME" ) + kde4_add_test_executable( ${_test_NAME} ${_srcList} ) + get_target_property(_target_OUTPUT_PATH ${_test_NAME} EXECUTABLE_OUTPUT_PATH) + add_test( ${_targetName} ${_target_OUTPUT_PATH}/${_test_NAME} ) +endmacro (KDE4_ADD_UNIT_TEST) # add an test executable # it will be built with RPATH poiting to the build dir # The targets are always created, but only built for the "all" # target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target # are created but not built by default. You can build them by manually building the target. -macro (KDE4_ADD_TEST _target_NAME) +macro (KDE4_ADD_TEST_EXECUTABLE _target_NAME) set(_add_executable_param) @@ -770,7 +788,7 @@ macro (KDE4_ADD_TEST _target_NAME) target_link_libraries(${_target_NAME} ${QT_QTMAIN_LIBRARY}) endif (WIN32) -endmacro (KDE4_ADD_TEST) +endmacro (KDE4_ADD_TEST_EXECUTABLE) macro (KDE4_ADD_EXECUTABLE _target_NAME) -- cgit v1.2.1