[CMake] Post-process compiler output

Michael Wild themiwi at gmail.com
Tue Jun 14 05:46:34 EDT 2011


On 06/14/2011 11:36 AM, Sebastian Schaetz wrote:
> Hi,
> 
> I'm using CMake to generate makefiles to build my C++ projects with g++. When
> developing code I find it useful to "post-process" g++ output. In particular I
> like to feed the output through gSTLFilt.pl [0] and a custom version of colorgcc
> [1].
> 
> Currently I have a wrapper around make (I call xmake.sh) that pipes the entire
> output of make through those two tools [2]. But this is not optimal since I lose
> the colorful output CMake puts into the makefiles.
> 
> So my question is: is there a way to append stuff to the g++ command line such
> as "2>&1 | perl colorize.pl 2>&1 | perl gSTLFilt.pl"?
> 
> Thanks in advance,
> Sebastian
> 
> [0] http://www.bdsoft.com/tools/stlfilt.html
> [1] http://schlueters.de/colorgcc.html
> [2] https://github.com/sschaetz/colorgcc/tree/filter

I don't think that this is possible directly. But you can write a
wrapper shell script which does the above and then pass that script as
the compiler to cmake. Something like this:

#!/bin/sh
/usr/bin/g++ $@ 2>&1 | perl colorize.pl 2>&1 | perl gSTLFilt.pl

HTH

Michael


More information about the CMake mailing list