aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a02f62e62..5e47edcca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -498,6 +498,17 @@ else()
set(ARCH_FLAG "-march=armv8")
else()
set(ARCH_FLAG "-march=${ARCH}")
+ if(ARCH STREQUAL "native")
+ check_c_compiler_flag(-march=native CC_SUPPORTS_MARCH_NATIVE)
+ if (NOT CC_SUPPORTS_MARCH_NATIVE)
+ check_c_compiler_flag(-mtune=native CC_SUPPORTS_MTUNE_NATIVE)
+ if (CC_SUPPORTS_MTUNE_NATIVE)
+ set(ARCH_FLAG "-mtune=${ARCH}")
+ else()
+ set(ARCH_FLAG "")
+ endif()
+ endif()
+ endif()
endif()
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
if(NOT MINGW)
@@ -570,6 +581,17 @@ else()
add_cxx_flag_if_supported(-fstack-protector-strong CXX_SECURITY_FLAGS)
endif()
+ # New in GCC 8.2
+ if (NOT WIN32)
+ add_c_flag_if_supported(-fcf-protection=full C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-fcf-protection=full CXX_SECURITY_FLAGS)
+ add_c_flag_if_supported(-fstack-clash-protection C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-fstack-clash-protection CXX_SECURITY_FLAGS)
+ endif()
+
+ add_c_flag_if_supported(-mmitigate-rop C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-mmitigate-rop CXX_SECURITY_FLAGS)
+
# linker
if (NOT WIN32)
# Windows binaries die on startup with PIE