aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindGPGME.cmake
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-03-28 12:25:28 -0600
committerGitHub <noreply@github.com>2018-03-28 12:25:28 -0600
commit105006c5f10e4c3cba7f0a6211215b07343e7c7d (patch)
treee153055d3f69493a7d68ff5f79a82da361ea22fd /cmake/FindGPGME.cmake
parentfefa28c4ef90eadb473d787a9c24d7ed890dbc4d (diff)
parent06c4a8ffd6f714045c3048651d7837d731c636a7 (diff)
downloaddino-105006c5f10e4c3cba7f0a6211215b07343e7c7d.tar.gz
dino-105006c5f10e4c3cba7f0a6211215b07343e7c7d.zip
Merge pull request #220 from bochecha/pkgconfig
Find libraries with pkgconfig
Diffstat (limited to 'cmake/FindGPGME.cmake')
-rw-r--r--cmake/FindGPGME.cmake59
1 files changed, 5 insertions, 54 deletions
diff --git a/cmake/FindGPGME.cmake b/cmake/FindGPGME.cmake
index 2ab06d8c..b402020d 100644
--- a/cmake/FindGPGME.cmake
+++ b/cmake/FindGPGME.cmake
@@ -1,57 +1,8 @@
-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)
- 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_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_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_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_NAME "${GPGME_LDFLAGS}")
- string(REGEX REPLACE "^(.* |)-L([^ ]*)( .*|)$" "\\2" GPGME_LIBRARY_DIRS "${GPGME_LDFLAGS}")
- find_library(GPGME_LIBRARY ${GPGME_LIBRARY_NAME} HINTS ${GPGME_LIBRARY_DIRS})
- mark_as_advanced(GPGME_LIBRARY)
- unset(GPGME_LIBRARY_NAME)
- unset(GPGME_LIBRARY_DIRS)
-
- if(NOT TARGET gpgme)
- add_library(gpgme INTERFACE IMPORTED)
- set_property(TARGET gpgme PROPERTY INTERFACE_LINK_LIBRARIES "${GPGME_LDFLAGS}")
- set_property(TARGET gpgme PROPERTY INTERFACE_COMPILE_OPTIONS "${GPGME_CFLAGS}")
- endif(NOT TARGET gpgme)
-endif(GPGME_CONFIG_EXECUTABLE)
+include(PkgConfigWithFallbackOnConfigScript)
+find_pkg_config_with_fallback_on_config_script(GPGME
+ PKG_CONFIG_NAME gpgme
+ CONFIG_SCRIPT_NAME gpgme
+)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GPGME