]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: enable FORTFY flags if supported 8301/head
authorKefu Chai <kchai@redhat.com>
Thu, 24 Mar 2016 15:20:44 +0000 (23:20 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 10 May 2016 18:41:12 +0000 (02:41 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt

index 46f5bd14589150a0095098cdd1a5d07d3886800e..9afa6e0e8f4e7f16c43730b02d9e4ab8912d5505 100644 (file)
@@ -16,6 +16,18 @@ set(CMAKE_ASM_COMPILER  ${PROJECT_SOURCE_DIR}/src/yasm-wrapper)
 set(CMAKE_ASM_FLAGS "-f elf64")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char -fPIC")
 
+include(CheckCCompilerFlag)
+CHECK_C_COMPILER_FLAG("-Wp,-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,-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")
+endif()
+
 execute_process(
   COMMAND yasm -f elf64 ${CMAKE_SOURCE_DIR}/src/common/crc32c_intel_fast_asm.S -o /dev/null
   RESULT_VARIABLE no_yasm