aboutsummaryrefslogtreecommitdiff
path: root/CompilerChecks.cmake
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-08-22 08:35:46 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-22 08:54:59 +0200
commit5e9435924c547555185d70470096e4f3a72124a6 (patch)
tree911c0a0b86cc417f8136422a33c50dbb8fb67c7d /CompilerChecks.cmake
parent64a354159f0ca4bfe64876b70a1b2941a934cf98 (diff)
downloadlibssh-5e9435924c547555185d70470096e4f3a72124a6.tar.gz
libssh-5e9435924c547555185d70470096e4f3a72124a6.tar.xz
libssh-5e9435924c547555185d70470096e4f3a72124a6.zip
cmake: Set -D_FORTIFY_SOURCE=2 if possible
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'CompilerChecks.cmake')
-rw-r--r--CompilerChecks.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake
index 5762ee15..4d8850c6 100644
--- a/CompilerChecks.cmake
+++ b/CompilerChecks.cmake
@@ -49,6 +49,14 @@ if (UNIX)
endif()
unset(CMAKE_REQUIRED_FLAGS)
+
+ if (CMAKE_BUILD_TYPE)
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
+ if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel))
+ add_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" SUPPORTED_COMPILER_FLAGS)
+ endif()
+ endif()
+
if (PICKY_DEVELOPER)
add_c_compiler_flag("-Werror" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wno-error=deprecated-declarations" SUPPORTED_COMPILER_FLAGS)