Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save CMake output to file?

I can usually save the output of bash commands by >> output_file.txt

But when I execute cmake the output is still sent to the screen rather than output file as expected:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D \
BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D \
INSTALL_PYTHON_EXAMPLES=ON  -D BUILD_EXAMPLES=ON .. >> output_file.txt
like image 365
NRKirby Avatar asked Mar 26 '15 09:03

NRKirby


1 Answers

That is because part (possibly all, depending on the situation) of your cmake output is streamed to stderr.

Use this to redirect stderr to stdout:

cmake ... >> output_file.txt 2>&1

or append only stderr to output_file.txt:

cmake ... 2>> output_file.txt
like image 61
Cyrus Avatar answered Nov 03 '22 05:11

Cyrus