From 1aa82864ceb6c567189b8cbd78d7ec7e3e6f2cd0 Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Sat, 11 Jul 2020 23:09:38 -0400 Subject: [PATCH] Add CMake option to toggle stack protection hardening --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f45c873..bbc21f3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,12 @@ else (MSVC) set(CPPLINT_ARG_OUTPUT "--output=eclipse") set(CPPCHECK_ARG_TEMPLATE "--template=gcc") # Useful compile flags and extra warnings - add_compile_options(-fstack-protector) + # Stack protection is not supported on MinGW-W64 on Windows, allow this flag to be turned off. + option(SQLITECPP_USE_STACK_PROTECTION "USE Stack Protection hardening." ON) + if (SQLITECPP_USE_STACK_PROTECTION) + message (STATUS "Using Stack Protection hardening") + add_compile_options(-fstack-protector) + endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wswitch-enum -Wshadow -Wno-long-long") # C++ only, don't bother with sqlite3 if (CMAKE_COMPILER_IS_GNUCXX) # GCC flags