diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2013-12-20 15:23:55 +0100 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2013-12-20 15:23:55 +0100 |
commit | b5a3ce9158cafd820a3461dc017d1720061d87de (patch) | |
tree | acb5e2a3644ccd3cf41b92fd072d739cbe88c6b2 | |
parent | b435fc9d578e1b63711d72aeb757ec640ae1c8cd (diff) | |
download | openlmi-providers-b5a3ce9158cafd820a3461dc017d1720061d87de.tar.gz openlmi-providers-b5a3ce9158cafd820a3461dc017d1720061d87de.tar.xz openlmi-providers-b5a3ce9158cafd820a3461dc017d1720061d87de.zip |
build: Check for -fstack-protector-strong availability
Some compilers don't seem to support -fstack-protector-strong, let's make
it conditional.
$ gcc -fstack-protector-strong
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
$ gcc -v
gcc version 4.8.1 (Gentoo 4.8.1-r1 p1.2, pie-0.5.7)
-rw-r--r-- | CMakeLists.txt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de7156..77627ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,16 @@ cmake_minimum_required(VERSION 2.6) # Set flags and definitions add_definitions(-D_XOPEN_SOURCE=500 -D_GNU_SOURCE) -set(CMAKE_C_FLAGS "-std=c99 -fstack-protector-strong -Wall -W -Wformat-security -pedantic -g -Wextra -Wno-unused-parameter -Wformat -Wparentheses -Wl,--no-undefined ${CMAKE_C_FLAGS}") +set(CMAKE_C_FLAGS "-std=c99 -Wall -W -Wformat-security -pedantic -g -Wextra -Wno-unused-parameter -Wformat -Wparentheses -Wl,--no-undefined ${CMAKE_C_FLAGS}") + +# Some compilers don't have -fstack-protector-strong yet +include(CheckCCompilerFlag) +check_c_compiler_flag(-fstack-protector-strong HAS_STACK_PROTECTOR_STRONG) +if(HAS_STACK_PROTECTOR_STRONG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong") +else(HAS_STACK_PROTECTOR_STRONG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector") +endif() # Set LIB_SUFFIX to 64 on 64bit architectures if(CMAKE_SIZEOF_VOID_P EQUAL 4) |