mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 12:45:17 -07:00
build/CMakeLists.txt: group related logic
- Group CMAKE_BUILD_TYPE-related logic together. - Print the MIN_LOG_LEVEL message (in the build-log) next to the CMAKE_BUILD_TYPE message.
This commit is contained in:
parent
4031e93c45
commit
4397bf5785
@ -97,14 +97,22 @@ else()
|
||||
option(ENABLE_LTO "enable link time optimization" ON)
|
||||
endif()
|
||||
|
||||
# Set default build type.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'")
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
|
||||
endif()
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Build type.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
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()
|
||||
@ -329,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)
|
||||
@ -525,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.
|
||||
|
Loading…
Reference in New Issue
Block a user