gcc.cmake: Add option for coloured gcc output
Setting the environment variable GCC_COLORS or CMake option FORCE_COLORED_OUTPUT will cause GCC's colour messages to be outputted.
This commit is contained in:
parent
60ffdb1f0a
commit
4d21d40b1e
1 changed files with 17 additions and 0 deletions
17
gcc.cmake
17
gcc.cmake
|
|
@ -85,3 +85,20 @@ if(NOT ("${CCACHE}" STREQUAL CCACHE-NOTFOUND))
|
|||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
|
||||
endif()
|
||||
mark_as_advanced(CCACHE)
|
||||
|
||||
# GCC color options:
|
||||
# Ninja and ccache cause gcc to not emit colored output when -fdiagnostics-color=auto.
|
||||
# We upgrade this to -fdiagnostics-color=always if FORCE_COLORED_OUTPUT is set
|
||||
# We default FORCE_COLORED_OUTPUT=ON if GCC_COLORS is set in the environment
|
||||
# otherwise FORCE_COLORED_OUTPUT is left off.
|
||||
if ($ENV{GCC_COLORS})
|
||||
set(coloured_output ON)
|
||||
else()
|
||||
set(coloured_output OFF)
|
||||
endif()
|
||||
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output." ${coloured_output})
|
||||
mark_as_advanced(FORCE_COLORED_OUTPUT)
|
||||
if (${FORCE_COLORED_OUTPUT})
|
||||
include_guard(GLOBAL)
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
endif ()
|
||||
|
|
|
|||
Loading…
Reference in a new issue