From 55d7e31f7e224af1019a0827be522e07de9ddcab Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 12 May 2024 15:10:01 +0000 Subject: [PATCH] Use hardening flags only for debug builds to avoid conflicts --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b84ebaf9c..eb42827d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,9 +400,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") # false positives in boost::multiarray during release build, keep as warning-only endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT WIN32) - # For gcc 14+ we can use -fhardened instead - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -fcf-protection=full") + if(CMAKE_BUILD_TYPE MATCHES Debug) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT WIN32) + # For gcc 14+ we can use -fhardened instead + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -fcf-protection=full") + endif() endif() # Fix string inspection with lldb