From 178847613640e88d065195a82bc6813fe66bccc6 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 20 Mar 2021 21:20:21 +0100 Subject: [PATCH] Use control flow protection if the compiler supports it in CMakeLists.txt. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f950aca..1fdb977 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)