Qt Creator 12 - CMake Update

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

CMake Debugger

CMake starting with version 3.27 supports an interactive debugger.

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 Debugging

CMake Profiler

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.

Qt Creator 12 - CMake Profiler

Hover Help

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

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.

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.

Qt Creator 12 - CMake Hover Help


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

Qt Creator 12 extends this for:

  • functions / macros, and options
  • project targets
  • CMake’s own find and include modules
  • local variables (only created by set, list)
  • imported targets

For this to work a successful project configuration is required.

Qt Creator 12 - CMake Navigation


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.

Qt Creator 12 - CMake Snippets


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

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

The CMake specific trigger tokens are supported:

  • ${ for variables
  • $< for generator expressions
  • $ENV{ for environment variables

Qt Creator 12 - CMake Completion

Local CMake Find packages

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.

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

Qt Creator 12 packs this as a code snippet.

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.

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

Qt Creator 12 - CMake Local Packages

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 Creator 12 - CMake Error reporting

Output Messages

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

Qt Creator 12 - CMake Output

cmake-format local configuration files

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

Blog Topics: