From 7d66a02b888e4055c62e6f477bc36b6ce760336b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 2 Dec 2019 17:12:51 +0100 Subject: [PATCH] build: CMakeLists: do not set MIN_LOG_LEVEL with C flags (#11498) Fixes https://github.com/neovim/neovim/issues/11496. --- CMakeLists.txt | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d25cd89342..dbe2bf4d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,20 +134,18 @@ set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# 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") -endif() -if(NOT CMAKE_C_FLAGS_MINSIZEREL MATCHES DMIN_LOG_LEVEL) - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DMIN_LOG_LEVEL=3") -endif() -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 1 (INFO)") + # Minimize logging for release-type builds. + if(CMAKE_BUILD_TYPE STREQUAL "Release" + OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" + OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + message(STATUS "MIN_LOG_LEVEL not specified, default is 3 (ERROR) for release builds") + set(MIN_LOG_LEVEL 3) + else() + message(STATUS "MIN_LOG_LEVEL not specified, default is 1 (INFO)") + set(MIN_LOG_LEVEL 1) + endif() else() if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$") message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})