Qt Creator 15-CMake更新

Qt Creator 15 - CMake Update

Qt Creator 15-CMake更新

December 16, 2024 by Cristian Adam | Comments

​2024年12月16日作者:克里斯蒂安·亚当|评论

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

以下是Qt Creator 15中CMake的新功能和修复:

More feature parity with QMake projects

与QMake项目具有更多同等功能

Qt Creator 15 allows adding subprojects for CMake projects. This can be done via right-click context menu on the project and selecting New Subproject …

Qt Creator 15允许为CMake项目添加子项目。这可以通过右键单击项目上的上下文菜单并选择“新建子项目…”来完成…

This newly added subproject can be independently built / clean / rebuild. Either from the right-click context menu, or from the top-level Build menu.

这个新添加的子项目可以独立构建/清理/重建。从右键单击上下文菜单或顶级“构建”菜单中。

Notice that the Forms directory has the pencil icon in the same way as a QMake project!

请注意,Forms目录的铅笔图标与QMake项目的方式相同!

This is available for the projects that have the Package manager auto-setup enabled, since currently it’s the only way for Qt Creator to integrate the following piece of CMake code:

这适用于启用了包管理器自动设置的项目,因为目前这是Qt Creator集成以下CMake代码的唯一方法:

option(QT_CREATOR_SOURCE_GROUPS "Qt Creator source groups extensions" ON)
if (QT_CREATOR_SOURCE_GROUPS)
  source_group("Resources" REGULAR_EXPRESSION "\\.(pdf|plist|png|jpeg|jpg|storyboard|xcassets|qrc|svg|gif|ico|webp)$")
  source_group("Forms" REGULAR_EXPRESSION "\\.(ui)$")
  source_group("State charts" REGULAR_EXPRESSION "\\.(scxml)$")
endif()

CMake targets have the associated CMakeLists.txt file node

CMake目标具有关联的CMakeLists.txt文件节点

Below you can see that every subproject, which is marked as a folder with the CMake logo icon, now includes an Open … entry in its context menu. This action allows access to the corresponding CMakeLists.txt file.

下面可以看到,每个标记为带有CMake徽标图标的文件夹的子项目现在都在其上下文菜单中包含一个Open…条目。此操作允许访问相应的CMakeLists.txt文件。

Notably, each CMake target has a file node with its defining CMakeLists.txt file in the Projects view.

值得注意的是,每个CMake目标都有一个文件节点,在Projects视图中定义了CMakeLists.txt文件。

This change also renders the Simplify Tree view less cluttered with CMakeLists.txt entries.

此更改还使Simplify Tree视图中的CMakeLists.txt条目不那么杂乱。

FOLDER property support

FOLDER属性支持

When using the FOLDER property in CMake projects for organising their structures, Qt Creator will now reflect and display these folder hierarchies.

​当在CMake项目中使用FOLDER属性来组织其结构时,Qt Creator现在将反映和显示这些文件夹层次结构。

Loading of a project via CMakeCache.txt

通过CMakeCache.txt加载项目

Qt Creator 15 can load a CMake project via the <build-dir>/CMakeCache.txt file. This is equivalent to opening the CMakeLists.txt project and then importing the <build-dir> configuration.

Qt Creator 15可以通过<build-dir>/CMakeCache.txt文件加载CMake项目。这相当于打开CMakeLists.txt项目,然后导入<build-dir>配置。

Package manager auto-setup: Windows UTF-8 challenge

包管理器自动设置:Windows UTF-8挑战

The objective here is to display the text Holiday Greetings 🌲✨ !  in the console output. Furthermore, the project has to reside within a folder named HolidayGreetings🌲✨.

这里的目的是显示“节日问候”文本🌲✨ !在控制台输出中。此外,该项目必须位于名为HolidayGreetings的文件夹中🌲✨.

The Windows configuration is a standard English (United States) language setting, as seen below:

Windows配置是标准的英语(美国)语言设置,如下所示:

windows-11-default-english-configuration

To fulfill the need to output UTF-8 Unicode text within an English locale environment, we will use the {fmt} library, which will be supplied by Conan. The source code for CMakeLists.txtmain.cpp and conanfile.txt is below:

​为了满足在英语语言环境中输出UTF-8 Unicode文本的需要,我们将使用Conan提供的{fmt}库。CMakeLists.txt、main.cpp和connfile.txt的源代码如下:

cmake_minimum_required(VERSION 3.16)

project(HolidayGreetings🌲✨)

set(CMAKE_CXX_STANDARD 17)

find_package(fmt CONFIG REQUIRED)

add_executable(HolidayGreetings main.cpp)
target_link_libraries(HolidayGreetings PRIVATE fmt::fmt)
#include <fmt/printf.h>

int main()
{
    fmt::print("Holiday Greetings 🌲✨ !\n");
    return 0;
}

 

[requires]
fmt/11.0.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值