2017-03-23 16:10:45 +00:00
|
|
|
set(GPGME_PKG_CONFIG_NAME gpgme)
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
find_program(GPGME_CONFIG_EXECUTABLE NAMES gpgme-config)
|
|
|
|
mark_as_advanced(GPGME_CONFIG_EXECUTABLE)
|
2017-04-15 16:01:51 +00:00
|
|
|
find_program(GPGME_SH_EXECUTABLE NAMES sh)
|
|
|
|
mark_as_advanced(GPGME_SH_EXECUTABLE)
|
|
|
|
|
2017-03-02 14:37:32 +00:00
|
|
|
|
|
|
|
if(GPGME_CONFIG_EXECUTABLE)
|
2017-04-15 16:01:51 +00:00
|
|
|
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
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_VARIABLE GPGME_VERSION
|
2017-04-15 16:01:51 +00:00
|
|
|
RESULT_VARIABLE ERRCODE
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-04-15 16:01:51 +00:00
|
|
|
gpgme_config_fail(${ERRCODE})
|
2017-03-02 14:37:32 +00:00
|
|
|
|
2017-04-15 16:01:51 +00:00
|
|
|
execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --api-version
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_VARIABLE GPGME_API_VERSION
|
2017-04-15 16:01:51 +00:00
|
|
|
RESULT_VARIABLE ERRCODE
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-04-15 16:01:51 +00:00
|
|
|
gpgme_config_fail(${ERRCODE})
|
2017-03-02 14:37:32 +00:00
|
|
|
|
2017-04-15 16:01:51 +00:00
|
|
|
execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --cflags
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_VARIABLE GPGME_CFLAGS
|
2017-04-15 16:01:51 +00:00
|
|
|
RESULT_VARIABLE ERRCODE
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-04-15 16:01:51 +00:00
|
|
|
gpgme_config_fail(${ERRCODE})
|
2017-03-02 14:37:32 +00:00
|
|
|
|
2017-04-15 16:01:51 +00:00
|
|
|
execute_process(COMMAND "${GPGME_SH_EXECUTABLE}" "${GPGME_CONFIG_EXECUTABLE}" --libs
|
2017-03-23 16:10:45 +00:00
|
|
|
OUTPUT_VARIABLE GPGME_LDFLAGS
|
2017-04-15 16:01:51 +00:00
|
|
|
RESULT_VARIABLE ERRCODE
|
2017-03-02 14:37:32 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-04-15 16:01:51 +00:00
|
|
|
gpgme_config_fail(${ERRCODE})
|
2017-03-23 16:10:45 +00:00
|
|
|
|
2017-03-24 09:40:48 +00:00
|
|
|
string(REGEX REPLACE "^(.* |)-l([^ ]*gpgme[^ ]*)( .*|)$" "\\2" GPGME_LIBRARY "${GPGME_LDFLAGS}")
|
|
|
|
string(REGEX REPLACE "^(.* |)-L([^ ]*)( .*|)$" "\\2" GPGME_LIBRARY_DIRS "${GPGME_LDFLAGS}")
|
2017-03-23 16:10:45 +00:00
|
|
|
find_library(LIB_NAME_GPGME ${GPGME_LIBRARY} HINTS ${GPGME_LIBRARY_DIRS})
|
|
|
|
set(GPGME_LIBRARY ${LIB_NAME_GPGME})
|
|
|
|
|
|
|
|
if(NOT TARGET gpgme)
|
2017-03-24 09:40:48 +00:00
|
|
|
add_library(gpgme INTERFACE IMPORTED)
|
|
|
|
set_property(TARGET gpgme PROPERTY INTERFACE_LINK_LIBRARIES "${GPGME_LDFLAGS}")
|
2017-03-23 16:10:45 +00:00
|
|
|
set_property(TARGET gpgme PROPERTY INTERFACE_COMPILE_OPTIONS "${GPGME_CFLAGS}")
|
|
|
|
endif(NOT TARGET gpgme)
|
2017-03-02 14:37:32 +00:00
|
|
|
endif(GPGME_CONFIG_EXECUTABLE)
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(GPGME
|
2017-03-23 16:10:45 +00:00
|
|
|
REQUIRED_VARS GPGME_LIBRARY
|
2017-03-02 14:37:32 +00:00
|
|
|
VERSION_VAR GPGME_VERSION)
|