Build: Cleanup gnutls/openssl defines

We only need HAVE_LIBGNUTLS and HAVE_LIBOPENSSL to compile the right crypto backend.
This commit is contained in:
Peter Keresztes Schmidt 2021-05-30 22:52:04 +02:00
parent 5d93555d9f
commit 8129600a37
3 changed files with 0 additions and 48 deletions

View File

@ -371,7 +371,6 @@ if (${ZM_CRYPTO_BACKEND} STREQUAL "gnutls")
set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}") set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}")
endif() endif()
mark_as_advanced(FORCE GNUTLS_LIBRARIES 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") set(optlibsfound "${optlibsfound} GnuTLS")
else() else()
set(optlibsnotfound "${optlibsnotfound} GnuTLS") set(optlibsnotfound "${optlibsnotfound} GnuTLS")
@ -381,11 +380,9 @@ elseif (${ZM_CRYPTO_BACKEND} STREQUAL "openssl")
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND) if(OPENSSL_FOUND)
set(HAVE_LIBOPENSSL 1) set(HAVE_LIBOPENSSL 1)
set(HAVE_LIBCRYPTO 1)
list(APPEND ZM_BIN_LIBS "${OPENSSL_LIBRARIES}") list(APPEND ZM_BIN_LIBS "${OPENSSL_LIBRARIES}")
include_directories("${OPENSSL_INCLUDE_DIR}") include_directories("${OPENSSL_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H)
set(optlibsfound "${optlibsfound} OpenSSL") set(optlibsfound "${optlibsfound} OpenSSL")
else() else()
set(optlibsnotfound "${optlibsnotfound} OpenSSL") set(optlibsnotfound "${optlibsnotfound} OpenSSL")
@ -679,41 +676,6 @@ if(ZM_ONVIF)
set(ZM_HAS_ONVIF 1) set(ZM_HAS_ONVIF 1)
endif() endif()
# Check for authentication functions
if(HAVE_OPENSSL_MD5_H)
set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
check_prototype_definition(
MD5
"unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)" "NULL" "openssl/md5.h"
HAVE_MD5_OPENSSL)
endif()
if(HAVE_GNUTLS_GNUTLS_H)
set(CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARIES}")
set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}")
check_prototype_definition(
gnutls_fingerprint
"int gnutls_fingerprint (gnutls_digest_algorithm_t algo, const gnutls_datum_t * data, void *result, size_t * result_size)" "0" "stdlib.h;gnutls/gnutls.h"
HAVE_DECL_GNUTLS_FINGERPRINT)
endif()
if(NOT HAVE_DECL_GNUTLS_FINGERPRINT AND HAVE_MD5_OPENSSL)
set(HAVE_DECL_MD5 1)
endif()
if((NOT HAVE_MD5_OPENSSL) AND (NOT HAVE_DECL_GNUTLS_FINGERPRINT))
message(AUTHOR_WARNING
"ZoneMinder requires a working MD5 function for hashed authentication but
none were found - hashed authentication will not be available")
endif()
# Dirty fix for zm_user only using openssl's md5 if gnutls is not available.
# This needs to be fixed in zm_user.[h,cpp] but such fix will also require changes to configure.ac
if(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL)
set(HAVE_GNUTLS_OPENSSL_H 0)
endif()
# Check for Perl # Check for Perl
find_package(Perl) find_package(Perl)
if(NOT PERL_FOUND) if(NOT PERL_FOUND)

View File

@ -15,7 +15,6 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall CFLAGS = -Wall
CXXFLAGS = -DHAVE_LIBCRYPTO
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
DEBOPT = --enable-debug DEBOPT = --enable-debug

View File

@ -29,14 +29,11 @@
#cmakedefine HAVE_LIBJPEG 1 #cmakedefine HAVE_LIBJPEG 1
#cmakedefine HAVE_JPEGLIB_H 1 #cmakedefine HAVE_JPEGLIB_H 1
#cmakedefine HAVE_LIBOPENSSL 1 #cmakedefine HAVE_LIBOPENSSL 1
#cmakedefine HAVE_OPENSSL_MD5_H 1
#cmakedefine HAVE_LIBCRYPTO 1
#cmakedefine HAVE_LIBPTHREAD 1 #cmakedefine HAVE_LIBPTHREAD 1
#cmakedefine HAVE_PTHREAD_H #cmakedefine HAVE_PTHREAD_H
#cmakedefine HAVE_LIBPCRE 1 #cmakedefine HAVE_LIBPCRE 1
#cmakedefine HAVE_PCRE_H 1 #cmakedefine HAVE_PCRE_H 1
#cmakedefine HAVE_LIBGNUTLS 1 #cmakedefine HAVE_LIBGNUTLS 1
#cmakedefine HAVE_GNUTLS_GNUTLS_H 1
#cmakedefine HAVE_LIBMYSQLCLIENT 1 #cmakedefine HAVE_LIBMYSQLCLIENT 1
#cmakedefine HAVE_MYSQL_H 1 #cmakedefine HAVE_MYSQL_H 1
#cmakedefine HAVE_LIBAVFORMAT 1 #cmakedefine HAVE_LIBAVFORMAT 1
@ -68,12 +65,6 @@
#cmakedefine HAVE_LIBJWT 1 #cmakedefine HAVE_LIBJWT 1
#cmakedefine HAVE_RTSP_SERVER 1 #cmakedefine HAVE_RTSP_SERVER 1
/* Authenication checks */
#cmakedefine HAVE_MD5_OPENSSL 1
#cmakedefine HAVE_MD5_GNUTLS 1
#cmakedefine HAVE_DECL_MD5 1
#cmakedefine HAVE_DECL_GNUTLS_FINGERPRINT 1
/* Few ZM options that are needed by the source code */ /* Few ZM options that are needed by the source code */
#cmakedefine ZM_MEM_MAPPED 1 #cmakedefine ZM_MEM_MAPPED 1