How can I redirect the output of the CMake "execute_process" command to STDOUT in real-time?

Viewed 1234

I am working on a project that needs to execute a system process from a CMake script that may take a while to run. The problem is the entire time the process is running I get no feedback about whether it is succeeding or not. Since the process may take a few minutes to run it may appear as though it froze even though it is still silently working.

At the end of the process I can get the output in a CMake variable and print all of the things that happened during that time:

execute_process(COMMAND some system command
    OUTPUT_VARIABLE command_output
)

# ... nothing happens for a few minutes while the process executes

# All of the output from the past few minutes is printed all at once.
message(STATUS ${command_output})

It would be much nicer if I could just redirect the process output directly to STDOUT so I could see output of the process while it is executing... Is there any way to do this?

0 Answers
Related