Qt Creator 5 - CMake projects update

Tuesday August 17, 2021 by Cristian Adam | Comments

Qt Creator 5 comes with bug fixes and new features that affect CMake projects.

CMake output in Projects mode

When configuring CMake projects in Projects mode now you can see the output of the CMake command.

Besides seeing the output you can also filter the output messages as seen in the screencast below:

Compile output in Projects mode

Now you can see the compilation output in Projects mode, there is no more need to switch between 'Projects' and 'Edit' mode to see the compilation output.

No more temporary build directory

Qt Creator 5 doesn't use a temporary directory for the initial project configuration. This means that for bigger projects, you don't have to configure the project twice to get it right.

This behavior was previously opt-in in settings by checking the 'Auto-create build directories' check box.

Build directory is no longer read-only

Qt Creator 4.13 made the build directory edit field read-only due to build directories created for every letter typed when 'Auto-create build directories' setting was enabled.

Qt Creator 5 enables you to edit the build directory and the directory is created only when you finish editing.

Hide Source and Header groups

Now you can have the source and header files without the extra tree level of 'Header Files' and 'Source Files'. This can be configured as seen below:

Selecting a default run target

Qt Creator itself has multiple executables, but when you run the project you would just want to run 'qtcreator' and not the first executable in the list.

With Qt Creator 5, you can set the FOLDER property with the qtc_runnable value and Qt Creator will just show those targets in the run list.

In your CMakeLists.txt you need to have something like:


set_target_properties(main_executable PROPERTIES FOLDER 'qtc_runnable')
No more QT_QMAKE_EXECUTABLE warning

Qt Creator is setting a few CMake variables when configuring a project. If the variables are not referenced, CMake is showing a warning.

Now these variables are referenced in the package-manager/auto-setup.cmake CMake file that gets injected via the CMAKE_PROJECT_INCLUDE_BEFORE parameter and CMake will no longer emit those warnings.

Macro support for Execute Custom Commands

Locator's 'Execute Custom Commands' option got support for macros.

This means that if you want to delete the active project's build directory you can do:


! cmake -E rm -rf %{ActiveProject:BuildConfig:Path}

Or if you want to run ctest for the active project (CMake 3.20+):


! ctest --test-dir %{ActiveProject:BuildConfig:Path}

Share with your friends

Blog Topics:
  • cmake

Attachments

  • Original document
  • Permalink

Disclaimer

Qt Group Oyj published this content on 17 August 2021 and is solely responsible for the information contained therein. Distributed by Public, unedited and unaltered, on 17 August 2021 19:23:02 UTC.