summaryrefslogtreecommitdiffstats
path: root/cmake/modules/add_gpg_crypto_test.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/add_gpg_crypto_test.cmake')
-rw-r--r--cmake/modules/add_gpg_crypto_test.cmake61
1 files changed, 61 insertions, 0 deletions
diff --git a/cmake/modules/add_gpg_crypto_test.cmake b/cmake/modules/add_gpg_crypto_test.cmake
new file mode 100644
index 00000000..c3df76c9
--- /dev/null
+++ b/cmake/modules/add_gpg_crypto_test.cmake
@@ -0,0 +1,61 @@
1# Copyright (c) 2013 Sandro Knauß <mail@sandroknauss.de>
2#
3# Redistribution and use is allowed according to the terms of the BSD license.
4# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
5
6set( MIMETREEPARSERRELPATH framework/src/domain/mime/mimetreeparser)
7set( GNUPGHOME ${CMAKE_BINARY_DIR}/${MIMETREEPARSERRELPATH}/tests/gnupg_home )
8add_definitions( -DGNUPGHOME="${GNUPGHOME}" )
9
10macro (ADD_GPG_CRYPTO_TEST _target _testname)
11 if (UNIX)
12 if (APPLE)
13 set(_library_path_variable "DYLD_LIBRARY_PATH")
14 elseif (CYGWIN)
15 set(_library_path_variable "PATH")
16 else (APPLE)
17 set(_library_path_variable "LD_LIBRARY_PATH")
18 endif (APPLE)
19
20 if (APPLE)
21 # DYLD_LIBRARY_PATH does not work like LD_LIBRARY_PATH
22 # OSX already has the RPATH in libraries and executables, putting runtime directories in
23 # DYLD_LIBRARY_PATH actually breaks things
24 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/")
25 else (APPLE)
26 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${QT_LIBRARY_DIR}")
27 endif (APPLE)
28 set(_executable "$<TARGET_FILE:${_target}>")
29
30 # use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
31 add_custom_command(TARGET ${_target} POST_BUILD
32 COMMAND ${CMAKE_COMMAND}
33 -D_filename=${_executable}.shell -D_library_path_variable=${_library_path_variable}
34 -D_ld_library_path="${_ld_library_path}" -D_executable=$<TARGET_FILE:${_target}>
35 -D_gnupghome="${GNUPGHOME}"
36 -P ${CMAKE_SOURCE_DIR}/cmake/modules/generate_crypto_test_wrapper.cmake
37 )
38
39 set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_executable}.shell" )
40 add_test(NAME ${_testname} COMMAND ${_executable}.shell)
41
42 else (UNIX)
43 # under windows, set the property WRAPPER_SCRIPT just to the name of the executable
44 # maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
45 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${QT_LIBRARY_DIR}")
46 set(_executable "$<TARGET_FILE:${_target}>")
47
48 # use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
49 add_custom_command(TARGET ${_target} POST_BUILD
50 COMMAND ${CMAKE_COMMAND}
51 -D_filename="${_executable}.bat"
52 -D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
53 -D_gnupghome="${GNUPGHOME}"
54 -P ${CMAKE_SOURCE_DIR}/cmake/modules/generate_crypto_test_wrapper.cmake
55 )
56
57 add_test(NAME ${_testname} COMMAND ${_executable}.bat)
58
59 endif (UNIX)
60endmacro (ADD_GPG_CRYPTO_TEST)
61