3 # Find the native GNUTLS includes and library
5 # GNUTLS_INCLUDE_DIRS - where to find gnutls.h, etc.
6 # GNUTLS_LIBRARIES - List of libraries when using gnutls.
7 # GNUTLS_FOUND - True if gnutls found.
8 # GNUTLS_DLL_DIR - (Windows) Path to the GnuTLS DLLs.
9 # GNUTLS_DLLS - (Windows) List of required GnuTLS DLLs.
12 if(GNUTLS_INCLUDE_DIRS)
13 # Already in cache, be silent
14 set(GNUTLS_FIND_QUIETLY TRUE)
17 include(FindWSWinLibs)
18 findwswinlibs("gnutls-.*" "GNUTLS_HINTS")
20 if(NOT USE_REPOSITORY)
21 find_package(PkgConfig)
22 pkg_search_module(GNUTLS gnutls)
25 # sources include gnutls/gnutls.h, look for that location instead of gnutls.h.
26 find_path(GNUTLS_INCLUDE_DIR
30 "${GNUTLS_INCLUDEDIR}"
31 "${GNUTLS_HINTS}/include"
34 find_library(GNUTLS_LIBRARY
36 gnutls libgnutls-28 libgnutls-30
42 # On systems without pkg-config (e.g. Windows), search its header
43 # (available since GnuTLS 0.1.3)
44 if(NOT GNUTLS_VERSION)
45 if(GNUTLS_INCLUDE_DIR)
46 set(_version_regex "^#define[ \t]+GNUTLS_VERSION[ \t]+\"([^\"]+)\".*")
47 file(STRINGS "${GNUTLS_INCLUDE_DIR}/gnutls/gnutls.h" GNUTLS_VERSION REGEX "${_version_regex}")
48 string(REGEX REPLACE "${_version_regex}" "\\1" GNUTLS_VERSION "${GNUTLS_VERSION}")
53 include(FindPackageHandleStandardArgs)
54 find_package_handle_standard_args(GNUTLS
55 REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
56 VERSION_VAR GNUTLS_VERSION)
59 set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
60 set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
62 set(GNUTLS_DLL_DIR "${GNUTLS_HINTS}/bin"
63 CACHE PATH "Path to the GnuTLS DLLs"
65 # Note: 32-bit glib2-2.52.2-1.34-win32ws needs libgcc_s_sjlj-1.dll too.
66 file(GLOB _gnutls_dlls RELATIVE "${GNUTLS_DLL_DIR}"
67 "${GNUTLS_DLL_DIR}/libgmp-*.dll"
68 "${GNUTLS_DLL_DIR}/libgcc_s_*.dll"
69 "${GNUTLS_DLL_DIR}/libffi-*.dll"
70 "${GNUTLS_DLL_DIR}/libgnutls-*.dll"
71 "${GNUTLS_DLL_DIR}/libhogweed-*.dll"
72 "${GNUTLS_DLL_DIR}/libiconv-*.dll"
73 "${GNUTLS_DLL_DIR}/libintl-*.dll"
74 "${GNUTLS_DLL_DIR}/libnettle-*.dll"
75 "${GNUTLS_DLL_DIR}/libp11-kit-*.dll"
76 "${GNUTLS_DLL_DIR}/libtasn1-*.dll"
77 "${GNUTLS_DLL_DIR}/libwinpthread-*.dll"
79 set(GNUTLS_DLLS ${_gnutls_dlls}
80 # We're storing filenames only. Should we use STRING instead?
81 CACHE FILEPATH "GnuTLS DLL list"
83 mark_as_advanced(GNUTLS_DLL_DIR GNUTLS_DLLS)
87 set(GNUTLS_INCLUDE_DIRS)
92 mark_as_advanced(GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIRS)