aheinecke@405: # Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik aheinecke@405: # Software engineering by Intevation GmbH aheinecke@405: # aheinecke@405: # This file is Free Software under the GNU GPL (v>=2) aheinecke@405: # and comes with ABSOLUTELY NO WARRANTY! aheinecke@405: # See LICENSE.txt for details. aheinecke@405: aheinecke@7: set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) aheinecke@7: andre@304: include_directories(${CMAKE_CURRENT_BINARY_DIR} andre@304: ${CMAKE_SOURCE_DIR}/ui andre@304: ${CMAKE_SOURCE_DIR}/common andre@304: ${CMAKE_SOURCE_DIR}/cinst) aheinecke@7: aheinecke@7: find_package(Qt5Test) rrenkert@140: include_directories(${Qt5Test_INCLUDE_DIRS}) aheinecke@43: find_program(HIAWATHA_EXECUTABLE hiawatha) aheinecke@43: aheinecke@43: if (NOT HIAWATHA_EXECUTABLE) aheinecke@43: message (STATUS "WARNING: hiawatha webserver not found. Downloader tests will fail.") aheinecke@43: else() aheinecke@43: add_definitions(-DHIAWATHA_EXECUTABLE="${HIAWATHA_EXECUTABLE}") aheinecke@43: endif() aheinecke@7: aheinecke@409: macro(add_custom_test _source _additional_sources) aheinecke@7: set(_test ${_source}) aheinecke@7: get_filename_component(_name ${_source} NAME_WE) aheinecke@326: set(_test_sources_with_resources ${_test} aheinecke@326: "${_additional_sources};${CMAKE_CURRENT_SOURCE_DIR}/common.cpp") andre@220: qt5_add_resources(_test_sources_with_resources andre@220: ${CMAKE_CURRENT_SOURCE_DIR}/data/testdata.qrc) andre@220: add_executable(${_name} ${_test_sources_with_resources}) aheinecke@409: add_test(tb-${_name} ${_name}) aheinecke@496: target_link_libraries(${_name} aheinecke@560: tbadminlib aheinecke@560: tblib aheinecke@496: ui_common aheinecke@496: Qt5::Test Qt5::Widgets aheinecke@408: trustbridge_common aheinecke@68: ${POLARSSL_LIBRARIES} aheinecke@68: ${EXTRA_STATIC_LIBS}) aheinecke@7: endmacro() aheinecke@7: aheinecke@7: # Add the current source dir to the definition aheinecke@7: # so that it can be used in file names in the tests. aheinecke@7: add_definitions(-DSOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") aheinecke@560: add_custom_test(certlistparsertest.cpp "") aheinecke@48: aheinecke@48: # Downloader rrenkert@139: if (HIAWATHA_EXECUTABLE) aheinecke@407: qt5_add_resources(DOWNLOADER_SOURCES_WITH_RESOURCES ${TRUSTBRIDGE_RESOURCES}) aheinecke@409: add_custom_test(downloadertest.cpp "${DOWNLOADER_SOURCES_WITH_RESOURCES}") rrenkert@139: endif() aheinecke@48: aheinecke@100: # Cinstprocess aheinecke@496: add_custom_test(cinstprocesstest.cpp "") aheinecke@293: add_dependencies(cinstprocesstest cinst) aheinecke@409: add_custom_test(commontest.cpp "") aheinecke@100: aheinecke@560: add_custom_test(createcertlisttest.cpp "") aheinecke@560: add_custom_test(mainwindowtest.cpp "") aheinecke@468: andre@220: if (WIN32) aheinecke@496: add_custom_test(windowsstoretest.cpp "${CMAKE_SOURCE_DIR}/cinst/windowsstore.c") andre@220: endif (WIN32) andre@220: andre@307: if (NSS_FOUND) aheinecke@326: include_directories(${NSS_INCLUDE_DIRS}) aheinecke@331: set(NSSTEST_SOURCES aheinecke@331: ${CMAKE_SOURCE_DIR}/cinst/nssstore_linux.c aheinecke@331: ${CMAKE_SOURCE_DIR}/cinst/nssstore_win.c) aheinecke@409: add_custom_test(nsstest.cpp "${NSSTEST_SOURCES}") aheinecke@326: target_link_libraries(nsstest ${NSS_LIBRARIES}) aheinecke@326: if (WIN32) aheinecke@326: target_link_libraries(nsstest -luserenv) aheinecke@326: endif() aheinecke@326: aheinecke@326: add_dependencies(nsstest mozilla) aheinecke@556: aheinecke@556: # NSS code searches the mozilla process in the same path as the caller aheinecke@556: if (WIN32) aheinecke@556: file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/mozilla.exe" link) aheinecke@556: file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/../../cinst/mozilla.exe" target) aheinecke@556: else() aheinecke@556: file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/mozilla" link) aheinecke@556: file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/../../cinst/mozilla" target) aheinecke@556: endif() aheinecke@556: aheinecke@556: if (NOT EXISTS ${link}) aheinecke@556: if (CMAKE_HOST_UNIX) aheinecke@556: set(command ln -s ${target} ${link}) aheinecke@556: else() aheinecke@556: set(command cmd.exe /c mklink ${link} ${target}) aheinecke@556: endif() aheinecke@556: execute_process(COMMAND ${command} aheinecke@556: RESULT_VARIABLE result aheinecke@556: ERROR_VARIABLE output) aheinecke@556: if (NOT ${result} EQUAL 0) aheinecke@556: message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}") aheinecke@556: endif() aheinecke@556: endif() andre@307: endif() andre@304: aheinecke@409: #add_custom_test(${CMAKE_SOURCE_DIR}/ui/main.cpp "${TRUSTBRIDGE_SOURCES}") aheinecke@7: