From ae402f2fd1f7984d97876c3915e3073924df96c5 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 30 Sep 2025 16:16:53 +0100 Subject: [PATCH] Add OpenSSL and LibreSSL support for tests using crypto functions --- tests/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 97d8872..f835874 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,10 @@ project(tests) add_subdirectory(lib) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) +# Find OpenSSL for tests that use it directly +find_package(OpenSSL QUIET) +find_package(LibreSSL QUIET) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/random DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/) @@ -23,4 +27,13 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/data.bin # 'Google_Tests_run' is the target name # 'test1.cpp tests2.cpp' are source files with tests add_executable(tests_run crc64.cpp spamsum.cpp crc32.c crc32.h flac.cpp lzma.cpp sha256.cpp) + +# Link libraries including OpenSSL for SHA256 test target_link_libraries(tests_run gtest gtest_main "aaruformat") + +# Link OpenSSL/LibreSSL for tests that use crypto functions directly +if(LIBRESSL_FOUND) + target_link_libraries(tests_run ${LIBRESSL_CRYPTO_LIBRARY}) +elseif(OpenSSL_FOUND) + target_link_libraries(tests_run ${OPENSSL_CRYPTO_LIBRARY}) +endif()