How to use CMAKE_EXPORT_COMPILE_COMMANDS?(如何使用 CMAKE_EXPORT_COMPILE_COMMANDS?)
问题描述
我一直在尝试将 clang-modernize 与 CMAKE_EXPORT_COMPILE_COMMANDS 结合使用,如在此工具的帮助中推荐的那样.
I've been trying to use clang-modernize with CMAKE_EXPORT_COMPILE_COMMANDS as recommended in the help of this tool.
使用此选项,cmake 会生成一个包含编译信息的 JSON 文件,例如包含路径(另见).
With this option cmake generates a JSON file containing compile info like include paths (see also).
这个变量在cmake的命令行中被接受,但是 cmake --help-variable CMAKE_EXPORT_COMPILE_COMMANDS 不起作用(这与 此邮件列表发布).
This variable is accepted on the command line of cmake,
but cmake --help-variable CMAKE_EXPORT_COMPILE_COMMANDS doesn't work (which is coherent with this mailing list posting).
有人知道如何使用它吗?
Has someone any idea on how to use it?
我也可以将它与 cppcheck 一起使用.
I could also use it with cppcheck.
更多信息
我在 clang 开发者论坛 指出此 cmake 功能并非在所有生成器上都可用.这在未来可能会改变,同时我的问题仍然存在,我也会尝试看看如果我使用 Visual Studio 以外的其他生成器会发生什么.
I've discovered on a clang developer forum that this cmake feature is not available on all generators. This might change in the future, in the mean time my question remains and I will try too see what happen if I use other generators than Visual Studio.
推荐答案
我建议设置
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
在 CMakeList.txt 中
in the CMakeList.txt
这篇关于如何使用 CMAKE_EXPORT_COMPILE_COMMANDS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 CMAKE_EXPORT_COMPILE_COMMANDS?
基础教程推荐
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 提升 ASIO 流缓冲 2021-01-01
