From 64ea00299d9728ec496ed0649698fa33e44a37b2 Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Tue, 4 Nov 2014 17:06:18 -0500 Subject: build: turn down the _FORTIFY_SOURCE level on gcc >= 4.0 --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- cgit