Search code examples
cmakelintcpplint

CMake CPPLINT coloured output


Is there any way to colour the cpplint output when setting

set(CMAKE_CXX_CPPLINT "cpplint")

in the cmake file?


Solution

  • If you want to color any output, you have to communicate that intention to the thing that displays it. For displaying the output of commands, typically a terminal is used, nowadays in the form of terminal emulator.

    If your terminal supports ANSI color escape sequences, you could just mock cpplint process and output a color code before and after it is run. On a *unix environment you could create an executable file named mycpplint with the content along:

    #!/bin/sh
    printf '\E[36m' ; cpplint "$@" ; printf '\E[0m'
    

    and then add that executable file location to PATH and do set(CMAKE_CXX_CPPLINT "mycpplint").