| 1 |
# SPDX-FileCopyrightText: 2010 Cyrille Berger <[email protected]> |
| 2 |
# SPDX-FileCopyrightText: 2006-2009 Alexander Neundorf <[email protected]> |
| 3 |
# SPDX-FileCopyrightText: 2006, 2007 Laurent Montel <[email protected]> |
| 4 |
# SPDX-FileCopyrightText: 2007 Matthias Kretz <[email protected]> |
| 5 |
# |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# |
| 8 |
|
| 9 |
add_custom_target(benchmark) |
| 10 |
|
| 11 |
include(KritaTestSuite) |
| 12 |
|
| 13 |
macro (KRITA_ADD_BENCHMARK _test_NAME) |
| 14 |
|
| 15 |
set(_srcList ${ARGN}) |
| 16 |
set(_targetName ${_test_NAME}) |
| 17 |
if( ${ARGV1} STREQUAL "TESTNAME" ) |
| 18 |
set(_targetName ${ARGV2}) |
| 19 |
list(REMOVE_AT _srcList 0 1) |
| 20 |
endif() |
| 21 |
|
| 22 |
set(_nogui) |
| 23 |
list(GET ${_srcList} 0 first_PARAM) |
| 24 |
if( ${first_PARAM} STREQUAL "NOGUI" ) |
| 25 |
set(_nogui "NOGUI") |
| 26 |
endif() |
| 27 |
|
| 28 |
add_executable( ${_test_NAME} ${_srcList} ) |
| 29 |
set_test_sdk_compile_definitions(${_test_NAME}) |
| 30 |
ecm_mark_as_test(${_test_NAME}) |
| 31 |
|
| 32 |
if(NOT KDE4_TEST_OUTPUT) |
| 33 |
set(KDE4_TEST_OUTPUT plaintext) |
| 34 |
endif() |
| 35 |
set(KDE4_TEST_OUTPUT ${KDE4_TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests") |
| 36 |
|
| 37 |
set(using_qtest "") |
| 38 |
foreach(_filename ${_srcList}) |
| 39 |
if(NOT using_qtest) |
| 40 |
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}") |
| 41 |
file(READ ${_filename} file_CONTENT) |
| 42 |
string(REGEX MATCH "QTEST_(KDE)?MAIN" using_qtest "${file_CONTENT}") |
| 43 |
endif() |
| 44 |
endif() |
| 45 |
endforeach() |
| 46 |
|
| 47 |
if (using_qtest AND KDE4_TEST_OUTPUT STREQUAL "xml") |
| 48 |
#MESSAGE(STATUS "${_targetName} : Using QTestLib, can produce XML report.") |
| 49 |
add_custom_target( ${_targetName} COMMAND $<TARGET_FILE:${_test_NAME}> -xml -o ${_targetName}.tml ) |
| 50 |
else () |
| 51 |
#MESSAGE(STATUS "${_targetName} : NOT using QTestLib, can't produce XML report, please use QTestLib to write your unit tests.") |
| 52 |
add_custom_target( ${_targetName} COMMAND $<TARGET_FILE:${_test_NAME}> ) |
| 53 |
endif () |
| 54 |
|
| 55 |
add_dependencies(benchmark ${_targetName} ) |
| 56 |
# add_test( ${_targetName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_test_NAME} -xml -o ${_test_NAME}.tml ) |
| 57 |
|
| 58 |
if (NOT MSVC_IDE) #not needed for the ide |
| 59 |
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests |
| 60 |
if (NOT BUILD_TESTING) |
| 61 |
if(NOT TARGET buildtests) |
| 62 |
add_custom_target(buildtests) |
| 63 |
endif() |
| 64 |
add_dependencies(buildtests ${_test_NAME}) |
| 65 |
endif () |
| 66 |
endif () |
| 67 |
endmacro (KRITA_ADD_BENCHMARK) |