From fe1ab42f160ac9b67f181775321fa89b62102159 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 14 Oct 2015 20:23:46 +0200 Subject: Require GnuTLS 2.12.0, add cmake version detection Since v2.1.0rc0-17-g877fd03 and v2.0.0rc0-23-g263ff53 ("ssl-utils: load RSA keys based on their modulus+exponent"), GnuTLS 2.12.0 is needed. Add a version check to cmake as well, tested on CentOS6 (with pkg-config check disabled to verify the code path). Note that RHEL6 has GnuTLS 2.8.5 and thus SSL decryption with a RSA private key is no longer supported on that version. Change-Id: I99fdfe6790107f48629dd435794fe8880263063d Reviewed-on: https://code.wireshark.org/review/11044 Reviewed-by: Alexis La Goutte Petri-Dish: Alexis La Goutte Tested-by: Petri Dish Buildbot Reviewed-by: Michal Labedzki Reviewed-by: Peter Wu --- cmake/modules/FindGNUTLS.cmake | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'cmake') diff --git a/cmake/modules/FindGNUTLS.cmake b/cmake/modules/FindGNUTLS.cmake index 2803aa8350..c10efee59b 100644 --- a/cmake/modules/FindGNUTLS.cmake +++ b/cmake/modules/FindGNUTLS.cmake @@ -20,9 +20,9 @@ FindWSWinLibs("gnutls-.*" "GNUTLS_HINTS") find_package(PkgConfig) pkg_search_module(GNUTLS gnutls) +# sources include gnutls/gnutls.h, look for that location instead of gnutls.h. FIND_PATH(GNUTLS_INCLUDE_DIR NAMES - gnutls.h gnutls/gnutls.h PATH_SUFFIXES include @@ -42,10 +42,23 @@ FIND_LIBRARY(GNUTLS_LIBRARY "${GNUTLS_HINTS}/bin" ) +# 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() + # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if -# all listed variables are TRUE +# all listed variables are TRUE and the requested version matches. INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNUTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNUTLS + REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR + VERSION_VAR GNUTLS_VERSION) IF(GNUTLS_FOUND) SET( GNUTLS_LIBRARIES ${GNUTLS_LIBRARY} ) -- cgit v1.2.3