Hi, How can I enable color output when using the Ninja generator? I have set CMAKE_COLOR_DIAGNOSTICS to ON and also tried adding the -fdiagnostics-color=always compiler option, but still, no color is displayed. Another cause is that if Ninja itself doesn't see a terminal, such as when you pipe it into Less, it removes color codes from its buffered subprocess output. The way Ninja supports disabling this is with an environment variable.
Make colors the output fine by default, nice. My default configuration with Make/Clang colors my output just fine. But if I simply change my generator to Ninja, the pretty coloring is.
From the FAQ: Ninja itself will detect if it's writing to a terminal and escape color codes from commands if it isn't. I'd like to have the ability to do the following: ninja less -r Perhaps with a flag like: ninja. Assuming you're using the "CMake Tools" VSCode extension, here's what works for me.
1 - Set CMAKE_COLOR_DIAGNOSTICS to ON in your environment This makes CMake pass -fcolor-diagnostics to clang. If you build on the command line, you'll now have color. But the VSCode "output" pane will still be non-colored.
2 - Install the "Output Colorizer" []. Otherwise, CMAKE_COLOR_DIAGNOSTICS is not defined by default. See the CLICOLOR and CLICOLOR_FORCE environment variables to control color output from CMake command.
With current ninja colored output exists only in the "smart" way. ninja deactivates the colors, when piped into something: $ ninja # colored output $ ninja cat # not colored output A lot of programs (like ls and grep) have a command li. Linux users are recommended to run cmake -G Ninja.
when generating the build files for Panda through CMake. When using Ninja, no color output is shown on the terminal making it hard to read / debug compiler messages. Is there a way to enable color compiler messages with the ninja generator? With make and clang, for example, the makefile generator is able to produce color output.
On POSIX, terminal color can be modified through ANSI escape codes, and if you put ANSI escape codes in your command's description, ninja will write it through to the terminal unmodified. That way, you can have colored descriptions. This build.ninja produces colored output: $ less build.ninja.