bash 如何将 CMake 输出保存到文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29275078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to save CMake output to file?
提问by NRKirby
I can usually save the output of bash commands by >> output_file.txt
我通常可以通过以下方式保存 bash 命令的输出 >> output_file.txt
But when I execute cmake
the output is still sent to the screen rather than output file as expected:
但是当我执行时cmake
,输出仍然按预期发送到屏幕而不是输出文件:
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
回答by Cyrus
That is because part (possibly all, depending on the situation) of your cmake output is streamed to stderr.
那是因为您的 cmake 输出的一部分(可能全部,取决于情况)被流式传输到 stderr。
Use this to redirect stderr to stdout:
使用它来将 stderr 重定向到 stdout:
cmake ... >> output_file.txt 2>&1
or append only stderr to output_file.txt:
或仅将 stderr 附加到 output_file.txt:
cmake ... 2>> output_file.txt