]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: eliminate FORTIFY_SOURCE warnings
authorAli Maredia <amaredia@redhat.com>
Fri, 17 Jun 2016 19:31:45 +0000 (15:31 -0400)
committerAli Maredia <amaredia@redhat.com>
Tue, 21 Jun 2016 17:44:47 +0000 (13:44 -0400)
"-werr" was added to CHECK_C_COMPILER_FLAG to
make sure FORTIFY_SOURCE is only turned on if
the flag generates no warnings.

Added "-U_FORTIFY_SOURCE" to CMAKE_C_FLAGS to
mimic PR #9761.

Signed-off-by: Ali Maredia <amaredia@redhat.com>
src/CMakeLists.txt

index ab0b2fdfb6f77f5afc093fb7fbc3bacc77131f50..0e8809fcd97b66a1913a24666f33a69ff4dcc5b9 100644 (file)
@@ -22,11 +22,9 @@ 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")
+CHECK_C_COMPILER_FLAG("-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2 -Werror" HAS_FORTIFY_SOURCE)
 if(HAS_FORTIFY_SOURCE)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
-endif()
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2")
 endif()
 CHECK_C_COMPILER_FLAG(-fstack-protector-strong HAS_STACK_PROTECT)
 if (HAS_STACK_PROTECT)