diff options
author | Alex Merry <alex.merry@kde.org> | 2014-06-15 17:21:56 +0100 |
---|---|---|
committer | Alex Merry <alex.merry@kde.org> | 2014-06-21 16:41:16 +0100 |
commit | f6f1e8c7b8321389fe8268fc25254bd512a6f399 (patch) | |
tree | 6929be4b06cd70bacfa23c8b72f5f9af14a462a4 /modules | |
parent | bd22dc73a6da58dea8b709ef27f4c11eb598f42c (diff) | |
download | extra-cmake-modules-f6f1e8c7b8321389fe8268fc25254bd512a6f399.tar.gz extra-cmake-modules-f6f1e8c7b8321389fe8268fc25254bd512a6f399.tar.bz2 |
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@kde.org
CCMAIL: kde-buildsystem@kde.org
Diffstat (limited to 'modules')
-rw-r--r-- | modules/ECMAddTests.cmake | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index 6cc20b65..ed1e0f66 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) |