Warning, /pim/mimetreeparser/cmake/modules/kdepim_add_gpg_crypto_test.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2013 Sandro Knauß <mail@sandroknauss.de>
0002 #
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 
0005 set(GNUPGHOME ${CMAKE_BINARY_DIR}/autotests/gnupg_home)
0006 add_definitions(-DGNUPGHOME="${GNUPGHOME}")
0007 
0008 macro (ADD_GPG_CRYPTO_TEST _target _testname)
0009    if (UNIX)
0010       if (APPLE)
0011          set(_library_path_variable "DYLD_LIBRARY_PATH")
0012       elseif (CYGWIN)
0013          set(_library_path_variable "PATH")
0014       else (APPLE)
0015          set(_library_path_variable "LD_LIBRARY_PATH")
0016       endif (APPLE)
0017 
0018       if (APPLE)
0019          # DYLD_LIBRARY_PATH does not work like LD_LIBRARY_PATH
0020          # OSX already has the RPATH in libraries and executables, putting runtime directories in
0021          # DYLD_LIBRARY_PATH actually breaks things
0022          set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/")
0023       else (APPLE)
0024          set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${QT_LIBRARY_DIR}")
0025       endif (APPLE)
0026       set(_executable "$<TARGET_FILE:${_target}>")
0027 
0028       # use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
0029       add_custom_command(TARGET ${_target} POST_BUILD
0030         COMMAND ${CMAKE_COMMAND}
0031         -D_filename=${_executable}.shell -D_library_path_variable=${_library_path_variable}
0032         -D_ld_library_path="${_ld_library_path}" -D_executable=$<TARGET_FILE:${_target}>
0033         -D_gnupghome="${GNUPGHOME}"
0034         -P ${CMAKE_SOURCE_DIR}/cmake/modules/kdepim_generate_crypto_test_wrapper.cmake
0035       )
0036 
0037       set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_executable}.shell" )
0038       add_test(NAME ${_testname} COMMAND ${_executable}.shell)
0039 
0040    else (UNIX)
0041       # under windows, set the property WRAPPER_SCRIPT just to the name of the executable
0042       # maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
0043       set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${QT_LIBRARY_DIR}")
0044       set(_executable "$<TARGET_FILE:${_target}>")
0045 
0046       # use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
0047       add_custom_command(TARGET ${_target} POST_BUILD
0048          COMMAND ${CMAKE_COMMAND}
0049          -D_filename="${_executable}.bat"
0050          -D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
0051          -D_gnupghome="${GNUPGHOME}"
0052          -P ${CMAKE_SOURCE_DIR}/cmake/modules/kdepim_generate_crypto_test_wrapper.cmake
0053          )
0054 
0055       add_test(NAME ${_testname} COMMAND ${_executable}.bat)
0056 
0057    endif (UNIX)
0058 
0059    # can't be parallelized due to gpg-agent
0060    set_tests_properties(${_testname} PROPERTIES RUN_SERIAL TRUE)
0061 endmacro (ADD_GPG_CRYPTO_TEST)
0062 
0063 macro (ADD_GPG_CRYPTO_AKONADI_TEST _target _testname)
0064     set(_executable "$<TARGET_FILE:${_target}>")
0065 
0066     if (UNIX)
0067         if (APPLE)
0068             set(_library_path_variable "DYLD_LIBRARY_PATH")
0069         elseif (CYGWIN)
0070             set(_library_path_variable "PATH")
0071         else (APPLE)
0072             set(_library_path_variable "LD_LIBRARY_PATH")
0073         endif (APPLE)
0074 
0075         if (APPLE)
0076             # DYLD_LIBRARY_PATH does not work like LD_LIBRARY_PATH
0077             # OSX already has the RPATH in libraries and executables, putting runtime directories in
0078             # DYLD_LIBRARY_PATH actually breaks things
0079             set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/")
0080         else (APPLE)
0081             set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${QT_LIBRARY_DIR}")
0082         endif (APPLE)
0083 
0084         set(_posix "shell")
0085         set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_executable}.${_posix}" )
0086 
0087         # use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
0088         add_custom_command(TARGET ${_target} POST_BUILD
0089             COMMAND ${CMAKE_COMMAND}
0090             -D_filename=${_executable}.${_posix} -D_library_path_variable=${_library_path_variable}
0091             -D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
0092             -D_gnupghome="${GNUPGHOME}"
0093             -P ${CMAKE_SOURCE_DIR}/cmake/modules/kdepim_generate_crypto_test_wrapper.cmake
0094         )
0095 
0096 
0097     else (UNIX)
0098         # under windows, set the property WRAPPER_SCRIPT just to the name of the executable
0099         # maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
0100         set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${QT_LIBRARY_DIR}")
0101         set(_posix "bat")
0102 
0103         # use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
0104         add_custom_command(TARGET ${_target} POST_BUILD
0105             COMMAND ${CMAKE_COMMAND}
0106             -D_filename="${_executable}.${_posix}"
0107             -D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
0108             -D_gnupghome="${GNUPGHOME}"
0109             -P ${CMAKE_SOURCE_DIR}/cmake/modules/kdepim_generate_crypto_test_wrapper.cmake
0110         )
0111 
0112     endif ()
0113 
0114     if (NOT DEFINED _testrunner)
0115         find_program(_testrunner NAMES akonaditest akonaditest.exe)
0116         if (NOT _testrunner)
0117             message(WARNING "Could not locate akonaditest executable, isolated Akonadi tests will fail!")
0118         endif()
0119     endif()
0120 
0121     function(_defineTest name backend)
0122         set(backends ${ARGN})
0123         if (NOT DEFINED AKONADI_RUN_${backend}_ISOLATED_TESTS OR AKONADI_RUN_${backend}_ISOLATED_TESTS)
0124             LIST(LENGTH "${backends}" backendsLen)
0125             string(TOLOWER ${backend} lcbackend)
0126             LIST(FIND "${backends}" ${lcbackend} enableBackend)
0127             if (${backendsLen} EQUAL 0 OR ${enableBackend} GREATER -1)
0128                 set(configFile ${CMAKE_CURRENT_SOURCE_DIR}/unittestenv/config.xml)
0129                 if (AKONADI_TESTS_XML)
0130                     set(extraOptions -xml -o "${TEST_RESULT_OUTPUT_PATH}/${lcbackend}-${name}.xml")
0131                 endif()
0132                 set(_test_name akonadi-${lcbackend}-${name})
0133                 add_test(NAME ${_test_name}
0134                             COMMAND ${_testrunner} -c "${configFile}" -b ${lcbackend}
0135                                     "${_executable}.${_posix}" ${extraOptions}
0136                 )
0137                 # Taken from ECMAddTests.cmake
0138                 if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
0139                     if(CMAKE_HOST_SYSTEM MATCHES "Windows")
0140                         set(PATHSEP ";")
0141                     else() # e.g. Linux
0142                         set(PATHSEP ":")
0143                     endif()
0144                     set(_plugin_path $ENV{QT_PLUGIN_PATH})
0145                     set(_test_env
0146                         QT_PLUGIN_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}${PATHSEP}$ENV{QT_PLUGIN_PATH}
0147                         LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}${PATHSEP}$ENV{LD_LIBRARY_PATH}
0148                     )
0149                     set_tests_properties(${_test_name} PROPERTIES ENVIRONMENT "${_test_env}")
0150                 endif()
0151                 set_tests_properties(${_test_name} PROPERTIES RUN_SERIAL TRUE) # can't be parallelized due to gpg-agent
0152             endif()
0153         endif()
0154     endfunction()
0155 
0156     find_program(MYSQLD_EXECUTABLE mysqld /usr/sbin /usr/local/sbin /usr/libexec /usr/local/libexec /opt/mysql/libexec /usr/mysql/bin)
0157     if (MYSQLD_EXECUTABLE AND NOT WIN32)
0158         _defineTest(${_testname} "MYSQL" ${CONFIG_BACKENDS})
0159     endif()
0160 
0161     find_program(POSTGRES_EXECUTABLE postgres)
0162     if (POSTGRES_EXECUTABLE AND NOT WIN32)
0163         _defineTest(${_testname} "PGSQL" ${CONFIG_BACKENDS})
0164     endif()
0165 
0166     _defineTest(${_testname} "SQLITE" ${CONFIG_BACKENDS})
0167 endmacro (ADD_GPG_CRYPTO_AKONADI_TEST)