设置诊断:来自 CMakeLists.txt 的插入符号
本文介绍了设置诊断:来自 CMakeLists.txt 的插入符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 Visual Studio 2017 中新的(更好的)诊断信息.
I would like to use the new (and better) diagnostic information from visual studio 2017.
要同时为我的所有项目启用它,我想从我的 CMakeLists.txt 中声明这个标志
To have it enabled to all my project at once I want to declare this flag from my CMakeLists.txt
我试过了
但是编译时会报错说/diagnostics:classic(这是默认值)与/diagnostics:caret 不兼容
But when compiling there is an error saying that /diagnostics:classic (which is the default value) is not compatible with /diagnostics:caret
有没有办法使用 cmake 覆盖默认值?
Is there a way to override the default value using cmake ?
推荐答案
你只需要知道 CMake 尚未正式支持的 VS 编译器选项最终会在:
You just have to know that VS compiler options that CMake does not yet officially support will end up under:
属性/C/C++/命令行/附加选项
这就是你得到的原因
cl : Command line error D8016: '/diagnostics:classic' and '/diagnostics:caret'
command-line options are incompatible
但是您可以使用新的 cl
选项">VS_USER_PROPS
目标属性(版本 >= 3.8).
But you can give cl
options globally with the new VS_USER_PROPS
target property (version >= 3.8).
这是一个工作示例:
CMakeLists.txt
参考
- 使用 CMake 添加 Visual C++ 属性表
这篇关于设置诊断:来自 CMakeLists.txt 的插入符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!