diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8272a1a469..988c69cd2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,14 +97,22 @@ else() option(ENABLE_LTO "enable link time optimization" ON) endif() -# Set default build type. +message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") + +# Build type. if(NOT CMAKE_BUILD_TYPE) - message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'") + message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE) +else() + message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") +endif() +if(CMAKE_BUILD_TYPE MATCHES Debug) + set(DEBUG 1) +else() + set(DEBUG 0) endif() - # Set available build types for CMake GUIs. -# A different build type can still be set by -DCMAKE_BUILD_TYPE=... +# Other build types can still be set by -DCMAKE_BUILD_TYPE=... set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") @@ -138,12 +146,6 @@ set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Default to -O2 on release builds. -if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3") - message(STATUS "Replacing -O3 in CMAKE_C_FLAGS_RELEASE with -O2") - string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") -endif() - # Minimize logging for release-type builds. if(NOT CMAKE_C_FLAGS_RELEASE MATCHES DMIN_LOG_LEVEL) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DMIN_LOG_LEVEL=3") @@ -155,6 +157,22 @@ if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DMIN_LOG_LEVEL) set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DMIN_LOG_LEVEL=3") endif() +# Log level (MIN_LOG_LEVEL in log.h) +if("${MIN_LOG_LEVEL}" MATCHES "^$") + message(STATUS "MIN_LOG_LEVEL not specified, default is 0 (DEBUG)") +else() + if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$") + message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL}) + endif() + message(STATUS "MIN_LOG_LEVEL=${MIN_LOG_LEVEL}") +endif() + +# Default to -O2 on release builds. +if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3") + message(STATUS "Replacing -O3 in CMAKE_C_FLAGS_RELEASE with -O2") + string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +endif() + if(CMAKE_COMPILER_IS_GNUCC) check_c_compiler_flag(-Og HAS_OG_FLAG) else() @@ -172,11 +190,6 @@ if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") endif() -# Enable -Wconversion. -if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow -Wconversion") -endif() - # gcc 4.0+ sets _FORTIFY_SOURCE=2 automatically. This currently # does not work with Neovim due to some uses of dynamically-sized structures. # https://github.com/neovim/neovim/issues/223 @@ -264,7 +277,8 @@ if(MSVC) add_definitions(-DWIN32) else() add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter - -Wstrict-prototypes -std=gnu99) + -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion + -Wmissing-prototypes) check_c_compiler_flag(-Wimplicit-fallthrough HAS_WIMPLICIT_FALLTHROUGH_FLAG) if(HAS_WIMPLICIT_FALLTHROUGH_FLAG) @@ -333,12 +347,6 @@ if(TRAVIS_CI_BUILD) endif() endif() -if(CMAKE_BUILD_TYPE MATCHES Debug) - set(DEBUG 1) -else() - set(DEBUG 0) -endif() - option(LOG_LIST_ACTIONS "Add list actions logging" OFF) add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) @@ -456,22 +464,6 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA message(FATAL_ERROR "Sanitizers are only supported for Clang") endif() -if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD|FreeBSD|Windows") # see #5318 - message(STATUS "skipping jemalloc on this system: ${CMAKE_SYSTEM_NAME}") - option(ENABLE_JEMALLOC "enable jemalloc" OFF) -else() - option(ENABLE_JEMALLOC "enable jemalloc" ON) -endif() - -if(ENABLE_JEMALLOC) - if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) - message(STATUS "Sanitizers enabled; disabling jemalloc") - else() - find_package(JeMalloc REQUIRED) - include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS}) - endif() -endif() - if(ENABLE_LIBINTL) # LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464 find_package(LibIntl REQUIRED) @@ -545,17 +537,9 @@ install_helper( FILES ${MANPAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) -# MIN_LOG_LEVEL for log.h -if("${MIN_LOG_LEVEL}" MATCHES "^$") - message(STATUS "MIN_LOG_LEVEL not specified") -else() - if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$") - message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL}) - endif() - message(STATUS "MIN_LOG_LEVEL set to ${MIN_LOG_LEVEL}") -endif() - +# # Go down the tree. +# add_subdirectory(src/nvim) # Read compilation flags from src/nvim, used in config subdirectory below. |