From ffc095f95a51b515aa3fb2d2f89b2d90d1f093fd Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sun, 8 Aug 2021 19:29:32 +0200 Subject: [PATCH] CMake: Add build time check for EVP_PKEY_get_raw_public_key() availability We need the function since 9dbbfcd388a11d78a8efe1501aee1e385867b5a9, but unfortunately it's not provided by LibreSSL. By introducing a build time check we inform the user about the issue explicitly instead of just letting compilation fail. --- src/Mayaqua/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index 6bca56de..534bc866 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -17,6 +17,21 @@ set_target_properties(mayaqua ) find_package(OpenSSL REQUIRED) + +include(CheckSymbolExists) + +set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +set(CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto) + +check_symbol_exists(EVP_PKEY_get_raw_public_key "openssl/evp.h" HAVE_EVP_PKEY_GET_RAW_PUBLIC_KEY) + +unset(CMAKE_REQUIRED_INCLUDES) +unset(CMAKE_REQUIRED_LIBRARIES) + +if(NOT HAVE_EVP_PKEY_GET_RAW_PUBLIC_KEY) + message(FATAL_ERROR "Required EVP_PKEY_get_raw_public_key() not found in OpenSSL library!") +endif() + find_package(ZLIB REQUIRED) # Required because we include in Encrypt.h.