griffin2000
griffin2000

Reputation: 779

How do you make CMake print *all* commands not just build commands?

So you can use the VERBOSE option to get CMake to print all the compiler command lines to the console as it builds, but that doesn't seem to have any effect on other commands that aren't compiler commands, e.g. this execute_process command:

  execute_process(
    COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests
    WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
    TIMEOUT ${_TEST_DISCOVERY_TIMEOUT}
    OUTPUT_VARIABLE output
    RESULT_VARIABLE result
  )

It's actually part of the google test module in CMake. I had an issue where I needed to track the exact command line that was being executed. I was able to but only by manually hacking the files. If I had just been able to spew all the commands CMake was executing it would have been much much quicker.

Is there some way to do that in CMake?

Upvotes: 2

Views: 1715

Answers (1)

Kevin
Kevin

Reputation: 18243

To get the commands in execute_process printed, you can set where you want them printed individually, in each execute_process command using COMMAND_ECHO:

execute_process(
    COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests
    WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
    TIMEOUT ${_TEST_DISCOVERY_TIMEOUT}
    OUTPUT_VARIABLE output
    RESULT_VARIABLE result
    COMMAND_ECHO STDOUT
  )

or universally for all execute_process commands throughout your CMake project by setting this variable in your top-level CMake file:

set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)

These features are available in CMake versions 3.15 and above.


For what it's worth, you can also get the full printout of every command CMake runs (with expanded CMake variables) using the cmake command line option:

cmake --trace-expand ..

but this may be much more verbosity than you're looking for.

Upvotes: 3

Related Questions