From 925c23b1c9669d1be4b657b6f2e853298e87b9f8 Mon Sep 17 00:00:00 2001 From: FeignClaims Date: Sun, 19 May 2024 15:11:18 +0800 Subject: [PATCH] Fix setting of config-specific hardening options --- src/Hardening.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Hardening.cmake b/src/Hardening.cmake index 6c6e26c1..a239a6dd 100644 --- a/src/Hardening.cmake +++ b/src/Hardening.cmake @@ -44,9 +44,7 @@ function( list(APPEND HARDENING_COMPILE_OPTIONS -Wstringop-overflow=4 -Wformat-overflow=2) endif() - if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - target_compile_definitions(${_project_name} INTERFACE _FORTIFY_SOURCE=3) - endif() + target_compile_definitions(${_project_name} INTERFACE $<$:DEBUG_FORTIFY_SOURCE=3>) endif() if(${ENABLE_ELF_PROTECTION}) @@ -64,9 +62,7 @@ function( list(APPEND HARDENING_LINK_OPTIONS /guard:cf) endif() - if(${ENABLE_STACK_PROTECTION} AND CMAKE_BUILD_TYPE STREQUAL "Debug") - list(APPEND HARDENING_COMPILE_OPTIONS /RTC1) - endif() + list(APPEND HARDENING_COMPILE_OPTIONS $<$:/RTC1>) if(${ENABLE_OVERFLOW_PROTECTION}) list(APPEND HARDENING_COMPILE_OPTIONS /sdl)