From 9c621f149a6a7599ba5ceb93f0e427f21a60febf Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Tue, 10 Oct 2023 10:56:34 -0600 Subject: [PATCH] Enable additional security checks for MSVC The /sdl compiler option enables additional security checks that were previously not enabled. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6d0cf84a..1addd049a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,11 +201,12 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang endif() if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" MATCHES "MSVC")) + # /sdl: Enable additional security checks # /GR-: Disable RTTI # /guard:cf: Enable control flow guard # /wd4152: Disable warning on conversion of a function pointer to a data pointer # /wd4201: Disable warning on anonymous struct/unions - target_compile_options(loader_common_options INTERFACE /GR- /guard:cf /wd4152 /wd4201) + target_compile_options(loader_common_options INTERFACE /sdl /GR- /guard:cf /wd4152 /wd4201) # Enable control flow guard target_link_options(loader_common_options INTERFACE "LINKER:/guard:cf")