2009-09-23 19:40:25 +00:00
|
|
|
#
|
2009-09-09 13:20:33 +00:00
|
|
|
# - Find gnutls
|
|
|
|
# Find the native GNUTLS includes and library
|
|
|
|
#
|
|
|
|
# GNUTLS_INCLUDE_DIRS - where to find gnutls.h, etc.
|
|
|
|
# GNUTLS_LIBRARIES - List of libraries when using gnutls.
|
|
|
|
# GNUTLS_FOUND - True if gnutls found.
|
2015-01-12 22:44:42 +00:00
|
|
|
# GNUTLS_DLL_DIR - (Windows) Path to the GnuTLS DLLs.
|
|
|
|
# GNUTLS_DLLS - (Windows) List of required GnuTLS DLLs.
|
2009-09-09 13:20:33 +00:00
|
|
|
|
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
if(GNUTLS_INCLUDE_DIRS)
|
2009-09-09 13:20:33 +00:00
|
|
|
# Already in cache, be silent
|
2018-12-30 16:13:47 +00:00
|
|
|
set(GNUTLS_FIND_QUIETLY TRUE)
|
|
|
|
endif()
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
include(FindWSWinLibs)
|
|
|
|
findwswinlibs("gnutls-.*" "GNUTLS_HINTS")
|
2013-09-23 21:45:55 +00:00
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
if(NOT WIN32)
|
2017-11-18 20:16:32 +00:00
|
|
|
find_package(PkgConfig)
|
2018-10-16 08:00:33 +00:00
|
|
|
pkg_search_module(GNUTLS gnutls)
|
2017-11-18 20:16:32 +00:00
|
|
|
endif()
|
2014-09-25 10:09:23 +00:00
|
|
|
|
2015-10-14 18:23:46 +00:00
|
|
|
# sources include gnutls/gnutls.h, look for that location instead of gnutls.h.
|
2018-12-30 16:13:47 +00:00
|
|
|
find_path(GNUTLS_INCLUDE_DIR
|
2014-09-25 10:09:23 +00:00
|
|
|
NAMES
|
|
|
|
gnutls/gnutls.h
|
|
|
|
HINTS
|
|
|
|
"${GNUTLS_INCLUDEDIR}"
|
2018-12-30 16:13:47 +00:00
|
|
|
"${GNUTLS_HINTS}/include"
|
2009-09-09 13:20:33 +00:00
|
|
|
)
|
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
find_library(GNUTLS_LIBRARY
|
2014-09-25 10:09:23 +00:00
|
|
|
NAMES
|
2018-12-30 16:13:47 +00:00
|
|
|
gnutls libgnutls-28 libgnutls-30
|
2014-09-25 10:09:23 +00:00
|
|
|
HINTS
|
|
|
|
"${GNUTLS_LIBDIR}"
|
|
|
|
"${GNUTLS_HINTS}/bin"
|
|
|
|
)
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2015-10-14 18:23:46 +00:00
|
|
|
# On systems without pkg-config (e.g. Windows), search its header
|
|
|
|
# (available since GnuTLS 0.1.3)
|
|
|
|
if(NOT GNUTLS_VERSION)
|
|
|
|
if(GNUTLS_INCLUDE_DIR)
|
|
|
|
set(_version_regex "^#define[ \t]+GNUTLS_VERSION[ \t]+\"([^\"]+)\".*")
|
|
|
|
file(STRINGS "${GNUTLS_INCLUDE_DIR}/gnutls/gnutls.h" GNUTLS_VERSION REGEX "${_version_regex}")
|
|
|
|
string(REGEX REPLACE "${_version_regex}" "\\1" GNUTLS_VERSION "${GNUTLS_VERSION}")
|
|
|
|
unset(_version_regex)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(GNUTLS
|
2015-10-14 18:23:46 +00:00
|
|
|
REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
|
|
|
|
VERSION_VAR GNUTLS_VERSION)
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
if(GNUTLS_FOUND)
|
|
|
|
set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
|
|
|
|
set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
|
|
|
|
if(WIN32)
|
|
|
|
set(GNUTLS_DLL_DIR "${GNUTLS_HINTS}/bin"
|
2015-01-12 22:44:42 +00:00
|
|
|
CACHE PATH "Path to the GnuTLS DLLs"
|
|
|
|
)
|
2018-12-15 17:45:53 +00:00
|
|
|
# Note: 32-bit glib2-2.52.2-1.34-win32ws needs libgcc_s_sjlj-1.dll too.
|
2018-12-30 16:13:47 +00:00
|
|
|
file(GLOB _gnutls_dlls RELATIVE "${GNUTLS_DLL_DIR}"
|
2015-01-12 22:44:42 +00:00
|
|
|
"${GNUTLS_DLL_DIR}/libgmp-*.dll"
|
2018-12-15 17:45:53 +00:00
|
|
|
"${GNUTLS_DLL_DIR}/libgcc_s_*.dll"
|
2015-01-12 22:44:42 +00:00
|
|
|
"${GNUTLS_DLL_DIR}/libffi-*.dll"
|
|
|
|
"${GNUTLS_DLL_DIR}/libgnutls-*.dll"
|
|
|
|
"${GNUTLS_DLL_DIR}/libhogweed-*.dll"
|
|
|
|
"${GNUTLS_DLL_DIR}/libnettle-*.dll"
|
|
|
|
"${GNUTLS_DLL_DIR}/libp11-kit-*.dll"
|
|
|
|
"${GNUTLS_DLL_DIR}/libtasn1-*.dll"
|
2017-02-15 13:01:23 +00:00
|
|
|
"${GNUTLS_DLL_DIR}/libwinpthread-*.dll"
|
2015-01-12 22:44:42 +00:00
|
|
|
)
|
2018-12-30 16:13:47 +00:00
|
|
|
set(GNUTLS_DLLS ${_gnutls_dlls}
|
2015-01-12 22:44:42 +00:00
|
|
|
# We're storing filenames only. Should we use STRING instead?
|
|
|
|
CACHE FILEPATH "GnuTLS DLL list"
|
|
|
|
)
|
2018-12-30 16:13:47 +00:00
|
|
|
mark_as_advanced(GNUTLS_DLL_DIR GNUTLS_DLLS)
|
2015-01-12 22:44:42 +00:00
|
|
|
endif()
|
2018-12-30 16:13:47 +00:00
|
|
|
else()
|
|
|
|
set(GNUTLS_LIBRARIES)
|
|
|
|
set(GNUTLS_INCLUDE_DIRS)
|
|
|
|
set(GNUTLS_DLL_DIR)
|
|
|
|
set(GNUTLS_DLLS)
|
|
|
|
endif()
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2018-12-30 16:13:47 +00:00
|
|
|
mark_as_advanced(GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIRS)
|