aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-12-25 17:35:07 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-12-25 17:35:07 +0100
commitfb3f649c76dc9b16a163c7df7a26b9303b6d6319 (patch)
tree1b9a062af5edf8175a304f93afef76bc434773b5 /cmake/Modules
parent5dfc474fa842286d30c6912f21b66f6aa421edfb (diff)
downloadlibssh-fb3f649c76dc9b16a163c7df7a26b9303b6d6319.tar.gz
libssh-fb3f649c76dc9b16a163c7df7a26b9303b6d6319.tar.xz
libssh-fb3f649c76dc9b16a163c7df7a26b9303b6d6319.zip
cmake: Only set -D_FORTIFY_SOURCE=2 if we have optimizations.
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index f2ac0822..d2315721 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -26,10 +26,13 @@ if (UNIX AND NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif (WITH_STACK_PROTECTOR)
- check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
- if (WITH_FORTIFY_SOURCE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
- endif (WITH_FORTIFY_SOURCE)
+ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
+ if (NOT CMAKE_BUILD_TYPE_LOWER MATCHES debug)
+ check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
+ if (WITH_FORTIFY_SOURCE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
+ endif (WITH_FORTIFY_SOURCE)
+ endif()
endif (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
#