diff options
author | John Szakmeister <john@szakmeister.net> | 2014-12-18 04:14:14 -0500 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2014-12-18 04:14:14 -0500 |
commit | 379dcd7d7faf4c9b38042eca424d4ee72a768fa6 (patch) | |
tree | 6e256595663fc19b78d4bd18c902ccce8f13d7aa | |
parent | 9ebc960cb9f7c74c244e095a84aab7f397e4d4ae (diff) | |
parent | 0a5dad8a10da7988f2c21fa26bb61aa6ce53205d (diff) | |
download | rneovim-379dcd7d7faf4c9b38042eca424d4ee72a768fa6.tar.gz rneovim-379dcd7d7faf4c9b38042eca424d4ee72a768fa6.tar.bz2 rneovim-379dcd7d7faf4c9b38042eca424d4ee72a768fa6.zip |
Merge pull request #1686 from jszakmeister/include-opts-in-fortify-check
build: include the flags for the build type in the _FORTIFY_SOURCE check
-rw-r--r-- | CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f41f03241..ec49bee339 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,17 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion") # does not work with Neovim due to some uses of dynamically-sized structures. # See https://github.com/neovim/neovim/issues/223 for details. include(CheckCSourceCompiles) + +# Include the build type's default flags in the check for _FORTIFY_SOURCE, +# otherwise we may incorrectly identify the level as acceptable and find out +# later that it was not when optimizations were enabled. CFLAGS is applied +# even though you don't see it in CMAKE_REQUIRED_FLAGS. +set(INIT_FLAGS_NAME CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}) +string(TOUPPER ${INIT_FLAGS_NAME} INIT_FLAGS_NAME) +if(${INIT_FLAGS_NAME}) + set(CMAKE_REQUIRED_FLAGS "${${INIT_FLAGS_NAME}}") +endif() + check_c_source_compiles(" #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 1 #error \"_FORTIFY_SOURCE > 1\" |