Is there a way to have colorized output in cmake
for messages, (e.g. like here is written) , but only when output is not redirected to a file (and using only cmake's possibilities)? Because using that method, messages in the file are colorized too (escape sequences printed).
I'd like to be able to force and compiler flags like -fdiagnostics-color
for gcc or -fcolor-diagnostics
for clang. On some platforms compiler doesn't colorize output without these flags. I think it's impossible to do this correctly. The flags are cached and every time, when make
is started, it uses the same value as was configured when cmake
was started for first time. I don't know how to change flags in dependence if output is redirected to screen or to file, but if it is possible, I'd like to know.