From f8d925987ba7e60ae99e9c4cc50a7df326ecdf16 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Wed, 24 Apr 2019 11:00:17 -0700 Subject: [PATCH] Update CMakeLists.txt Adds Control Flow Guard compiler flag to vulkaninfo Control Flow Guard (CG) protects against some forms of memory corruption. See https://docs.microsoft.com/en-us/windows/desktop/secbp/control-flow-guard for details. This compiler flag enables CFG on vulkaninfo. (CFG is already enabled on the Cube project.) Enabling CFG is a low-risk, "set and forget" low hanging fruit for security hardening. --- vulkaninfo/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vulkaninfo/CMakeLists.txt b/vulkaninfo/CMakeLists.txt index b9d0dfa..5a822c4 100644 --- a/vulkaninfo/CMakeLists.txt +++ b/vulkaninfo/CMakeLists.txt @@ -71,6 +71,13 @@ endif() if(WIN32) target_compile_definitions(vulkaninfo PUBLIC -DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS) + if(NOT MSVC_VERSION LESS 1900) + # Enable control flow guard + message(STATUS "Building vulkaninfo with control flow guard") + add_compile_options("$<$:/guard:cf>") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf") + endif() # Use static MSVCRT libraries foreach(configuration -- 2.7.4