mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #656 from heinrich5991/pr_ddnet_cmake_check_fortify_source
CMakeLists.txt: Check for _FORTIFY_SOURCE before defining it
This commit is contained in:
commit
acd8bc1fe0
|
@ -123,6 +123,12 @@ else()
|
|||
set(PLATFORM_LIBS)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(_FORTIFY_SOURCE "" FORTIFY_SOURCE_DEFINED)
|
||||
endif()
|
||||
|
||||
|
||||
########################################################################
|
||||
# INITALIZE TARGET LISTS
|
||||
########################################################################
|
||||
|
@ -408,7 +414,9 @@ foreach(target ${TARGETS})
|
|||
target_compile_options(${target} PRIVATE /wd4996) # Use of non-_s functions.
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
target_compile_options(${target} PRIVATE -fstack-protector-all) # Protect the stack pointer.
|
||||
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=1>) # Detect some buffer overflows.
|
||||
if(NOT FORTIFY_SOURCE_DEFINED)
|
||||
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=1>) # Detect some buffer overflows.
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
|
Loading…
Reference in a new issue