# How to enable color output with Ninja

**URL:** https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544
**Category:** Usage
**Tags:** os:linux, comp:gcc, gen:ninja
**Created:** [July 19, 2023, 9:13am UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544 "2023-07-19T09:13:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![murtiko](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@murtiko](https://discourse.cmake.org/u/murtiko)
#### Post date: [July 19, 2023, 9:13am UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544/1 "2023-07-19T09:13:01Z")

</div>

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.

The color output works fine when I use the make generator. Is there a way to get colored output when using the Ninja generator?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 19, 2023, 10:15am UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544/2 "2023-07-19T10:15:14Z")

</div>

Ninja buffers output, so tools are writing to a pipe, not directly to the terminal, so auto-detection may turn it off conservatively. Does `make -Otarget` still work (this does similar buffering)?

---

<div class="post-metadata">

### Author: ![murtiko](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@murtiko](https://discourse.cmake.org/u/murtiko)
#### Post date: [July 19, 2023, 11:09am UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544/3 "2023-07-19T11:09:44Z")

</div>

Yes, `make -Otarget` displays colored output when the project configured with Make.

So is it expected to get color with Ninja then?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 19, 2023, 11:33pm UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544/4 "2023-07-19T23:33:25Z")

</div>

I’m not sure…I’ve never used color diagnostics myself (NeoVim tends to re-color build output anyways AFAICT).
