From 7f8e5278834b238ed0b2b8e8a6257bdd09192e1e Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Tue, 10 Aug 2021 22:58:28 +0200 Subject: [PATCH] CMake: Fix BLAKE2 build failure with MSVC due to it not defining __SSE2__ --- src/Cedar/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Cedar/CMakeLists.txt b/src/Cedar/CMakeLists.txt index 120bb4ab..ac9343c6 100644 --- a/src/Cedar/CMakeLists.txt +++ b/src/Cedar/CMakeLists.txt @@ -29,6 +29,12 @@ set(BLAKE2_SRC $,${BLAKE2_SRC_PATH}/blake2s.c,${BLAKE2_SR target_include_directories(cedar PUBLIC ${BLAKE2_SRC_PATH}) target_sources(cedar PRIVATE ${BLAKE2_SRC}) +if(HAS_SSE2) + # If SSE2 is enabled, a build failure occurs with MSVC because it doesn't define "__SSE2__". + # The fix consists in defining "HAVE_SSE2" manually, effectively overriding the check. + set_property(SOURCE ${BLAKE2_SRC} PROPERTY COMPILE_DEFINITIONS "HAVE_SSE2") +endif() + if(VCPKG_TARGET_TRIPLET) find_package(unofficial-sodium CONFIG REQUIRED) target_link_libraries(cedar PUBLIC unofficial-sodium::sodium)