CMake can I filter compiler output through another program -
can tell cmake pipe stderr output compiler and/or linker through external program , showing output of on terminal instead?
for makefile generators can apply filter compiler output setting custom launcher compile rules. following cmake list file sketches necessary steps:
cmake_minimum_required(version 2.8) project (main) configure_file( "${project_source_dir}/gcc_filter.sh.in" "${project_binary_dir}/gcc_filter.sh" @only) add_executable (main main.cpp) set_property(global property rule_launch_compile "${project_binary_dir}/gcc_filter.sh")
in project root directory add following shell script template file gcc_filter.sh.in
:
#!/bin/sh # shell script invoked following arguments # $(cxx) $(cxx_defines) $(cxx_flags) -o object_file -c source_file # invoke compiler exec "$@" 2>&1 | "@project_source_dir@/myfilter.sh"
the actual shell script invoked custom launcher rule first copied project binary directory configure_file
call in cmake list file. executable bit of file gcc_filter.sh.in
must set. shell script forwards arguments compiler , pipes compiler output shell script myfilter.sh
in project root directory:
#!/bin/sh exec wc
the example myfilter.sh
invokes wc
more elaborate output filtering can done using above recipe.
Comments
Post a Comment