Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added workaround mbedtls and clang-cl incomatibility #441

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions external/crypto/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@ set(ENABLE_TESTING Off CACHE INTERNAL "")
set(ENABLE_PROGRAMS Off CACHE INTERNAL "")
set(GEN_FILES Off CACHE INTERNAL "")

# mbedtls uses CMAKE_C_COMPILER_ID to determine the type of compiler used.
# When compiling with clang-cl, mbedtls thinks the clang compiler
# is used, and sets flags according to what clang expects as arguments.
# However, clang-cl expects MSVC like arguments. Therefore we have to trick mbedtls
# in to thinking MSVC is being used as a compiler.
# After making mbedtls available the original COMPILER_ID will be restored
set(ORIGINAL_C_COMPILER_ID ${CMAKE_C_COMPILER_ID})
set(ORIGINAL_CXX_COMPILER_ID ${CMAKE_CXX_COMPILER_ID})

if (CMAKE_C_SIMULATE_ID)
set(CMAKE_C_COMPILER_ID ${CMAKE_C_SIMULATE_ID})
endif()

if (CMAKE_CXX_SIMULATE_ID)
set(CMAKE_CXX_COMPILER_ID ${CMAKE_CXX_SIMULATE_ID})
endif()

FetchContent_MakeAvailable(mbedtls)

set(CMAKE_C_COMPILER_ID ${ORIGINAL_C_COMPILER_ID})
set(CMAKE_CXX_COMPILER_ID ${ORIGINAL_CXX_COMPILER_ID})

function(add_mbedtls_target_properties)
foreach(target ${ARGN})
target_compile_options(${target} PUBLIC
daantimmer marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading