QtCreator best CMake/Conan workflow?
-
I'm wondering if anyone has a better QtCreator developer workflow for the QtCreator/Conan/CMake combination. I've installed the Conan plugin with QtCreator 9 and read some of the documentation, but it wants to add the conan install step as part of the build. In my experience, though, the Conan install step is what comes before the CMake configuration step, followed then by the CMake build step. Perhaps adding the conan install step as part of the build, as the plugin does, acts as a check to make sure your Conan dependencies stay up to date with any subsequent conanfile.py changes?
My usage is:
- create a build folder
- run something like
conan install ../<project-folder> -pr <profile> --build=missing
on the command line in the build folder - open the CMakeLists.txt from within QtCreator, telling it to use the build folder I created.
- watch the CMake configuration fail (toolchain file not specified yet), then go into the project build settings and manually type in the CMAKE_TOOLCHAIN_FILE as a value to use in QtCreator's CMake "initial configuration" tab.
- Re-run CMake configuration - i.e. "Re-configure with initial parameters"
- build the project
the clunky part is having to do the Conan piece outside the IDE, which prevents QtCreator from being able to create the build folders on your behalf. Also, since my toolchain is generated from the Conan profile the QtCreator kit is mostly unused. It doesn't seem appropriate to name the cmake toolchain file in the kit because the toolchain file is auto-generated.
-
Qt Creator's CMake project manager has the Package manager auto-setup feature. I blogged about it here: Qt Creator: CMake package-manager auto-setup.
This will inject the
share\qtcreator\package-manager\auto-setup.cmake
CMake code into your CMake project viaCMAKE_PROJECT_INCLUDE_BEFORE
variable.For Conan it will use the conan-cmake project, which would run the
conan install
step.In Qt Creator 9 you need to enable the feature, see:
-
-
@cristian-adam Thank you