Skip to content

Commit 70903c8

Browse files
authored
Force colored output for ninja build. (#5959)
1 parent d268a2a commit 70903c8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ option(R_LIB "Build shared library for R package" OFF)
3232
## Dev
3333
option(USE_DEBUG_OUTPUT "Dump internal training results like gradients and predictions to stdout.
3434
Should only be used for debugging." OFF)
35+
option(FORCE_COLORED_OUTPUT "Force colored output from compilers, useful when ninja is used instead of make." OFF)
3536
option(ENABLE_ALL_WARNINGS "Enable all compiler warnings. Only effective for GCC/Clang" OFF)
3637
option(GOOGLE_TEST "Build google tests" OFF)
3738
option(USE_DMLC_GTEST "Use google tests bundled with dmlc-core submodule" OFF)
@@ -107,6 +108,12 @@ if (USE_CUDA)
107108
message(STATUS "CUDA GEN_CODE: ${GEN_CODE}")
108109
endif (USE_CUDA)
109110

111+
if (FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND
112+
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
113+
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
114+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
115+
endif()
116+
110117
find_package(Threads REQUIRED)
111118

112119
if (USE_OPENMP)

0 commit comments

Comments
 (0)