diff options
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ecf10816..d2b5217658 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 2.8.7) -project (NEOVIM) +cmake_minimum_required(VERSION 2.8.7) +project(NEOVIM) # Point CMake at any custom modules we may ship list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -67,11 +67,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Default to -O2 on release builds. string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +# Enable -Wconversion. +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion") + # 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" - AND CMAKE_BUILD_TYPE MATCHES "^Rel") +include(CheckCSourceCompiles) +check_c_source_compiles(" +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 1 +#error \"_FORTIFY_SOURCE > 1\" +#endif +int +main(void) +{ + return 0; +} +" _FORTIFY_SOURCE_ACCEPTABLE) + +if(NOT _FORTIFY_SOURCE_ACCEPTABLE) # -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") |