CMake does not redirect stderr with execute_process

I am trying to redirect stdout and stderr to the same file using CMake. I use the execute_process parameter in CMake with the ERROR_FILE and OUTPUT_FILE .

I successfully write the output, but there is no error there. What am I doing wrong?

CMakeLists.txt File

 add_test(NAME test${ID} COMMAND ${CMAKE_COMMAND} -DEXE=../examples/test${exampleID} -DID=${ID} -DARGS=${args} -P ${CMAKE_CURRENT_SOURCE_DIR}/Tester.cmake ) 

File Tester.cmake

 separate_arguments( ARGS ) # Run the test execute_process( COMMAND "${EXE}" ${ARGS} ERROR_FILE test${ID}.out OUTPUT_FILE test${ID}.out ) 
0
source share
1 answer

Setting the same file for OUTPUT_FILE and ERROR_FILE only recently been added in CMake 3.3. See release notes .

As work for earlier versions, use the OUTPUT_VARIABLE and ERROR_VARIABLE with the same variable, and then write the contents of this variable to a file, for example:

 execute_process( COMMAND "${EXE}" ${ARGS} ERROR_VARIABLE _testOut OUTPUT_VARIABLE _testOut ) file (WRITE "test${ID}.out" "${_testOut}") 
+1
source

Source: https://habr.com/ru/post/1241759/


All Articles