From 72d03cc961796266b7b29a1e3afce94e9770c91b Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Mon, 8 Dec 2014 20:00:54 +0000 Subject: [PATCH] cmake: Pass -DMIN_LOG_LEVEL as compiler definition - Check if MIN_LOG_LEVEL value is a number 0-3, default to INFO (1) or ignore it in Release mode - When TRAVIS_CI_BUILD is ON the default is DEBUG (0) - Add local.mk.example --- .travis.yml | 5 ++--- CMakeLists.txt | 10 ++++++++++ contrib/local.mk.example | 5 +++++ src/nvim/CMakeLists.txt | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5329dcaff1..10219690b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ env: - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:$HOME/.local/mingw32/bin:$PATH" # LLVM symbolizer path. - LLVM_SYMBOLIZER="$(which llvm-symbolizer-3.6)" - # Force verification of DLOG macros. - - CFLAGS="-DMIN_LOG_LEVEL=0" # Build directory for Neovim. - BUILD_DIR="$TRAVIS_BUILD_DIR/build" # Build directory for third-party dependencies. @@ -29,7 +27,8 @@ env: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX -DBUSTED_OUTPUT_TYPE=gtest - -DDEPS_PREFIX=$DEPS_BUILD_DIR/usr" + -DDEPS_PREFIX=$DEPS_BUILD_DIR/usr + -DMIN_LOG_LEVEL=0" - DEPS_CMAKE_FLAGS="-DDEPS_DOWNLOAD_DIR:PATH=$DEPS_DOWNLOAD_DIR" # Additional CMake flags for 32-bit builds. - CMAKE_FLAGS_32BIT="-DCMAKE_SYSTEM_LIBRARY_PATH=/lib32:/usr/lib32:/usr/local/lib32 diff --git a/CMakeLists.txt b/CMakeLists.txt index 321a919494..adf23c19b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,6 +381,16 @@ install_helper( FILES ${MANPAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +# MIN_LOG_LEVEL for log.h +if(DEFINED MIN_LOG_LEVEL) + if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$") + message(FATAL_ERROR "MIN_LOG_LEVEL must be a number DEBUG (0), INFO (1), WARNING (2) or ERROR (3)") + endif() + message(STATUS "Log level set to ${MIN_LOG_LEVEL}") +else() + message(STATUS "Log level not specified, defaulting to INFO(1)") +endif() + # Go down the tree. add_subdirectory(src/nvim) diff --git a/contrib/local.mk.example b/contrib/local.mk.example index 22aac4fda7..a0b2d034e1 100644 --- a/contrib/local.mk.example +++ b/contrib/local.mk.example @@ -31,6 +31,11 @@ # # CMAKE_BUILD_TYPE := Debug +# By default, nvim's log level is INFO (1) (unless CMAKE_BUILD_TYPE is +# "Release", in which case logging is disabled). +# The log level must be a number DEBUG (0), INFO (1), WARNING (2) or ERROR (3). +# CMAKE_EXTRA_FLAGS += -DMIN_LOG_LEVEL=1 + # By default, nvim uses bundled versions of its required third-party # dependencies. # Uncomment these entries to instead use system-wide installations of diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 1038895b86..ea5125e4e7 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -108,6 +108,10 @@ if(NOT MSVC) ${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion") endif() +if(DEFINED MIN_LOG_LEVEL) + add_definitions(-DMIN_LOG_LEVEL=${MIN_LOG_LEVEL}) +endif() + get_directory_property(gen_cdefs COMPILE_DEFINITIONS) foreach(gen_cdef ${gen_cdefs} DO_NOT_DEFINE_EMPTY_ATTRIBUTES) if(NOT "${gen_cdef}" MATCHES "INCLUDE_GENERATED_DECLARATIONS")