Skip to main content

Qt Creator 15 - CMake Update

Comments

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

More feature parity with QMake projects

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 …

qtcreator-15-cmake-add-subproject

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

qtcreator-15-cmake-rebuild-subproject

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

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:

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

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.

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

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

qtcreator-15-target-cmakelists

FOLDER property support

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

qtcreator-15-cmake-folder-property

Loading of a project via 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.

qtcreator-15-cmake-cmakecache

Package manager auto-setup: Windows UTF-8 challenge

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🌲✨.

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

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.txt, main.cpp and conanfile.txt is below:

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

qtcreator-15-holiday-greetings

Comments

Subscribe to our blog

Try Qt 6.10 Now!

Download the latest release here: www.qt.io/download

Qt 6.10 is now available, with new features and improvements for application developers and device creators.

We're Hiring

Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.