CMake Port/Qt Creator

From Qt Wiki
Jump to: navigation, search

How to use Qt Creator 4.12+ to open and develop Qt 6 CMake projects


  • Have CMake 3.17+ in PATH of Qt Creator (looking at you macOS)
  • Have Ninja 1.10+ in PATH of Qt Creator (looking at you macOS)
  • Have CMAKE_GENERATOR environment variable set to Ninja (In QtCreator's environment)
  • Qt Creator 4.12.x+
  • Have various qt source repos checked out (dev branch)
Simpler method 1

How to open qtdeclarative in Qt Creator 4.12.2 (on macOS)

  1. build (and install) qtbase with cmake on command line
  2. build (and install) qtdeclarative with cmake on command line (with qt-cmake <src> && cmake —build .)
  3. register the Qt version in Qt Creator (Pointing it to the qmake that was built in (1)), press Apply
  4. create a kit with that Qt version in Qt Creator
  5. make sure compiler is set sensibly
  6. make sure the CMake Generator is set correctly
  7. remove everything from the “CMake Configuration” from the kit
  8. open the qtdeclarative/CMakeLists.txt in Qt Creator, check the kit that you created and change the build directory to qtdeclarative’s build directory

Complicated method 2


  • Only works with non-prefix builds (developer builds)!!
  • Repos should be opened and configured in topological dependency order

Goal: Open qtbase, qtdeclarative, qtshadertools, qtquick3d projects in Qt Creator to get code model completion, etc.

""Assumptions"" (I'm just gonna use my own local paths):

  • qtbase source path = /Volumes/T3/Dev/qt/qt5_cmake/qtbase
  • qtdeclarative source path = /Volumes/T3/Dev/qt/qt5_cmake/qtdeclarative
  • qtshadertools source path = /Volumes/T3/Dev/qt/qt5_cmake/qtshadertools
  • etc


  1. Beforehand prepare a qtbase build dir path ( /Volumes/T3/Dev/qt/qt5_cmake/qtbase_built_developer_pure_creator )
  2. Go to Qt Creator Settings -> Kits -> Add -> Call it something like "Pure CMake Creator Kit"
  3. In Qt version of the created Kit select None
  4. Scroll down and click the Change button next to CMake generator, make sure Generator is Ninja
  5. Click the Change button next to CMake Configuration, find the existing CMAKE_PREFIX_PATH entry, and replace it with the absolute path from step 1 CMAKE_PREFIX_PATH:STRING=/Volumes/T3/Dev/qt/qt5_cmake/qtbase_built_developer_pure_creator
  6. In the same dialog add 3 additional entries at the bottom FEATURE_developer_build:BOOL=ON BUILD_EXAMPLES:BOOL=OFF BUILD_TESTING:BOOL=OFF
  7. Press Ok and Ok to save and exit the kit settings
  8. Open qtbase/CMakeLists.txt as a new project, you'll get the kit selection settings, disable all other kits, tick the "Pure CMake Creator Kit", tick only "Debug" config, and paste the previous qtbase build dir path (IMPORTANT!), press Configure Project
  9. Open 6 General messages pane, if nothing cmake related shows up there, run the Build -> Run CMake menu item from the top menu. It should start configuring, and hopefully configures successfully. You should now have qtbase code completion.
  10. Open qtdeclarative/CMakeLists.txt as a new project, choose the same kit, tick only Debug config, build dir can be anything. Execute Build -> Run CMake Menu item, and it should hopefully configure.
  11. Repeat step 10 for qtshadertools
  12. Repeat step 10 for qtquick3d
  13. You should now have code completion for all 4 projects.

If you don't want to open projects per-repo, you can try opening qt5.git/CMakeLists.txt top-level project, but that might not work at the moment. Although there's fewer steps this way.