cmake: Only prevent MSVC codegen using the CRT if SDL_LIBC=OFF

This commit is contained in:
Cameron Gutman 2021-11-04 01:02:48 -05:00
parent d8b53e821e
commit 7f308abb55
1 changed files with 9 additions and 7 deletions

View File

@ -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)