1
0
Fork 0

Fix: [CMake] Use the right run-time library depending on vcpkg triplet (#8964)

pull/9160/head
Loïc Guilloux 2021-04-07 12:43:17 +02:00 committed by Charles Pigott
parent 5cbbb0d17b
commit 5c6b43832c
1 changed files with 14 additions and 12 deletions

View File

@ -4,6 +4,7 @@
# #
macro(compile_flags) macro(compile_flags)
if(MSVC) if(MSVC)
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
# Switch to MT (static) instead of MD (dynamic) binary # Switch to MT (static) instead of MD (dynamic) binary
# For MSVC two generators are available # For MSVC two generators are available
@ -18,6 +19,7 @@ macro(compile_flags)
string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS) string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS)
string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}") string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}")
endforeach() endforeach()
endif()
# "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the # "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the
# C++11 standard". We need C++11 for the way we use threads. # C++11 standard". We need C++11 for the way we use threads.