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

Brad King brad.king at kitware.com
Fri May 17 11:43:04 EDT 2013


On 05/04/2013 08:12 AM, Leif Walsh wrote:
> I think the colors and carriage returns (without line feeds) are lost
> because the build tool sees its controlling terminal is cmake, not a
> real terminal program capable of showing color or redrawing, so it
> doesn't output them. Cmake may be logging this stuff too (to send to
> cdash for example) so this is kind of a responsible choice. 

This is correct, but it doesn't have to be so.  In the case of a
direct "cmake --build ..." invocation from a terminal CMake is not
doing any special logging so it should be able to share its host
terminal such that isatty() returns true for the underlying tools.

The "cmake --build ..." implementation ultimately runs through the
cmSystemTools::RunSingleCommand code path:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmSystemTools.cxx;hb=v2.8.11#l615

in order to invoke the native build command.  One could add an
option to that code path to share the output pipes with the cmake
process just like "ctest --launch" does in pass-thru mode:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/CTest/cmCTestLaunch.cxx;hb=v2.8.11#l221
 cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
 cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);

One could then activate that from the "cmake --build" call site
by passing the option through all the intermediate levels of the
call stack (cmake::Build and cmGlobalGenerator::Build IIRC).

-Brad


More information about the CMake mailing list