Different colour for warning versus error in build window with CMake

Answered

It is very difficult to quickly differentiate between build errors and warnings or notes in the build window.

There are 2 warnings, 3 notes and one error in the image above but finding he error is not easy, especially if this output is many pages long.

You can change the colour in Settings->Editor->Color Scheme->Console Colors->Console->Error output
How can you set a different colour for note, warning and error?

1
4 comments

Hello!

The colors are controlled by CMake (https://cmake.org/cmake/help/latest/variable/CMAKE_COLOR_MAKEFILE.html).

We have https://youtrack.jetbrains.com/issue/CPP-8540 which sounds related to your request. Feel free to comment or upvote the issue. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

0

Thanks for the response.

After a lot more digging I have found that the colours are actually controlled by the compiler and you can influence that by providing config to the compiler.

See https://apimirror.com/gcc~7/diagnostic-message-formatting-options

So in my case adding

add_compile_options(-fdiagnostics-color=always)

to CMakeList.txt solved my problem.
Hope it helps someone else.

0

Thanks a lot for sharing the solution!

0

Please sign in to leave a comment.