From e430b7b64f87d171e3975de8b4cb7bc7038cb4b4 Mon Sep 17 00:00:00 2001 From: Arvin Farahmand Date: Thu, 15 Apr 2021 11:20:10 -0400 Subject: [PATCH] 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 always enabled for clang and gcc. Setting `CONFIG_COMPILER_COLOR_DIAGNOSTICS=n` disables this feature and reverts to plain diagnostic messages with no formatting. Signed-off-by: Arvin Farahmand --- CMakeLists.txt | 2 +- Kconfig.zephyr | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6022d234f2e..2114ee7d90f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,7 +211,7 @@ zephyr_compile_options($) # @Intent: Set compiler specific flag for production of debug information zephyr_compile_options($) -if($ENV{ZEPHYR_BUILD_COLOUR_DIAGNOSTIC}) +if(CONFIG_COMPILER_COLOR_DIAGNOSTICS) # @Intent: Set compiler specific flag for diagnostic messages zephyr_compile_options($) endif() diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 09840d9b0b2..9571d374a32 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -235,6 +235,12 @@ config NO_OPTIMIZATIONS endchoice +config COMPILER_COLOR_DIAGNOSTICS + bool "Enable colored diganostics" + default y + help + Compiler diagnostic messages are colorized. + config COMPILER_OPT string "Custom compiler options" help