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:
Arvin Farahmand 2021-04-15 11:20:10 -04:00 committed by Carles Cufí
commit b8f5968a42
3 changed files with 11 additions and 0 deletions

View file

@ -179,3 +179,6 @@ set_compiler_property(PROPERTY sanitize_undefined -fsanitize=undefined)
# Required ASM flags when using gcc
set_property(TARGET asm PROPERTY required "-xassembler-with-cpp")
# gcc flag for colourful diagnostic messages
set_compiler_property(PROPERTY diagnostic -fdiagnostics-color=always)