aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2014-11-04 17:06:18 -0500
committerJohn Szakmeister <john@szakmeister.net>2014-11-05 03:53:31 -0500
commit64ea00299d9728ec496ed0649698fa33e44a37b2 (patch)
tree95d07ebf16377116fb0d58a6e313eee3f618fce5
parent04633e3e6bb0da1489050fee2c7514f9a1808327 (diff)
downloadrneovim-64ea00299d9728ec496ed0649698fa33e44a37b2.tar.gz
rneovim-64ea00299d9728ec496ed0649698fa33e44a37b2.tar.bz2
rneovim-64ea00299d9728ec496ed0649698fa33e44a37b2.zip
build: turn down the _FORTIFY_SOURCE level on gcc >= 4.0
-rw-r--r--CMakeLists.txt10
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c939507cc6..00095fae53 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,16 @@ if(APPLE)
endif()
endif()
+# gcc 4.0 and better turn on _FORTIFY_SOURCE=2 automatically. This currently
+# does not work with Neovim due to some uses of dynamically-sized structures.
+# See https://github.com/neovim/neovim/issues/223 for details.
+if(CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "4")
+ # -U in add_definitions doesn't end up in the correct spot, so we add it to
+ # the flags variable instead.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1")
+endif()
+
add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter
-Wstrict-prototypes -std=gnu99)