regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / cmake / modules / FindGCRYPT.cmake
blob1da7a66fd03d5ab8dcd5d8d4db35b5f4272f1f9e
2 # - Find gcrypt
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)
15 endif()
17 include(FindWSWinLibs)
18 FindWSWinLibs("libgcrypt-.*" "GCRYPT_HINTS")
20 find_path(GCRYPT_INCLUDE_DIR
21   NAMES gcrypt.h
22   PATH_SUFFIXES
23     include
24   HINTS
25     "${GCRYPT_INCLUDEDIR}"
26     "${GCRYPT_HINTS}"
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
33   PATH_SUFFIXES
34     lib
35   HINTS
36     "${GCRYPT_LIBDIR}"
37     "${GCRYPT_HINTS}"
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
45   PATH_SUFFIXES
46     lib
47   HINTS
48     "${GCRYPT_LIBDIR}"
49     "${GCRYPT_HINTS}"
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}")
57   unset(_version_regex)
58 endif()
60 include(FindPackageHandleStandardArgs)
61 find_package_handle_standard_args(GCRYPT
62   REQUIRED_VARS   GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR
63   VERSION_VAR     GCRYPT_VERSION)
65 if(GCRYPT_FOUND)
66   set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
67   set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
68   if(WIN32)
69     set(GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
70       CACHE PATH "Path to the Libgcrypt DLLs"
71     )
72     file(GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
73       "${GCRYPT_DLL_DIR}/libgcrypt-*.dll"
74       "${GCRYPT_DLL_DIR}/libgpg-error*.dll"
75     )
76     set(GCRYPT_DLLS ${_gcrypt_dlls}
77       # We're storing filenames only. Should we use STRING instead?
78       CACHE FILEPATH "Libgcrypt DLL list"
79     )
80     mark_as_advanced(GCRYPT_DLL_DIR GCRYPT_DLLS)
81   endif()
82 else()
83   set(GCRYPT_LIBRARIES)
84   set(GCRYPT_INCLUDE_DIRS)
85   set(GCRYPT_DLL_DIR)
86   set(GCRYPT_DLLS)
87 endif()
89 mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)