In the old days (prior to Qt Creator version 4.0) you could simply pass the CMake configuration command line and you would get a right configured project from the start!
Qt Creator up to version 4.13
There were three ways to configure CMake projects in Qt Creator with the above flags:
Use a command line script which would configure the project and then import it in Qt Creator.
Create a Qt Creator Kit, which would have all the settings in the CMake Configuration field.
Manually select all the options in the CMake project settings. This would add the values in the CMakeLists.txt.user file.
If you used a script to configure the project (or cmake-gui), and then decided to change a setting Qt Creator, you could encounter the following dialog:
Qt Creator 4.13
The above dialog is gone in Qt Creator 4.13 since Qt Creator doesn’t use the CMakeLists.txt.user file to store individual CMake options. It only stores the Initial CMake parameters, the subsequently changed ones are passed via -D<option>=<value> to CMake, which stores the options in the CMakeCache.txt file.
This means that if you remove the build directory, all the custom settings that are not part of the initial CMake parameters are gone.
This configuration dialog looks like this:
You can configure the project from the Build menu and then Run CMake like this:
Notice the Clear CMake Configuration menu entry, which would remove the CMakeCache.txt file, which you need to do if you change the Initial CMake parameters field. This has the potential of doing a full rebuild.
Having less targets to build has an impact on Qt Creator build time (Windows 10, 10 core Intel i9 machine):
CMake configure time
“Nuking” up the build
You can either delete the whole build directory, or from Qt Creator’s Build menu:
Clean Project “Qt Creator”. This will execute the clean ninja target, which will remove the build artifacts (*.obj, *.dll, *.exe)
Clear CMake Configuration. This will remove the CMakeCache.txt file.
Then you can Run CMake and Build Project “Qt Creator” and it should behave as having had nuked the build directory.
Auto-create build directories
Qt Creator by default sets the following options for CMake:
This means that every time you type and save your CMakeLists.txt CMake will configure the project. I personally have the habit of pressing Ctrl-S without thinking and when CMake runs in the background for 30 seconds it becomes quickly annoying.
The second option means that Qt Creator will initially configure the project in a temp directory, and when you build the project, it will start from scratch and configure the project again with the build directory.
I like to have less CMake project configure runs and no surprise CMake configure runs by setting up CMake the other way around: