I would like to directly see the output of a command started by the EXECUTE_PROCESS
command on stdout while the program is running.
I have the following test CMakeLists.txt file
PROJECT(TEST)
cmake_minimum_required(VERSION 2.8)
EXECUTE_PROCESS(COMMAND dir)
When run from the commandline it produces this
D:\tmp\testCMake\_build>"c:\Program Files (x86)\CMake 2.8\bin\cmake.exe" .
-- Configuring done
-- Generating done
-- Build files have been written to: D:/tmp/testCMake/_build
I would like to see the output from dir
directly on the console.
I know I can capture the output using the OUTPUT_VARIABLE
and ERROR_VARIABLE
arguments. But, that provides the result at the end of the command run.
According to the documentation the output should normally be passed through
If no OUTPUT_* or ERROR_* options are given the output will be shared with the corresponding pipes of the CMake process itself.
I am using CMake 2.8.3 on Windows Vista
Try:
execute_process(COMMAND cmd /c dir)
instead. 'dir' is a built-in shell command. 'execute_process' expects a *.exe file name as it's first argument after COMMAND. (Or some exe available in the PATH.)
In fact, if you try to dig in and find out what's wrong with your original execute_process call...
execute_process(COMMAND dir RESULT_VARIABLE rv)
message("rv='${rv}'")
...you'll get this output:
rv='The system cannot find the file specified'
Which is pretty much what you'd get if you passed "dir" to the WIN32 CreateProcess call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With