execute_process buffering

I am using execute_process to run a process that can take some time (specifically - docker build). I want to see the output from the process as it is generated since it lets me know where it is up to and how much longer it will take, but execute_process is buffering the output and only dumping it all once the process is finished. How can I get it to show the output as it is generated, without buffering?

Are you using OUTPUT_VARIABLE and/or ERROR_VARIABLE to capture the output? If so, try ECHO_OUTPUT_VARIABLE and ECHO_ERROR_VARIABLE instead (requires CMake 3.18 or later).

I am not using either of those. The only thing I am using is OUTPUT_STRIP_TRAILING_WHITESPACE

This little experiment shows that execute_process() doesn’t print till the process ends or stdout pipe is flushed.
If you run the Python script directly without CMake, the printing occurs “real time” even when not flushed thought that could be a bit platform-dependent.