Making CMake print commands before executing

An option, which applies to GNU make and works with any Makefile, whether generated by CMake or not, is to use the --trace option to make. This will print out the commands make is executing and still execute them.

This applies to all commands, not just those that VERBOSE=1 or V=1 triggers the printing of in CMake/automake generated makefiles.

And yet another alternative on Linux is to run make under strace, as strace -f -e trace=execve make <make options>. The output from strace will include every process that is executed: by make, by a shell script that make ran, etc.

For instance, you might find that the CMake-generated makefile executes /usr/bin/cmake -E __run_co_compile <lots of options ...> and still wonder what the exact compiler invocation(s) are that this in turn will run. You can get that with the strace method.


I am fairly sure this will work:

make VERBOSE=1

You should also be able to add this to your CMakeLists.txt to permanently set that:

set(CMAKE_VERBOSE_MAKEFILE on)

This is covered in the CMake FAQ.


For automake-generated Makefiles, try:

make V=1