我该如何调试CMakeLists.txt
文件(至少做诸如列出变量之类的事情),而不仅仅是使用the message() command https://cmake.org/cmake/help/latest/command/message.html?
在最初撰写此答案时,CMake 没有交互式调试器,但可以使用标志-Wdev
, --debug-output
and --trace
获取更多信息并检查日志文件CMakeFiles\CMakeOutput.log
and CMakeFiles\CMakeError.log
主要收集 CMake 调用的进程的输出(例如,在检查类型或标头是否存在时)。
从3.7版本开始 https://blog.kitware.com/cmake-e-server-improves-visual-studio-and-qt-creator-ides/,CMake 现在正式支持“服务器模式”,因此 IDE 中的集成可能会在不久的将来得到改进。初步支持存在于Qt创建者 https://blog.qt.io/blog/2016/11/15/cmake-support-in-qt-creator-and-elsewhere/ and Visual Studio 2017 RC https://blogs.msdn.microsoft.com/vcblog/2016/11/16/cmake-support-in-visual-studio-the-visual-studio-2017-rc-update/
从3.27版本开始 https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-debugger,CMake还支持调试适配器协议 https://microsoft.github.io/debug-adapter-protocol/以及一些 IDE 供应商(例如CLion https://blog.jetbrains.com/clion/2022/10/clion-2022-3-eap-cmake-debugger/ or 视觉工作室 https://devblogs.microsoft.com/cppblog/cmake-debugger-allows-you-to-debug-your-cmake-scripts-and-more/)现在支持或已经宣布支持 CMake 调试。具体如何工作取决于具体的 IDE。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)