Skip to content

Commit

Permalink
cmake: Pass -DMIN_LOG_LEVEL as compiler definition
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
equalsraf committed Jan 10, 2016
1 parent 50db031 commit 72d03cc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions contrib/local.mk.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/nvim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 72d03cc

Please sign in to comment.