[extra-cmake-modules] modules: ECMAddTests: make NAME_PREFIX only apply to the test, not the target
Alex Merry
alex.merry at kde.org
Sat Jun 21 15:42:41 UTC 2014
Git commit f6f1e8c7b8321389fe8268fc25254bd512a6f399 by Alex Merry.
Committed on 15/06/2014 at 16:21.
Pushed by alexmerry into branch 'master'.
ECMAddTests: make NAME_PREFIX only apply to the test, not the target
David Faure and Patrick Spendrin have convinced me that NAME_PREFIX
should be informational only, and not be used to prevent clashes, since
it makes things confusing when you run tests manually.
This is a SIC change (although in practice only kio and kconfig should
be affected, currently).
REVIEW: 118768
CCMAIL: kde-frameworks-devel at kde.org
CCMAIL: kde-buildsystem at kde.org
M +21 -14 modules/ECMAddTests.cmake
http://commits.kde.org/extra-cmake-modules/f6f1e8c7b8321389fe8268fc25254bd512a6f399
diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake
index 6cc20b6..ed1e0f6 100644
--- a/modules/ECMAddTests.cmake
+++ b/modules/ECMAddTests.cmake
@@ -12,12 +12,19 @@
# [GUI])
#
# Add a new unit test using the passed source files. The parameter TEST_NAME is
-# used to set the name of the resulting test. It may be omitted if there is
-# exactly one source file. In that case the name of the source file (without the
-# file extension) will be used as the test name. If the flag GUI is passed the
-# test binary will be a GUI executable, otherwise the resulting binary will be a
-# console application. The test will be linked against the libraries and/or
-# targets passed to LINK_LIBRARIES.
+# used to set the name of the resulting test, and the target built for and run
+# by the test. It may be omitted if there is exactly one source file. In that
+# case the name of the source file (without the file extension) will be used as
+# the test name.
+#
+# If NAME_PREFIX is given, this prefix will be prepended to the test name, but
+# not the target name. As a result, it will not prevent clashes between tests
+# with the same name in different parts of the project, but it can be used to
+# give an indication of where to look for a failing test.
+#
+# If the flag GUI is passed the test binary will be a GUI executable, otherwise
+# the resulting binary will be a console application. The test will be linked
+# against the libraries and/or targets passed to LINK_LIBRARIES.
#
#
# ::
@@ -54,23 +61,23 @@ function(ecm_add_test)
set(_sources ${ECM_ADD_TEST_UNPARSED_ARGUMENTS})
list(LENGTH _sources _sourceCount)
if(ECM_ADD_TEST_TEST_NAME)
- set(_testname ${ECM_ADD_TEST_TEST_NAME})
+ set(_targetname ${ECM_ADD_TEST_TEST_NAME})
elseif(${_sourceCount} EQUAL "1")
#use the source file name without extension as the testname
- get_filename_component(_testname ${_sources} NAME_WE)
+ get_filename_component(_targetname ${_sources} NAME_WE)
else()
#more than one source file passed, but no test name given -> error
message(FATAL_ERROR "ecm_add_test() called with multiple source files but without setting \"TEST_NAME\"")
endif()
- set(_testname "${ECM_ADD_TEST_NAME_PREFIX}${_testname}")
- add_executable(${_testname} ${_sources})
+ set(_testname "${ECM_ADD_TEST_NAME_PREFIX}${_targetname}")
+ add_executable(${_targetname} ${_sources})
if(NOT ECM_ADD_TEST_GUI)
- ecm_mark_nongui_executable(${_testname})
+ ecm_mark_nongui_executable(${_targetname})
endif()
- add_test(NAME ${_testname} COMMAND ${_testname})
- target_link_libraries(${_testname} ${ECM_ADD_TEST_LINK_LIBRARIES})
- ecm_mark_as_test(${_testname})
+ add_test(NAME ${_testname} COMMAND ${_targetname})
+ target_link_libraries(${_targetname} ${ECM_ADD_TEST_LINK_LIBRARIES})
+ ecm_mark_as_test(${_targetname})
endfunction()
function(ecm_add_tests)
More information about the Kde-buildsystem
mailing list