[CMake] "cmake --build ." and colors

Andreas Mohr andi at lisas.de
Sat May 4 06:02:42 EDT 2013


Hi,

On Fri, May 03, 2013 at 04:19:40PM -0400, cmake-request at cmake.org wrote:
> Date: Fri, 3 May 2013 17:46:06 +0000
> From: Gregoire Aujay <gaujay at movea.com>

> Hello,
> 
> I also found that using cmake --build . with ninja outputs all lines but if I directly use ninja to build it only outputs one line which is very cool (it clears current line before printing the new one if there is no warning/error).

Possibly that's both (colors, line clearing) related to ANSI color escape codes
as used by the native build tool.
It's perhaps possible to analyze where exactly the augmented output gets
lost within the chain (doing analysis on source code side, of course).
Probably some CMake handling or adopting of tool output filters out that markup.


> I am wondering if there is any trick to enable colors when running this command:
> cmake --build .
> 
> The only way I manage to get the colors is to directly use the make program, e.g.:
> mingw32-make all
> 
> 
> The issue is that I am trying to use a script that runs cmake to build instead of the make program that may change (ninja, mingw-make, make, msvc, etc).

Yes, very much so. Dito for ninja and make here (and as launched by
some cross-platform [ruby/python/perl] script).
Somehow I failed to actively pick up that I could go through cmake --build .
rather than grabbing ${CMAKE_BUILD_TOOL} (formerly ${CMAKE_MAKE_PROGRAM}) directly.

Also, one might want to pass e.g. parallelization (make -jX) configuration through it
as well, so it might be useful to devise a standard parameterization
mechanism for --build to support *any* such attributes, in a generalized form.

Andreas Mohr


More information about the CMake mailing list