changeset 9600:788f5768b107

cmake: add -fstack-protector to checked builds, if available
author Steve Borho <steve@borho.org>
date Mon, 02 Mar 2015 16:55:25 -0600
parents 6a9cff19ca93
children c19c94af303f
files source/CMakeLists.txt
diffstat 1 files changed, 4 insertions(+-), 0 deletions(-) [+]
line wrap: on
line diff
--- a/source/CMakeLists.txt	Mon Mar 02 10:04:37 2015 -0600
+++ b/source/CMakeLists.txt	Mon Mar 02 16:55:25 2015 -0600
@@ -183,6 +183,7 @@ if(CHECKED_BUILD)
         check_cxx_compiler_flag(-fsanitize=address CC_HAS_FSANITIZE)              # clang and gcc
         check_cxx_compiler_flag(-fsanitize=undefined-trap CC_HAS_CATCH_UNDEFINED) # clang
         check_cxx_compiler_flag(-ftrapv CC_HAS_FTRAPV)                            # gcc
+        check_cxx_compiler_flag(-fstack-protector CC_HAS_STACK_PROTECT)           # gcc
         if(CC_HAS_FSANITIZE)
             add_definitions(-fsanitize=address)
         endif()
@@ -192,6 +193,9 @@ if(CHECKED_BUILD)
         if(CC_HAS_CATCH_UNDEFINED)
             add_definitions(-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error)
         endif()
+        if(CC_HAS_STACK_PROTECT)
+            add_definitions(-fstack-protector)
+        endif()
     endif(GCC)
 endif()