CMake Port/Qt Creator

From Qt Wiki
< CMake Port
Revision as of 12:29, 9 June 2020 by Croitor Alexandru (talk | contribs) (Created page with "== How to use Qt Creator 4.12+ to open and develop Qt 6 CMake projects == Complicated method 2 (written by Alexandru) '''Prerequisites''': * Have CMake 3.17+ in PATH of Qt...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

Complicated method 2 (written by Alexandru)

Prerequisites:

  • 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)

Gotchas:

  • 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

"Steps":

  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.