Add a CF_PROTECTION variable to hold the -fcf-protection flag in the CMakeLists.txt file

This commit is contained in:
Username404-59 2021-08-22 17:03:53 +02:00
parent 9a1ea05e83
commit 57f8f251bc
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 2 deletions

View File

@ -40,9 +40,10 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUA
set(CMAKE_CXX_FLAGS "-flto ${CMAKE_CXX_FLAGS} -pipe -fstack-protector-strong -fstack-clash-protection -fexceptions")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fmerge-all-constants -ftree-vectorize")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-fcf-protection" CF_PROTECTION_SUPPORTED)
set(CF_PROTECTION "-fcf-protection")
CHECK_CXX_COMPILER_FLAG("${CF_PROTECTION}" CF_PROTECTION_SUPPORTED)
if (CF_PROTECTION_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CF_PROTECTION}")
endif()
endif()