From: John Spray Date: Tue, 28 Jun 2016 14:54:13 +0000 (+0100) Subject: cmake: fix FORTIFY_SOURCE check X-Git-Tag: v11.0.0~8^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=004c8d1f2fda2f909ae84a5030fa32ab8f96a66f;p=ceph-ci.git cmake: fix FORTIFY_SOURCE check This got broken in 6f3e3cf6. The -Werror part wasn't having the desired effect, so we were enabling FORTIFY_SOURCE even when in -O0 Signed-off-by: John Spray --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16a22d66160..0bda6635f73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,10 +26,12 @@ if(NOT CMAKE_BUILD_TYPE) endif() include(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG("-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2 -Werror" HAS_FORTIFY_SOURCE) +CHECK_C_COMPILER_FLAG("-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2" HAS_FORTIFY_SOURCE) +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(HAS_FORTIFY_SOURCE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2") endif() +endif() CHECK_C_COMPILER_FLAG(-fstack-protector-strong HAS_STACK_PROTECT) if (HAS_STACK_PROTECT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")