Update CMakeLists.txt to include OpenSSL include directories and check for SHA256_Init function

This commit is contained in:
2025-10-02 22:17:44 +01:00
parent b83cf6e762
commit a9d4448c46
2 changed files with 8 additions and 3 deletions

View File

@@ -161,9 +161,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
# include(FindLibreSSL.cmake)
# Check for OpenSSL and SHA256_Init
find_package(OpenSSL QUIET)
find_package(LibreSSL QUIET)
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto)
check_function_exists(SHA256_Init HAVE_OPENSSL_SHA256_INIT)
if(OpenSSL_FOUND)
message("-- OpenSSL VERSION: ${OPENSSL_VERSION}")
endif()
@@ -172,13 +177,13 @@ if(LIBRESSL_FOUND)
message("-- LibreSSL VERSION: ${LIBRESSL_VERSION}")
endif()
if(OpenSSL_FOUND OR LIBRESSL_FOUND)
if((OpenSSL_FOUND OR LIBRESSL_FOUND) AND HAVE_OPENSSL_SHA256_INIT)
add_compile_definitions(AARU_HAS_SHA256)
endif()
if(LIBRESSL_FOUND)
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${LIBRESSL_CRYPTO_LIBRARY})
elseif(OpenSSL_FOUND)
elif(OpenSSL_FOUND)
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${OPENSSL_CRYPTO_LIBRARY})
endif()

View File

@@ -37,6 +37,6 @@ target_link_libraries(tests_run PRIVATE gtest gtest_main aaruformat)
if(LIBRESSL_FOUND)
target_link_libraries(tests_run PRIVATE ${LIBRESSL_CRYPTO_LIBRARY})
elseif(OpenSSL_FOUND)
target_link_libraries(tests_run ${OPENSSL_CRYPTO_LIBRARY})
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(tests_run PRIVATE ${OPENSSL_CRYPTO_LIBRARY})
endif()