cmake: Enable CET compatibility for x86/x64 targets using VS 16.7+

This commit is contained in:
Cameron Gutman 2022-08-21 14:15:06 -05:00 committed by Sam Lantinga
parent 00452e47fa
commit 2ceea46061
2 changed files with 10 additions and 0 deletions

View File

@ -688,6 +688,11 @@ if(MSVC)
target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_SECURE_NO_DEPRECATE") target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_SECURE_NO_DEPRECATE")
target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_NONSTDC_NO_DEPRECATE") target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_NONSTDC_NO_DEPRECATE")
target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_SECURE_NO_WARNINGS") target_compile_definitions(sdl-build-options INTERFACE "-D_CRT_SECURE_NO_WARNINGS")
# CET support was added in VS 16.7
if(MSVC_VERSION GREATER 1926 AND NOT CMAKE_GENERATOR_PLATFORM MATCHES ARM)
list(APPEND EXTRA_LDFLAGS_BUILD "-CETCOMPAT")
endif()
endif() endif()
if(MSVC) if(MSVC)

View File

@ -47,6 +47,11 @@ if(WINDOWS)
link_libraries(mingw32) link_libraries(mingw32)
endif() endif()
# CET support was added in VS 16.7
if(MSVC_VERSION GREATER 1926 AND NOT CMAKE_GENERATOR_PLATFORM MATCHES ARM)
link_libraries(-CETCOMPAT)
endif()
# FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin, # FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin,
# but we need them for VS as well. # but we need them for VS as well.
link_libraries(SDL2main) link_libraries(SDL2main)