Qt Creator 12-CMake更新

Qt Creator 12 - CMake Update

Qt Creator 12-CMake更新

October 11, 2023 by Cristian Adam | Comments

​十月112023作者:Cristian Adam |评论

Here are the new CMake features and fixes in Qt Creator 12:

以下是Qt Creator 12中的新CMake功能和修复程序:

CMake Debugger

CMake调试器

CMake starting with version 3.27 supports an interactive debugger.

​从3.27版本开始的CMake支持交互式调试器。

Qt Creator 12 has added support for the Debug Adapter Protocol, and one of the first supported cases is the CMake debugger.

​Qt Creator 12增加了对调试适配器协议的支持,首批支持的案例之一是CMake调试器。

CMake Profiler

CMake档案器

I’ve mentioned the CMake profiler a while ago at New features in CMake 3.18. Qt Creator 12 does the transparent integration with the Chrome Trace Format Visualizer.

​不久前,我在CMake3.18中的New features中提到了CMake探查器。Qt Creator 12与Chrome Trace Format Visualizer进行透明集成。

Hover Help

悬浮式帮助

Qt Creator has had F1 support for CMake functions for a while now (CMake.qch  needs to be installed with CMake though). 

Qt Creator对CMake功能的F1支持已经有一段时间了(不过CMake.qch需要与CMake一起安装)。

With Qt Creator 12 this functionality is more refined. F1 will work not only for commands, but also for variables, properties, policies, environment variables and CMake find and include modules.

使用Qt Creator 12,此功能更加完善。F1不仅适用于命令,还适用于变量、属性、策略、环境变量以及CMake查找和包含模块。

Additionally the reStructuredText rst help files are parsed and displayed as hover help tooltips. This works for all above cases, and also when doing code completion.

此外,reStructuredText rst帮助文件将被解析并显示为悬停帮助工具提示。这适用于上述所有情况,也适用于完成代码时。

导航

Qt Creator supported only one navigation (F2) case: namely source files in the project.

Qt Creator只支持一种导航(F2)情况:即项目中的源文件。

Qt Creator 12 extends this for:

Qt Creator 12将其扩展为:

  • functions / macros, and options
  • 函数/宏和选项
  • project targets
  • 项目目标
  • CMake’s own find and include modules
  • CMake自己的查找和包含模块
  • local variables (only created by set, list)
  • 局部变量(仅由集合、列表创建)
  • imported targets
  • 导入的目标

For this to work a successful project configuration is required.

为此,需要一个成功的项目配置。

Snippets

代码段

Qt Creator has had the ability to display code snippets for CMake, but it never shipped any snippet. Qt Creator 12 comes with five CMake code snippets.

QtCreator已经能够显示CMake的代码片段,但它从未提供任何片段。Qt Creator 12附带了五个CMake代码片段。

Completion

补全

Qt Creator 12 uses the meta information from the KSyntaxHighlighting engine to provide code completion specific arguments for the CMake commands.

Qt Creator12使用来自KSyntaxHighlighting引擎的元信息来为CMake命令提供代码补全特定参数。

For example set_source_files_properties will only get suggested the source file properties, and not the test or target properties.

例如,set_source_files_properties将只获得建议的源文件属性,而不是测试或目标属性。

The CMake specific trigger tokens are supported:

支持CMake特定的触发令牌:

  • ${ for variables
  • ${用于变量
  • $< for generator expressions
  • $<用于生成器表达式
  • $ENV{ for environment variables
  • $ENV{用于环境变量

Local CMake Find packages

本地CMake查找包

For CMake projects that have external dependencies the Modern CMake approach is to use Find<package>.cmake modules that expose imported targets. CMake documents this at A Sample Find Module.

​对于具有外部依赖关系的CMake项目,现代CMake方法是使用公开导入目标的Find<package>.CMake模块。CMake在“样本查找模块”中对此进行了记录。

These Find modules are usually placed under ${CMAKE_CURRENT_SOURCE_DIR}/cmake directory, and this is appended to the CMAKE_MODULE_PATH list variable.

这些Find模块通常放在${CMAKE_CURRENT_SOURCE_DIR}/CMAKE目录下,并将其附加到CMAKE_MODULE_PATH列表变量中。

Qt Creator 12 packs this as a code snippet.

Qt Creator 12将其打包为一个代码片段。

I took the Using libclang to Parse C++ (aka libclang 101) example to showcase how this works. Note that the Windows llvm.org releases do not contain the CMake find modules and one can’t simply use find_package to find the libclang library. See #47222 for more information.

​我举了一个使用libclang来解析C++(又名libclang 101)的例子来展示它是如何工作的。请注意,Windows llvm.org版本不包含CMake查找模块,并且不能简单地使用find_package来查找libclang库。请参阅#47222了解更多信息。

Note that under c:\Program Files\LLVM there are the include and lib directories that provide the libclang headers and libraries.

请注意,在c:\Program Files\LLVM下有include和lib目录,它们提供libclang头文件和库。

Better error / warning messages support

更好的错误/警告消息支持

Qt Creator 12 will now display the multi line error / warning messages and display the call stack in proper order.

Qt Creator12现在将显示多行错误/警告消息,并按正确顺序显示调用堆栈。

Output Messages

输出消息

Qt Creator 12 will prefix all output messages with [cmake] so that one could filter only the CMake messages if needed.

Qt Creator12将在所有输出消息前加上[cmake],以便在需要时仅过滤cmake消息。

cmake-format local configuration files

cmake格式的本地配置文件

Last but not least, Qt Creator 12 supports local .cmake-format[.py|json] configuration files!

最后但同样重要的是,Qt Creator 12支持本地.cmake格式的[.py|json]配置文件!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值