From 67bae522e5ad7c9a8489d967fd73a1d01225c0bf Mon Sep 17 00:00:00 2001 From: Prince Melvin Date: Tue, 2 Jun 2026 11:54:07 +0530 Subject: [PATCH] Enable Control Flow Guard (CFG) for Release builds Add Guard to both ClCompile and Link sections in the vcxproj for Release|Win32 and Release|x64 configurations. Also add /guard:cf compiler and linker flags in CMakeLists.txt for MSVC builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- LogMonitor/src/CMakeLists.txt | 5 +++++ LogMonitor/src/LogMonitor/LogMonitor.vcxproj | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/LogMonitor/src/CMakeLists.txt b/LogMonitor/src/CMakeLists.txt index 35ca5752..3066bc6d 100644 --- a/LogMonitor/src/CMakeLists.txt +++ b/LogMonitor/src/CMakeLists.txt @@ -37,6 +37,11 @@ target_include_directories(LogMonitor PRIVATE target_link_libraries(LogMonitorLib PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(LogMonitor PRIVATE LogMonitorLib nlohmann_json::nlohmann_json) +if(MSVC) + target_compile_options(LogMonitor PRIVATE /guard:cf) + target_link_options(LogMonitor PRIVATE /guard:cf) +endif() + # Set output path — use $ so Release/Debug binaries go into separate subdirectories, # matching the pipeline's $(buildConfiguration) layout. set_target_properties(LogMonitor PROPERTIES diff --git a/LogMonitor/src/LogMonitor/LogMonitor.vcxproj b/LogMonitor/src/LogMonitor/LogMonitor.vcxproj index 5976a443..a1dae0f4 100644 --- a/LogMonitor/src/LogMonitor/LogMonitor.vcxproj +++ b/LogMonitor/src/LogMonitor/LogMonitor.vcxproj @@ -125,12 +125,14 @@ true true true + Guard WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true pch.h Console + Guard true true true @@ -144,6 +146,7 @@ true true true + Guard NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true pch.h @@ -151,6 +154,7 @@ Console + Guard true true true