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