activate libssp compiler flags for gcc only

In 82c8a1e3 I made "--param ssp-buffer-size=4" one argument instead of
two to fix another problem when passing compiler flags to
CMAKE_REQUIRED_LIBRARIES, clang cannot deal with this and this breaks
the build on mac.

Enable libssp related flags for gcc only, because clang does not support
them anyway. This fixes the build issue on mac.
This commit is contained in:
Rafael Kitover 2017-03-11 19:19:47 -08:00
parent 82c8a1e3fa
commit 915e2d1ec2
1 changed files with 10 additions and 7 deletions

View File

@ -335,17 +335,20 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
SET(MY_C_FLAGS ${MY_C_FLAGS} -fPIC)
ENDIF()
# check if SSP flags are supported
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
IF(F_STACK_PROTECTOR_STRONG_FLAG)
SET(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
# check if ssp flags are supported for this version of gcc
IF(CMAKE_COMPILER_IS_GNUCXX)
CHECK_CXX_COMPILER_FLAG(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
CHECK_CXX_COMPILER_FLAG("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
IF(F_STACK_PROTECTOR_STRONG_FLAG)
SET(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
IF(SSP_BUFFER_SIZE_FLAG)
SET(MY_C_FLAGS ${MY_C_FLAGS} "--param ssp-buffer-size=4")
CHECK_CXX_COMPILER_FLAG("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
IF(SSP_BUFFER_SIZE_FLAG)
SET(MY_C_FLAGS ${MY_C_FLAGS} "--param ssp-buffer-size=4")
ENDIF()
ENDIF()
ENDIF()