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() endforeach()
endif() endif()
# Make sure /RTC1 is disabled, otherwise it will use functions from the CRT if(NOT SDL_LIBC)
foreach(flag_var # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE foreach(flag_var
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}") CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
endforeach(flag_var) string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
endif()
endif() endif()
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config, # 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}) list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
endif() endif()
if(MSVC) if(MSVC AND NOT SDL_LIBC)
# Prevent codegen that would use the VC runtime libraries. # Prevent codegen that would use the VC runtime libraries.
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-") set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-")
if(NOT ARCH_64) if(NOT ARCH_64)