From 7f308abb559e426ec7562a47db5176bb11a9175d Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Thu, 4 Nov 2021 01:02:48 -0500
Subject: [PATCH] cmake: Only prevent MSVC codegen using the CRT if
SDL_LIBC=OFF
---
CMakeLists.txt | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index edb926fe01..eeec50ce04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -237,12 +237,14 @@ if(MSVC)
endforeach()
endif()
- # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
- foreach(flag_var
- CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
- string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
- endforeach(flag_var)
+ if(NOT SDL_LIBC)
+ # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
+ foreach(flag_var
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+ string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
+ endforeach(flag_var)
+ endif()
endif()
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
@@ -1469,7 +1471,7 @@ elseif(WINDOWS)
list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
endif()
- if(MSVC)
+ if(MSVC AND NOT SDL_LIBC)
# Prevent codegen that would use the VC runtime libraries.
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-")
if(NOT ARCH_64)