Use control flow protection if the compiler supports it in CMakeLists.txt.

This commit is contained in:
Username404 2021-03-20 21:20:21 +01:00
parent 1413124530
commit 1788476136
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 5 additions and 0 deletions

View File

@ -29,6 +29,11 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUAL
endif()
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
set(CMAKE_CXX_FLAGS "-flto ${CMAKE_CXX_FLAGS} -fpie -pipe -fstack-protector-strong -fstack-clash-protection")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-fcf-protection" CF_PROTECTION_SUPPORTED)
if (CF_PROTECTION_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection")
endif()
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)