[cmake] add -DWITH_LIBRESSL option

* this option forces LibreSSL detection using CMake files, disables
  OpenSSL and MbedTLS detection
* Sets compatiblity options with OpenSSL to allow build to succeed
This commit is contained in:
Armin Novak 2023-12-20 23:30:24 +01:00 committed by David Fort
parent 46179077b9
commit 36f3aa68a7
2 changed files with 31 additions and 6 deletions

View File

@ -609,8 +609,21 @@ endif()
find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION})
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
option(WITH_LIBRESSL "build with LibreSSL" OFF)
if (WITH_LIBRESSL)
find_package(LibreSSL REQUIRED)
include_directories(${LibreSSL_INCLUDE_DIRS})
set(OPENSSL_INCLUDE_DIR ${LIBRESSL_INCLUDE_DIR})
set(OPENSSL_LIBRARIES ${LIBRESSL_LIBRARIES})
set(OPENSSL_CRYPTO_LIBRARIES ${LIBRESSL_LIBRARIES})
set(WITH_OPENSSL ON)
set(OPENSSL_FOUND ON)
add_definitions("-DWITH_LIBRESSL")
add_definitions("-DWITH_OPENSSL")
else()
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
endif()
find_feature(PCSC ${PCSC_FEATURE_TYPE} ${PCSC_FEATURE_PURPOSE} ${PCSC_FEATURE_DESCRIPTION})

View File

@ -269,7 +269,7 @@ if(NOT WIN32 AND NOT IOS)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES pthread)
endif()
set(OPENSSL_FEATURE_TYPE "RECOMMENDED")
set(OPENSSL_FEATURE_TYPE "RECOMMENDED")
set(OPENSSL_FEATURE_PURPOSE "cryptography")
set(OPENSSL_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
@ -277,10 +277,22 @@ set(OPENSSL_FEATURE_TYPE "RECOMMENDED")
set(MBEDTLS_FEATURE_PURPOSE "cryptography")
set(MBEDTLS_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
option(WITH_LIBRESSL "build with LibreSSL" OFF)
if (WITH_LIBRESSL)
find_package(LibreSSL REQUIRED)
set(OPENSSL_INCLUDE_DIR ${LIBRESSL_INCLUDE_DIR})
set(OPENSSL_LIBRARIES ${LIBRESSL_LIBRARIES})
set(OPENSSL_CRYPTO_LIBRARIES ${LIBRESSL_LIBRARIES})
set(WITH_OPENSSL ON)
set(OPENSSL_FOUND ON)
add_definitions("-DWITH_LIBRESSL")
add_definitions("-DWITH_OPENSSL")
else()
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
endif()
if (NOT OPENSSL_FOUND AND NOT MBEDTLS_FOUND)
if (NOT OPENSSL_FOUND AND NOT MBEDTLS_FOUND AND NOT LibreSSL_FOUND)
message(FATAL_ERROR "OpenSSL or MBedTLS are required, none enabled/found")
endif()