Skip to content

Commit

Permalink
Enable additional security checks for MSVC
Browse files Browse the repository at this point in the history
The /sdl compiler option enables additional security checks that were
previously not enabled.
  • Loading branch information
charles-lunarg committed Oct 10, 2023
1 parent d728191 commit 9c621f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 9c621f1

Please sign in to comment.