cmakebuildgnu-makeverboseverbosity

How can I get make to be verbose but with only "meaningful" lines when building with cmake?


I'm using CMake with the GNU Make generator on a project of mine, and then want to build it - verbosely.

I'm interested in lines which actually produce things, and not interested in lines such as:

gmake[2]: Entering directory '/some/where'
gmake[2]: Leaving directory '/some/other/place'

nor the lines saying:

cd /some/where && /path/to/cmake/bin/cmake -E cmake_link_script CMakeFiles/some.dir/link.txt --verbose=1

as those are "wrapping" the actual work that will happen when cmake runs that script (e.g. calls a linker executable such as gcc).

I don't mind very much the percentage headers such as:

[ 97%] Building CXX object /path/to/proj/CMakeFiles/something.dir/foo.o

i.e. if your solution removes them, then fine, if it keeps them - also fine.

I've read answers and comments on this question: Using CMake with GNU Make: How can I see the exact commands?, and the best I've come up with so far is:

MAKEFLAGS="$MAKEFLAGS --no-print-dir" cmake --build build_dir/  --verbose 

The --verbose gives you maximum (?) verbosity, with everything you don't want. Then, the --no-print-dir is picked up by GNU Make, making it avoid the Entering/Leaving Directory messages.

Can I do better, and actually avoid the cd and the cmake -E commands?

Notes:


Solution

  • You can discover for yourself that there is no way to do what you want.

    Since cmake is just generating makefiles, and it's make that is actually running the recipes and printing the output, you need to look at the makefile and see how the rules are constructed. If you find a sample rule for a link line for example you will see it looks like this:

    myexecutable: ...
            @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/mydir/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable myexecutable"
            cd /mydir && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/myexecutable.dir/link.txt --verbose=$(VERBOSE)
    

    Note that there is no special variable, or token, or anything appearing in this recipe before the cd /mydir ... text.

    So, there is absolutely no way to control how this particular recipe is printed, separately from how all the other recipes are printed. You either get them all, or you get none of them.