cmake: gcc/clang: enable colour diagnostics in terminal output
When compiler results are piped through a non-terminal (e.g. ninja) the compiler disables colour diagnostics. Using `-fdiagnostics-color` forces the compiler to enable colour output. This flag is set for clang and gcc when `ZEPHYR_BUILD_COLOUR_DIAGNOSTIC` environment variable is set when a clean build is started. Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
This commit is contained in:
parent
d8bbd2ad5c
commit
b8f5968a42
3 changed files with 11 additions and 0 deletions
|
@ -211,6 +211,11 @@ zephyr_compile_options($<TARGET_PROPERTY:compiler,no_common>)
|
||||||
# @Intent: Set compiler specific flag for production of debug information
|
# @Intent: Set compiler specific flag for production of debug information
|
||||||
zephyr_compile_options($<TARGET_PROPERTY:compiler,debug>)
|
zephyr_compile_options($<TARGET_PROPERTY:compiler,debug>)
|
||||||
|
|
||||||
|
if($ENV{ZEPHYR_BUILD_COLOUR_DIAGNOSTIC})
|
||||||
|
# @Intent: Set compiler specific flag for diagnostic messages
|
||||||
|
zephyr_compile_options($<TARGET_PROPERTY:compiler,diagnostic>)
|
||||||
|
endif()
|
||||||
|
|
||||||
zephyr_compile_options(
|
zephyr_compile_options(
|
||||||
${TOOLCHAIN_C_FLAGS}
|
${TOOLCHAIN_C_FLAGS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,6 +13,9 @@ check_set_compiler_property(PROPERTY hosted)
|
||||||
# clang flags for coverage generation
|
# clang flags for coverage generation
|
||||||
set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline)
|
set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline)
|
||||||
|
|
||||||
|
# clang flag for colourful diagnostic messages
|
||||||
|
set_compiler_property(PROPERTY diagnostic -fcolor-diagnostics)
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# This section covers flags related to warning levels #
|
# This section covers flags related to warning levels #
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
|
@ -179,3 +179,6 @@ set_compiler_property(PROPERTY sanitize_undefined -fsanitize=undefined)
|
||||||
|
|
||||||
# Required ASM flags when using gcc
|
# Required ASM flags when using gcc
|
||||||
set_property(TARGET asm PROPERTY required "-xassembler-with-cpp")
|
set_property(TARGET asm PROPERTY required "-xassembler-with-cpp")
|
||||||
|
|
||||||
|
# gcc flag for colourful diagnostic messages
|
||||||
|
set_compiler_property(PROPERTY diagnostic -fdiagnostics-color=always)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue