diff options
author | Marvin W <git@larma.de> | 2017-04-15 18:01:51 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-04-15 18:03:24 +0200 |
commit | a0b2a66ef0e71918b27207889519f3dc270ebb43 (patch) | |
tree | 19e00017e8ccfda89925e54caae4dec0505d1e60 /cmake/FindGCrypt.cmake | |
parent | e3b69538bacd14283374f5e7619db610cafd81d6 (diff) | |
download | dino-a0b2a66ef0e71918b27207889519f3dc270ebb43.tar.gz dino-a0b2a66ef0e71918b27207889519f3dc270ebb43.zip |
Replace OpenSSL with GCrypt
Diffstat (limited to 'cmake/FindGCrypt.cmake')
-rw-r--r-- | cmake/FindGCrypt.cmake | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/FindGCrypt.cmake b/cmake/FindGCrypt.cmake new file mode 100644 index 00000000..7c6b2173 --- /dev/null +++ b/cmake/FindGCrypt.cmake @@ -0,0 +1,57 @@ +set(GCrypt_PKG_CONFIG_NAME gcrypt) + +find_program(GCrypt_CONFIG_EXECUTABLE NAMES libgcrypt-config) +mark_as_advanced(GCrypt_CONFIG_EXECUTABLE) +find_program(GCrypt_SH_EXECUTABLE NAMES sh) +mark_as_advanced(GCrypt_SH_EXECUTABLE) + + +if(GCrypt_CONFIG_EXECUTABLE) + macro(gcrypt_config_fail errcode) + if(${errcode}) + message(FATAL_ERROR "Error invoking libgcrypt-config: ${errcode}") + endif(${errcode}) + endmacro(gcrypt_config_fail) + file(TO_NATIVE_PATH "${GCrypt_CONFIG_EXECUTABLE}" GCrypt_CONFIG_EXECUTABLE) + file(TO_NATIVE_PATH "${GCrypt_SH_EXECUTABLE}" GCrypt_SH_EXECUTABLE) + + execute_process(COMMAND "${GCrypt_SH_EXECUTABLE}" "${GCrypt_CONFIG_EXECUTABLE}" --version + OUTPUT_VARIABLE GCrypt_VERSION + RESULT_VARIABLE ERRCODE + OUTPUT_STRIP_TRAILING_WHITESPACE) + gcrypt_config_fail(${ERRCODE}) + + execute_process(COMMAND "${GCrypt_SH_EXECUTABLE}" "${GCrypt_CONFIG_EXECUTABLE}" --api-version + OUTPUT_VARIABLE GCrypt_API_VERSION + RESULT_VARIABLE ERRCODE + OUTPUT_STRIP_TRAILING_WHITESPACE) + gcrypt_config_fail(${ERRCODE}) + + execute_process(COMMAND "${GCrypt_SH_EXECUTABLE}" "${GCrypt_CONFIG_EXECUTABLE}" --cflags + OUTPUT_VARIABLE GCrypt_CFLAGS + RESULT_VARIABLE ERRCODE + OUTPUT_STRIP_TRAILING_WHITESPACE) + gcrypt_config_fail(${ERRCODE}) + + execute_process(COMMAND "${GCrypt_SH_EXECUTABLE}" "${GCrypt_CONFIG_EXECUTABLE}" --libs + OUTPUT_VARIABLE GCrypt_LDFLAGS + RESULT_VARIABLE ERRCODE + OUTPUT_STRIP_TRAILING_WHITESPACE) + gcrypt_config_fail(${ERRCODE}) + + string(REGEX REPLACE "^(.* |)-l([^ ]*gcrypt[^ ]*)( .*|)$" "\\2" GCrypt_LIBRARY "${GCrypt_LDFLAGS}") + string(REGEX REPLACE "^(.* |)-L([^ ]*)( .*|)$" "\\2" GCrypt_LIBRARY_DIRS "${GCrypt_LDFLAGS}") + find_library(LIB_NAME_GCrypt ${GCrypt_LIBRARY} HINTS ${GCrypt_LIBRARY_DIRS}) + set(GCrypt_LIBRARY ${LIB_NAME_GCrypt}) + + if(NOT TARGET gcrypt) + add_library(gcrypt INTERFACE IMPORTED) + set_property(TARGET gcrypt PROPERTY INTERFACE_LINK_LIBRARIES "${GCrypt_LDFLAGS}") + set_property(TARGET gcrypt PROPERTY INTERFACE_COMPILE_OPTIONS "${GCrypt_CFLAGS}") + endif(NOT TARGET gcrypt) +endif(GCrypt_CONFIG_EXECUTABLE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GCrypt + REQUIRED_VARS GCrypt_LIBRARY + VERSION_VAR GCrypt_VERSION)
\ No newline at end of file |