2009-09-23 19:40:25 +00:00
|
|
|
#
|
2009-09-09 13:20:33 +00:00
|
|
|
# - Find gcrypt
|
|
|
|
# Find the native GCRYPT includes and library
|
|
|
|
#
|
|
|
|
# GCRYPT_INCLUDE_DIRS - where to find gcrypt.h, etc.
|
|
|
|
# GCRYPT_LIBRARIES - List of libraries when using gcrypt.
|
|
|
|
# GCRYPT_FOUND - True if gcrypt found.
|
2015-01-12 22:44:42 +00:00
|
|
|
# GCRYPT_DLL_DIR - (Windows) Path to the Libgcrypt DLLs.
|
|
|
|
# GCRYPT_DLLS - (Windows) List of required Libgcrypt DLLs.
|
2009-09-09 13:20:33 +00:00
|
|
|
|
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
if(GCRYPT_INCLUDE_DIRS)
|
2009-09-09 13:20:33 +00:00
|
|
|
# Already in cache, be silent
|
2018-12-29 11:11:18 +00:00
|
|
|
set(GCRYPT_FIND_QUIETLY TRUE)
|
|
|
|
endif()
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
include(FindWSWinLibs)
|
2017-02-15 13:01:23 +00:00
|
|
|
FindWSWinLibs("libgcrypt-.*" "GCRYPT_HINTS")
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
find_path(GCRYPT_INCLUDE_DIR gcrypt.h
|
2015-01-12 22:44:42 +00:00
|
|
|
HINTS
|
2018-12-29 11:11:18 +00:00
|
|
|
"${GCRYPT_HINTS}/include"
|
2013-10-04 07:41:43 +00:00
|
|
|
)
|
2013-09-23 21:45:55 +00:00
|
|
|
|
2022-08-20 00:23:14 +00:00
|
|
|
# libgcrypt-20 is used in libgcrypt-1.8.3-win??ws (from Debian).
|
|
|
|
# libgcrypt is used in libgcrypt-1.10.1-2-win??ws (from Debian).
|
2018-12-29 11:11:18 +00:00
|
|
|
find_library(GCRYPT_LIBRARY
|
2022-08-20 00:23:14 +00:00
|
|
|
NAMES gcrypt libgcrypt libgcrypt-20
|
|
|
|
HINTS "${GCRYPT_HINTS}/lib")
|
2018-12-29 11:11:18 +00:00
|
|
|
|
|
|
|
# libgpg-error6-0 is used in libgcrypt-1.7.6-win??ws (built from source).
|
|
|
|
# libgpg-error-0 is used in libgcrypt-1.8.3-win??ws (from Debian).
|
2022-08-20 00:23:14 +00:00
|
|
|
# libgpg-error is used in libgcrypt-1.10.1-2-win??ws (from Debian).
|
2018-12-29 11:11:18 +00:00
|
|
|
find_library(GCRYPT_ERROR_LIBRARY
|
2022-08-20 00:23:14 +00:00
|
|
|
NAMES gpg-error libgpg-error libgpg-error-0 libgpg-error6-0
|
|
|
|
HINTS "${GCRYPT_HINTS}/lib")
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2015-10-14 17:40:24 +00:00
|
|
|
# Try to retrieve version from header if found (available since libgcrypt 1.3.0)
|
|
|
|
if(GCRYPT_INCLUDE_DIR)
|
|
|
|
set(_version_regex "^#define[ \t]+GCRYPT_VERSION[ \t]+\"([^\"]+)\".*")
|
|
|
|
file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" GCRYPT_VERSION REGEX "${_version_regex}")
|
|
|
|
string(REGEX REPLACE "${_version_regex}" "\\1" GCRYPT_VERSION "${GCRYPT_VERSION}")
|
|
|
|
unset(_version_regex)
|
|
|
|
endif()
|
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(GCRYPT
|
2015-10-14 17:40:24 +00:00
|
|
|
REQUIRED_VARS GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR
|
|
|
|
VERSION_VAR GCRYPT_VERSION)
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
if(GCRYPT_FOUND)
|
|
|
|
set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
|
|
|
|
set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
|
|
|
|
if(WIN32)
|
|
|
|
set(GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
|
2015-01-12 22:44:42 +00:00
|
|
|
CACHE PATH "Path to the Libgcrypt DLLs"
|
|
|
|
)
|
2018-12-29 11:11:18 +00:00
|
|
|
file(GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
|
2015-01-12 22:44:42 +00:00
|
|
|
"${GCRYPT_DLL_DIR}/libgcrypt-*.dll"
|
|
|
|
"${GCRYPT_DLL_DIR}/libgpg-error*.dll"
|
|
|
|
)
|
2018-12-29 11:11:18 +00:00
|
|
|
set(GCRYPT_DLLS ${_gcrypt_dlls}
|
2015-01-12 22:44:42 +00:00
|
|
|
# We're storing filenames only. Should we use STRING instead?
|
|
|
|
CACHE FILEPATH "Libgcrypt DLL list"
|
|
|
|
)
|
2018-12-29 11:11:18 +00:00
|
|
|
mark_as_advanced(GCRYPT_DLL_DIR GCRYPT_DLLS)
|
2015-01-12 22:44:42 +00:00
|
|
|
endif()
|
2018-12-29 11:11:18 +00:00
|
|
|
else()
|
|
|
|
set(GCRYPT_LIBRARIES)
|
|
|
|
set(GCRYPT_INCLUDE_DIRS)
|
|
|
|
set(GCRYPT_DLL_DIR)
|
|
|
|
set(GCRYPT_DLLS)
|
|
|
|
endif()
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-29 11:11:18 +00:00
|
|
|
mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)
|