Warning, /office/calligra/cmake/modules/MacroCalligraAddBenchmark.cmake is written in an unsupported language. File is not indexed.
0001 # Copyright (c) 2010, Cyrille Berger, <cberger@cberger.net> 0002 # Copyright (c) 2006-2009 Alexander Neundorf, <neundorf@kde.org> 0003 # Copyright (c) 2006, 2007, Laurent Montel, <montel@kde.org> 0004 # Copyright (c) 2007 Matthias Kretz <kretz@kde.org> 0005 # 0006 # Redistribution and use is allowed according to the terms of the BSD license. 0007 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0008 0009 add_custom_target(benchmark) 0010 0011 macro (CALLIGRA_ADD_BENCHMARK _test_NAME) 0012 0013 set(_srcList ${ARGN}) 0014 set(_targetName ${_test_NAME}) 0015 if( ${ARGV1} STREQUAL "TESTNAME" ) 0016 set(_targetName ${ARGV2}) 0017 list(REMOVE_AT _srcList 0 1) 0018 endif() 0019 0020 set(_nogui) 0021 list(GET ${_srcList} 0 first_PARAM) 0022 if( ${first_PARAM} STREQUAL "NOGUI" ) 0023 set(_nogui "NOGUI") 0024 endif() 0025 0026 add_executable( ${_test_NAME} ${_srcList} ) 0027 ecm_mark_as_test(${_test_NAME}) 0028 0029 if(NOT KDE4_TEST_OUTPUT) 0030 set(KDE4_TEST_OUTPUT plaintext) 0031 endif() 0032 set(KDE4_TEST_OUTPUT ${KDE4_TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests") 0033 0034 set(using_qtest "") 0035 foreach(_filename ${_srcList}) 0036 if(NOT using_qtest) 0037 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_filename}") 0038 file(READ ${_filename} file_CONTENT) 0039 string(REGEX MATCH "QTEST_(KDE)?MAIN" using_qtest "${file_CONTENT}") 0040 endif() 0041 endif() 0042 endforeach(_filename) 0043 0044 get_target_property( loc ${_test_NAME} LOCATION ) 0045 if(WIN32) 0046 if(MSVC_IDE) 0047 string(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}" loc "${loc}") 0048 endif() 0049 # .bat because of rpath handling 0050 set(_executable "${loc}.bat") 0051 else() 0052 if (APPLE AND NOT _nogui) 0053 set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME}.app/Contents/MacOS/${_test_NAME}) 0054 else () 0055 # .shell because of rpath handling 0056 set(_executable "${loc}.shell") 0057 endif () 0058 endif() 0059 0060 if (using_qtest AND KDE4_TEST_OUTPUT STREQUAL "xml") 0061 #MESSAGE(STATUS "${_targetName} : Using QTestLib, can produce XML report.") 0062 add_custom_target( ${_targetName} COMMAND ${_executable} -xml -o ${_targetName}.tml ) 0063 else () 0064 #MESSAGE(STATUS "${_targetName} : NOT using QTestLib, can't produce XML report, please use QTestLib to write your unit tests.") 0065 add_custom_target( ${_targetName} COMMAND ${_executable} ) 0066 endif () 0067 0068 add_dependencies(benchmark ${_targetName} ) 0069 # add_test( ${_targetName} ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME} -xml -o ${_test_NAME}.tml ) 0070 0071 if (NOT MSVC_IDE) #not needed for the ide 0072 # if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests 0073 if (NOT BUILD_TESTING) 0074 get_directory_property(_buildtestsAdded BUILDTESTS_ADDED) 0075 if(NOT _buildtestsAdded) 0076 add_custom_target(buildtests) 0077 set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE) 0078 endif() 0079 add_dependencies(buildtests ${_test_NAME}) 0080 endif () 0081 endif () 0082 0083 endmacro (CALLIGRA_ADD_BENCHMARK)