From 87e8769643ede4e5932949f5565d51085eeeb58f Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Sun, 31 Mar 2019 22:01:44 +0200 Subject: CMake: Avoid defining _FORTIFY_SOURCE twice in separate places --- CMakeLists.txt | 3 --- CMakeScripts/DefineDependsandFlags.cmake | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d52cae30c..0dcb68102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,9 +127,6 @@ include(CMakeScripts/HelperMacros.cmake) # Misc Utility Macros # ----------------------------------------------------------------------------- # BAD HACKS, NEED TO INVESTIGATE MAKING THESE LESS BAD -if (NOT CMAKE_BUILD_TYPE MATCHES Debug) - add_definitions(-D_FORTIFY_SOURCE=2) -endif() if(BUILD_SHARED_LIBS AND NOT WIN32) add_definitions(-fPIC) endif() diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index c87345552..09362da7d 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -21,13 +21,13 @@ list(APPEND INKSCAPE_CXX_FLAGS "-std=c++11") # Errors for common mistakes list(APPEND INKSCAPE_CXX_FLAGS "-Werror=format") # e.g.: printf("%s", std::string("foo")) list(APPEND INKSCAPE_CXX_FLAGS "-Werror=format-security") # e.g.: printf(variable); -list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-D_FORTIFY_SOURCE=2") +list(APPEND INKSCAPE_CXX_FLAGS "-D_FORTIFY_SOURCE=2") if (CMAKE_COMPILER_IS_GNUCC) -list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-Og") # for _FORTIFY_SOURCE -list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables") -if(CXX_COMPILER_VERSION VERSION_GREATER 8.0) -list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fstack-clash-protection -fcf-protection") -endif() + list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-Og") # for _FORTIFY_SOURCE + list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables") + if(CXX_COMPILER_VERSION VERSION_GREATER 8.0) + list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fstack-clash-protection -fcf-protection") + endif() endif() # Define the flags for profiling if desired: if(WITH_PROFILING) -- cgit v1.2.3