File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,17 @@ macro(os_set_flags)
7272
7373 if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|armv7l" OR APPLE OR # Some flags are not recognized or some systems / gcc versions
7474 (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0" )) #
75- set (ADDITIONAL_COMPILER_FLAGS "-Wformat -Wformat-security -fPIC -D_FORTIFY_SOURCE=2 - fstack-protector" )
75+ set (ADDITIONAL_COMPILER_FLAGS "-Wformat -Wformat-security -fPIC -fstack-protector" )
7676 else ()
7777 #‘-mfunction-return’ and ‘-fcf-protection’ are not compatible, so specifing -fcf-protection=none
78- set (ADDITIONAL_COMPILER_FLAGS "-Wformat -Wformat-security -fPIC -D_FORTIFY_SOURCE=2 - fcf-protection=none -mfunction-return=thunk -mindirect-branch=thunk -mindirect-branch-register -fstack-protector" )
78+ set (ADDITIONAL_COMPILER_FLAGS "-Wformat -Wformat-security -fPIC -fcf-protection=none -mfunction-return=thunk -mindirect-branch=thunk -mindirect-branch-register -fstack-protector" )
7979 endif ()
8080 set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -pie" )
8181
82+ string (FIND "${CMAKE_CXX_FLAGS} " "-D_FORTIFY_SOURCE" _index)
83+ if (${_index} EQUAL -1) # Define D_FORTIFY_SOURCE is undefined
84+ set (ADDITIONAL_COMPILER_FLAGS "${ADDITIONAL_COMPILER_FLAGS} -D_FORTIFY_SOURCE=2" )
85+ endif ()
8286
8387 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
8488 message (STATUS "Configuring for Debug build" )
You can’t perform that action at this time.
0 commit comments