From a0b2a66ef0e71918b27207889519f3dc270ebb43 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 15 Apr 2017 18:01:51 +0200 Subject: Replace OpenSSL with GCrypt --- cmake/FindGCrypt.cmake | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ cmake/FindGPGME.cmake | 27 ++++++++++++++++++++---- cmake/FindVala.cmake | 1 + 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 cmake/FindGCrypt.cmake (limited to 'cmake') 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 diff --git a/cmake/FindGPGME.cmake b/cmake/FindGPGME.cmake index 02fa7593..1bfefb95 100644 --- a/cmake/FindGPGME.cmake +++ b/cmake/FindGPGME.cmake @@ -2,23 +2,42 @@ set(GPGME_PKG_CONFIG_NAME gpgme) find_program(GPGME_CONFIG_EXECUTABLE NAMES gpgme-config) mark_as_advanced(GPGME_CONFIG_EXECUTABLE) +find_program(GPGME_SH_EXECUTABLE NAMES sh) +mark_as_advanced(GPGME_SH_EXECUTABLE) + if(GPGME_CONFIG_EXECUTABLE) - execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --version + macro(gpgme_config_fail errcode) + if(${errcode}) + message(FATAL_ERROR "Error invoking gpgme-config: ${errcode}") + endif(${errcode}) + endmacro(gpgme_config_fail) + file(TO_NATIVE_PATH "${GPGME_CONFIG_EXECUTABLE}" GPGME_CONFIG_EXECUTABLE) + file(TO_NATIVE_PATH "${GPGME_SH_EXECUTABLE}" GPGME_SH_EXECUTABLE) + + execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --version OUTPUT_VARIABLE GPGME_VERSION + RESULT_VARIABLE ERRCODE OUTPUT_STRIP_TRAILING_WHITESPACE) + gpgme_config_fail(${ERRCODE}) - execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --api-version + execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --api-version OUTPUT_VARIABLE GPGME_API_VERSION + RESULT_VARIABLE ERRCODE OUTPUT_STRIP_TRAILING_WHITESPACE) + gpgme_config_fail(${ERRCODE}) - execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --cflags + execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --cflags OUTPUT_VARIABLE GPGME_CFLAGS + RESULT_VARIABLE ERRCODE OUTPUT_STRIP_TRAILING_WHITESPACE) + gpgme_config_fail(${ERRCODE}) - execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --libs + execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --libs OUTPUT_VARIABLE GPGME_LDFLAGS + RESULT_VARIABLE ERRCODE OUTPUT_STRIP_TRAILING_WHITESPACE) + gpgme_config_fail(${ERRCODE}) string(REGEX REPLACE "^(.* |)-l([^ ]*gpgme[^ ]*)( .*|)$" "\\2" GPGME_LIBRARY "${GPGME_LDFLAGS}") string(REGEX REPLACE "^(.* |)-L([^ ]*)( .*|)$" "\\2" GPGME_LIBRARY_DIRS "${GPGME_LDFLAGS}") diff --git a/cmake/FindVala.cmake b/cmake/FindVala.cmake index 5b35d7d7..ae87de17 100644 --- a/cmake/FindVala.cmake +++ b/cmake/FindVala.cmake @@ -52,6 +52,7 @@ mark_as_advanced(VALA_EXECUTABLE) # Determine the valac version if(VALA_EXECUTABLE) + file(TO_NATIVE_PATH "${VALA_EXECUTABLE}" VALA_EXECUTABLE) execute_process(COMMAND ${VALA_EXECUTABLE} "--version" OUTPUT_VARIABLE VALA_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -- cgit v1.2.3-70-g09d2