diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aa5e467469..6022d234f2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,11 @@ zephyr_compile_options($) # @Intent: Set compiler specific flag for production of debug information zephyr_compile_options($) +if($ENV{ZEPHYR_BUILD_COLOUR_DIAGNOSTIC}) +# @Intent: Set compiler specific flag for diagnostic messages +zephyr_compile_options($) +endif() + zephyr_compile_options( ${TOOLCHAIN_C_FLAGS} ) diff --git a/cmake/compiler/clang/compiler_flags.cmake b/cmake/compiler/clang/compiler_flags.cmake index 1cae6fb29b5..0f481ff59ea 100644 --- a/cmake/compiler/clang/compiler_flags.cmake +++ b/cmake/compiler/clang/compiler_flags.cmake @@ -13,6 +13,9 @@ check_set_compiler_property(PROPERTY hosted) # clang flags for coverage generation 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 # ####################################################### diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index ee2bb027d6a..9eea90e6a9e 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -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)