Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake coloring errors and warnings

Tags:

c++

shell

cmake

Is there a way how to produce a colorful output from gcc which is called from Makefile generated by cmake? It would make debugging application a lot easier.

like image 983
Tombart Avatar asked Apr 01 '12 10:04

Tombart


3 Answers

Do you want colourful output from cmake binary? For that I don't know any solution.

CMake can generate Makefiles that provide verbose (and colourful) information about the build process. This can be enabled in the following way:

SET(CMAKE_COLOR_MAKEFILE ON)
# And optionally
SET(CMAKE_VERBOSE_MAKEFILE ON)

If you want to have the gcc output colourised, then have a look at colorgcc perl script. Having it installed try something like this:

CC=/usr/bin/colorgcc cmake .....

Or use the newer solution proposed in another answer by gfour - the gccfilter

like image 135
Anonymous Avatar answered Oct 16 '22 12:10

Anonymous


Download gccfilter (needs perl, libregexp and libgetopt-argvfile), then run:

gccfilter -c cmake ...

This will colorize the messages from the build process (which I assume are gcc mesages).

like image 3
gfour Avatar answered Oct 16 '22 11:10

gfour


Try colout, it is designed to seamlessly color the output of any command, and comes with a g++ AND a cmake theme, which you can use together:

make something 2>&1 | colout -t cmake | colout -t g++

Besides improving the cmake colorscheme, it even applies syntax coloring on the code printed out by g++.

like image 3
nojhan Avatar answered Oct 16 '22 12:10

nojhan