3 # Find the native GCRYPT includes and library
5 # GCRYPT_INCLUDE_DIRS - where to find gcrypt.h, etc.
6 # GCRYPT_LIBRARIES - List of libraries when using gcrypt.
7 # GCRYPT_FOUND - True if gcrypt found.
8 # GCRYPT_DLL_DIR - (Windows) Path to the Libgcrypt DLLs.
9 # GCRYPT_DLLS - (Windows) List of required Libgcrypt DLLs.
12 if(GCRYPT_INCLUDE_DIRS)
13 # Already in cache, be silent
14 set(GCRYPT_FIND_QUIETLY TRUE)
17 include(FindWSWinLibs)
18 FindWSWinLibs("libgcrypt-.*" "GCRYPT_HINTS")
20 find_path(GCRYPT_INCLUDE_DIR
25 "${GCRYPT_INCLUDEDIR}"
29 # libgcrypt-20 is used in libgcrypt-1.8.3-win??ws (from Debian).
30 # libgcrypt is used in libgcrypt-1.10.1-2-win??ws (from Debian).
31 find_library(GCRYPT_LIBRARY
32 NAMES gcrypt libgcrypt libgcrypt-20
40 # libgpg-error6-0 is used in libgcrypt-1.7.6-win??ws (built from source).
41 # libgpg-error-0 is used in libgcrypt-1.8.3-win??ws (from Debian).
42 # libgpg-error is used in libgcrypt-1.10.1-2-win??ws (from Debian).
43 find_library(GCRYPT_ERROR_LIBRARY
44 NAMES gpg-error libgpg-error libgpg-error-0 libgpg-error6-0
52 # Try to retrieve version from header if found (available since libgcrypt 1.3.0)
53 if(GCRYPT_INCLUDE_DIR)
54 set(_version_regex "^#define[ \t]+GCRYPT_VERSION[ \t]+\"([0-9\.]+\.[0-9]+).*")
55 file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" GCRYPT_VERSION REGEX "${_version_regex}")
56 string(REGEX REPLACE "${_version_regex}" "\\1" GCRYPT_VERSION "${GCRYPT_VERSION}")
60 include(FindPackageHandleStandardArgs)
61 find_package_handle_standard_args(GCRYPT
62 REQUIRED_VARS GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR
63 VERSION_VAR GCRYPT_VERSION)
66 set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
67 set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
69 set(GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
70 CACHE PATH "Path to the Libgcrypt DLLs"
72 file(GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
73 "${GCRYPT_DLL_DIR}/libgcrypt-*.dll"
74 "${GCRYPT_DLL_DIR}/libgpg-error*.dll"
76 set(GCRYPT_DLLS ${_gcrypt_dlls}
77 # We're storing filenames only. Should we use STRING instead?
78 CACHE FILEPATH "Libgcrypt DLL list"
80 mark_as_advanced(GCRYPT_DLL_DIR GCRYPT_DLLS)
84 set(GCRYPT_INCLUDE_DIRS)
89 mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)