From ef3d7497d00f6f91e2c3a12d73951e852f5bb53a Mon Sep 17 00:00:00 2001 From: hax0kartik Date: Tue, 3 Mar 2020 07:39:29 -0800 Subject: [PATCH] Only look for libjwt-gnutls and look for openssl only if gnutls is not found --- CMakeLists.txt | 70 +++++++++++++++++----------------- cmake/Modules/FindLibJWT.cmake | 2 +- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e56e6dd90..66f79ce77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,19 +357,43 @@ else(LIBJWT_FOUND) set(optlibsnotfound "${optlibsnotfound} LIBJWT") endif(LIBJWT_FOUND) +# gnutls (using find_library and find_path) +find_library(GNUTLS_LIBRARIES gnutls) +if(GNUTLS_LIBRARIES) + set(HAVE_LIBGNUTLS 1) + find_library(GNUTLS_OPENSSL_LIBRARIES gnutls-openssl) + if(GNUTLS_OPENSSL_LIBRARIES) + list(APPEND ZM_BIN_LIBS "${GNUTLS_OPENSSL_LIBRARIES}") + check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H) + endif(GNUTLS_OPENSSL_LIBRARIES) + list(APPEND ZM_BIN_LIBS "${GNUTLS_LIBRARIES}") + find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h) + if(GNUTLS_INCLUDE_DIR) + include_directories("${GNUTLS_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}") + endif(GNUTLS_INCLUDE_DIR) + mark_as_advanced(FORCE GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIR) + check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H) + set(optlibsfound "${optlibsfound} GnuTLS") +else(GNUTLS_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} GnuTLS") +endif(GNUTLS_LIBRARIES) + # OpenSSL -find_package(OpenSSL) -if(OPENSSL_FOUND) - set(HAVE_LIBOPENSSL 1) - set(HAVE_LIBCRYPTO 1) - list(APPEND ZM_BIN_LIBS "${OPENSSL_LIBRARIES}") - include_directories("${OPENSSL_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") - check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H) - set(optlibsfound "${optlibsfound} OpenSSL") -else(OPENSSL_FOUND) - set(optlibsnotfound "${optlibsnotfound} OpenSSL") -endif(OPENSSL_FOUND) +if(NOT HAVE_LIBGNUTLS) + find_package(OpenSSL) + if(OPENSSL_FOUND) + set(HAVE_LIBOPENSSL 1) + set(HAVE_LIBCRYPTO 1) + list(APPEND ZM_BIN_LIBS "${OPENSSL_LIBRARIES}") + include_directories("${OPENSSL_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") + check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H) + set(optlibsfound "${optlibsfound} OpenSSL") + else(OPENSSL_FOUND) + set(optlibsnotfound "${optlibsnotfound} OpenSSL") + endif(OPENSSL_FOUND) +endif(NOT HAVE_LIBGNUTLS) # pthread (using find_library and find_path) find_library(PTHREAD_LIBRARIES pthread) @@ -426,28 +450,6 @@ else(GCRYPT_LIBRARIES) set(optlibsnotfound "${optlibsnotfound} GCrypt") endif(GCRYPT_LIBRARIES) -# gnutls (using find_library and find_path) -find_library(GNUTLS_LIBRARIES gnutls) -if(GNUTLS_LIBRARIES) - set(HAVE_LIBGNUTLS 1) - find_library(GNUTLS_OPENSSL_LIBRARIES gnutls-openssl) - if(GNUTLS_OPENSSL_LIBRARIES) - list(APPEND ZM_BIN_LIBS "${GNUTLS_OPENSSL_LIBRARIES}") - check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H) - endif(GNUTLS_OPENSSL_LIBRARIES) - list(APPEND ZM_BIN_LIBS "${GNUTLS_LIBRARIES}") - find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h) - if(GNUTLS_INCLUDE_DIR) - include_directories("${GNUTLS_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}") - endif(GNUTLS_INCLUDE_DIR) - mark_as_advanced(FORCE GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIR) - check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H) - set(optlibsfound "${optlibsfound} GnuTLS") -else(GNUTLS_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} GnuTLS") -endif(GNUTLS_LIBRARIES) - # mysqlclient (using find_library and find_path) find_library(MYSQLCLIENT_LIBRARIES mysqlclient PATH_SUFFIXES mysql) if(MYSQLCLIENT_LIBRARIES) diff --git a/cmake/Modules/FindLibJWT.cmake b/cmake/Modules/FindLibJWT.cmake index 232a106e2..fb35490d4 100644 --- a/cmake/Modules/FindLibJWT.cmake +++ b/cmake/Modules/FindLibJWT.cmake @@ -9,7 +9,7 @@ find_path(LIBJWT_INCLUDE_DIR ) find_library(LIBJWT_LIBRARY - NAMES jwt libjwt liblibjwt jwt-gnutls libjwt-gnutls liblibjjwt-gnutls + NAMES jwt-gnutls libjwt-gnutls liblibjwt-gnutls HINTS ${PC_LIBJWT_LIBDIR} ${PC_LIBJWT_LIBRARY_DIR} )