MantisBT - CMake
View Issue Details
0015789CMake(No Category)public2015-10-14 11:072016-03-07 09:12
Jan Niklas Hasse 
Brad King 
normalfeaturealways
closedfixed 
 
CMake 3.5CMake 3.5 
0015789: Enable ANSI colors when CLICOLOR_FORCE is set to 1
Hi!

I have set up a build server which uses CMake and Makefiles on Windows using nmake. The build server pipes the output of both, so there's no colored output. But when I set the environment variable TERM to "xterm" nmake prints the messages like "Building xy" colored.

On my Linux build server this doesn't work however. I guess because the CMake generated Makefile checks if isatty returns true (which would mean the output isn't piped).

As there are situation where one wants to have colored output even if piped, it would be great, if CMake supported some kind of environment variable to force it on all platforms. As I was tired of all the different names, I've set up a page, which summarizes a possible standard name: http://bixense.com/clicolors/ [^]

What do you think about CMake to outputting ANSI colored text when CLICOLOR_FORCE is set to 1? Thanks :)
No tags attached.
patch 0001-KWSys-Force-colored-output-when-CLICOLOR_FORCE-is-se.patch (990) 2015-10-15 10:06
https://public.kitware.com/Bug/file/5543/0001-KWSys-Force-colored-output-when-CLICOLOR_FORCE-is-se.patch
Issue History
2015-10-14 11:07Jan Niklas HasseNew Issue
2015-10-14 11:23Brad KingNote Added: 0039600
2015-10-14 11:29Jan Niklas HasseNote Added: 0039601
2015-10-15 10:06Jan Niklas HasseFile Added: 0001-KWSys-Force-colored-output-when-CLICOLOR_FORCE-is-se.patch
2015-10-15 10:09Jan Niklas HasseNote Added: 0039616
2015-10-15 10:35Brad KingNote Added: 0039617
2015-10-15 10:35Brad KingNote Edited: 0039617bug_revision_view_page.php?bugnote_id=39617#r1932
2015-10-19 09:18Brad KingNote Added: 0039628
2015-10-19 09:18Brad KingAssigned To => Brad King
2015-10-19 09:18Brad KingStatusnew => resolved
2015-10-19 09:18Brad KingResolutionopen => fixed
2015-10-19 09:18Brad KingFixed in Version => CMake 3.5
2015-10-19 09:18Brad KingTarget Version => CMake 3.5
2015-10-19 10:28Jan Niklas HasseNote Added: 0039630
2016-03-07 09:12Robert MaynardNote Added: 0040622
2016-03-07 09:12Robert MaynardStatusresolved => closed

Notes
(0039600)
Brad King   
2015-10-14 11:23   
Yes, I think that makes sense. See the cmSystemTools::MakefileColorEcho method for an entry point into the code. Please read CONTRIBUTING.rst if you're interested in working on a patch.
(0039601)
Jan Niklas Hasse   
2015-10-14 11:29   
Great! Thanks for the pointer, I will work on a patch in the next days :)
(0039616)
Jan Niklas Hasse   
2015-10-15 10:09   
Patch is done, this was easier than I expected. Building and using a custom CMake worked like a charm! Kudos to you, contributing to CMake is fun :)
(0039617)
Brad King   
2015-10-15 10:35   
The patch modifies code in KWSys which has its own upstream separate from CMake. I've made the change over there:

 http://review.source.kitware.com/20280 [^]

based on your patch. I modified the logic a bit to conform to CLICOLOR_FORCE != 0 instead of CLICOLOR_FORCE == 1, as mentioned at http://bixense.com/clicolors/ [^] .

(0039628)
Brad King   
2015-10-19 09:18   
The change is now in KWSys upstream. I've integrated it into CMake here:

 KWSys 2015-10-16 (a7e5360f)
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c6a7203 [^]
(0039630)
Jan Niklas Hasse   
2015-10-19 10:28   
Thanks! :)
(0040622)
Robert Maynard   
2016-03-07 09:12   
Closing resolved issues that have not been updated in more than 4 months.