Skip to content

Commit

Permalink
Fix setting of config-specific hardening options
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed May 19, 2024
1 parent 46081b2 commit 925c23b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Hardening.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<CONFIG:Release,RelWithDebInfo>:DEBUG_FORTIFY_SOURCE=3>)
endif()

if(${ENABLE_ELF_PROTECTION})
Expand All @@ -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 $<$<CONFIG:Debug>:/RTC1>)

if(${ENABLE_OVERFLOW_PROTECTION})
list(APPEND HARDENING_COMPILE_OPTIONS /sdl)
Expand Down

0 comments on commit 925c23b

Please sign in to comment.