From 7cf3afc38e03d52d76848a6f0aa6d880d5ba97fd Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 22 Jan 2014 15:54:19 +0100 Subject: Mark target created by ecm_add_test as non GUI by default This behaviour can be overriden by passing the GUI flag to the command REVIEW: 115211 --- modules/ECMAddTests.cmake | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'modules/ECMAddTests.cmake') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index ff97d764..67026eca 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -1,19 +1,23 @@ include(ECMMarkAsTest) - +include(ECMMarkNonGuiExecutable) # This file provides the functions ecm_add_test() and ecm_add_tests(). # -# ecm_add_test( TEST_NAME NAME_PREFIX LINK_LIBRARIES ) +# ecm_add_test( TEST_NAME NAME_PREFIX LINK_LIBRARIES [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. # -# ecm_add_tests( NAME_PREFIX LINK_LIBRARIES ) +# ecm_add_tests( NAME_PREFIX LINK_LIBRARIES [GUI]) # # Add a new unit test for every source file passed. The name of the tests will be the name of the # corresponding source file minus the file extension. If NAME_PREFIX is set, that string will be # prepended to each of the unit test names. Each of the unit tests will be linked against the # libraries and/or targets passed in the LINK_LIBRARIES parameter. +# If the flag GUI is passed the test binary will be a GUI executable, otherwise the resulting +# binary will be a console application. # # Copyright (c) 2013, Alexander Richardson, # @@ -21,9 +25,10 @@ include(ECMMarkAsTest) # For details see the accompanying COPYING-CMAKE-SCRIPTS file. function(ecm_add_test) + set(options GUI) set(oneValueArgs TEST_NAME NAME_PREFIX) set(multiValueArgs LINK_LIBRARIES) - cmake_parse_arguments(ECM_ADD_TEST "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(ECM_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(_sources ${ECM_ADD_TEST_UNPARSED_ARGUMENTS}) list(LENGTH _sources _sourceCount) if(ECM_ADD_TEST_TEST_NAME) @@ -38,19 +43,29 @@ function(ecm_add_test) set(_testname "${ECM_ADD_TEST_NAME_PREFIX}${_testname}") add_executable(${_testname} ${_sources}) + if(NOT ECM_ADD_TEST_GUI) + ecm_mark_nongui_executable(${_testname}) + endif() add_test(${_testname} ${_testname}) target_link_libraries(${_testname} ${ECM_ADD_TEST_LINK_LIBRARIES}) ecm_mark_as_test(${_testname}) endfunction() function(ecm_add_tests) + set(options GUI) set(oneValueArgs NAME_PREFIX) set(multiValueArgs LINK_LIBRARIES) - cmake_parse_arguments(ECM_ADD_TESTS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(ECM_ADD_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(ECM_ADD_TESTS_GUI) + set(_exe_type GUI) + else() + set(_exe_type "") + endif() foreach(_test_source ${ECM_ADD_TESTS_UNPARSED_ARGUMENTS}) ecm_add_test(${_test_source} NAME_PREFIX ${ECM_ADD_TESTS_NAME_PREFIX} LINK_LIBRARIES ${ECM_ADD_TESTS_LINK_LIBRARIES} + ${_exe_type} ) endforeach() endfunction() -- cgit v1.2.1