CMake Port/Qt Creator: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
== How to use Qt Creator 4.12+ to open and develop Qt 6 CMake projects == | == How to use Qt Creator 4.12+ to open and develop Qt 6 CMake projects == | ||
'''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) | |||
===== Simpler method 1 ===== | ===== Simpler method 1 ===== | ||
Line 17: | Line 25: | ||
===== Complicated method 2 ===== | ===== Complicated method 2 ===== | ||
'''Gotchas''': | '''Gotchas''': |
Latest revision as of 12:23, 12 June 2020
How to use Qt Creator 4.12+ to open and develop Qt 6 CMake projects
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)
Simpler method 1
How to open qtdeclarative in Qt Creator 4.12.2 (on macOS)
- build (and install) qtbase with cmake on command line
- build (and install) qtdeclarative with cmake on command line (with qt-cmake <src> && cmake —build .)
- register the Qt version in Qt Creator (Pointing it to the qmake that was built in (1)), press Apply
- create a kit with that Qt version in Qt Creator
- make sure compiler is set sensibly
- make sure the CMake Generator is set correctly
- remove everything from the “CMake Configuration” from the kit
- 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
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":
- Beforehand prepare a qtbase build dir path ( /Volumes/T3/Dev/qt/qt5_cmake/qtbase_built_developer_pure_creator )
- Go to Qt Creator Settings -> Kits -> Add -> Call it something like "Pure CMake Creator Kit"
- In Qt version of the created Kit select None
- Scroll down and click the Change button next to CMake generator, make sure Generator is Ninja
- 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
- In the same dialog add 3 additional entries at the bottom FEATURE_developer_build:BOOL=ON BUILD_EXAMPLES:BOOL=OFF BUILD_TESTING:BOOL=OFF
- Press Ok and Ok to save and exit the kit settings
- 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
- 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.
- 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.
- Repeat step 10 for qtshadertools
- Repeat step 10 for qtquick3d
- 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.