[Commits] 52a1b5a: MY_CHECK_AND_SET_COMPILER_FLAG changes

holyfoot at askmonty.org holyfoot at askmonty.org
Wed Mar 11 11:11:33 EET 2015


revision-id: 52a1b5a8c23ebd068172c3c18a4f11c690fd1a2c
parent(s): 190858d996e7dc90e01fe8a5e7daec6af0012b23
committer: Alexey Botchkov
branch nick: 10.1
timestamp: 2015-03-11 13:05:03 +0400
message:

MY_CHECK_AND_SET_COMPILER_FLAG changes

* watch for "redefined macro" warning
* don't enable -D_FORTIFY_SOURCE=2 in debug builds (it requires -O)

---
 CMakeLists.txt                  | 8 +-------
 cmake/check_compiler_flag.cmake | 1 +
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ca49a9..48015fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -206,13 +206,7 @@ IF(SECURITY_HARDENED)
   MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
   MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
   MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")
-
-  # sometimes _FORTIFY_SOURCE is predefined
-  INCLUDE(CheckSymbolExists)
-  CHECK_SYMBOL_EXISTS(_FORTIFY_SOURCE "" HAVE_FORTIFY_SOURCE)
-  IF(NOT HAVE_FORTIFY_SOURCE)
-    ADD_DEFINITIONS(-D_FORTIFY_SOURCE=2)
-  ENDIF()
+  MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO)
 ENDIF()
 
 OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON) 
diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake
index 25e4af2..8eb6ed2 100644
--- a/cmake/check_compiler_flag.cmake
+++ b/cmake/check_compiler_flag.cmake
@@ -9,6 +9,7 @@ SET(fail_patterns
     FAIL_REGEX "unrecognized .*option"
     FAIL_REGEX "ignoring unknown option"
     FAIL_REGEX "warning:.*ignored"
+    FAIL_REGEX "warning:.*redefined"
     FAIL_REGEX "[Ww]arning: [Oo]ption"
     )
 


More information about the commits mailing list