From 845c67afada705ae3bba05897e1e7f0843e0bcca Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 18 Oct 2022 14:53:37 +0200 Subject: [PATCH] Use CMake to configure static C stdlib on Windows Previously warnings were generated because we were passing /MTd-like arguments twice, due to us and CMake 3.15+ adding these arguments: https://cmake.org/cmake/help/v3.25/policy/CMP0091.html. This requires CMake 3.15 on Windows. This fixes #5940. --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7121046d..05d78ebb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -800,10 +800,11 @@ if(NOT(GTEST_FOUND) AND DOWNLOAD_GTEST) if(MSVC) foreach(target gtest gmock) + set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded$<${DBG}:Debug>) # `/w` disables all warnings. This is needed because `gtest` enables # `/WX` (equivalent of `-Werror`) for some reason, breaking builds # when MSVS adds new warnings. - target_compile_options(${target} PRIVATE $<$:/MT> $<${DBG}:/MTd> /w) + target_compile_options(${target} PRIVATE /w) endforeach() endif() @@ -2996,7 +2997,7 @@ set(TARGETS ${TARGETS_OWN} ${TARGETS_DEP}) foreach(target ${TARGETS}) if(MSVC) - target_compile_options(${target} PRIVATE $<$:/MT> $<${DBG}:/MTd>) # Use static CRT + set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded$<${DBG}:Debug>) # Use static CRT target_compile_options(${target} PRIVATE /MP) # Use multiple cores target_compile_options(${target} PRIVATE /EHsc) # Only catch C++ exceptions with catch. target_compile_options(${target} PRIVATE /GS) # Protect the stack pointer.