CMake has for single configuration configurators the following build types (configuration):
- Empty (Qt Creator wrongly refers to this as “Default”)
- Debug
- Release
- RelWithDebInfo – Release with debug information, needed for profiling / post mortem debugging
- MinSizeRel – Release optimized for size, and not for speed.
If we have a look at CMake’s Modules/Compiler/GNU.cmake we can see:
# Initial configuration flags.
string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
The empty build type usually contains the common build flags for all build types. It is generated from
the CMAKE_C_FLAGS_INIT / CMAKE_CXX_FLAGS_INIT variables, and the CFLAGS / CXXFLAGS system environment variables.
But in the case of an IDE like Qt Creator makes no sense to have, you will end up for GCC with a
-O0 (Debug) build. I’ve opened QTCREATORBUG-22013 in this regard.
CMake uses the CMAKE_<LANG>_FLAGS_<CONFIG>_INIT
variables which will be used to populate the CMAKE_CMAKE_<LANG>_FLAGS_<CONFIG> variables.
There are cases when you might want to change the default build types:
- Want to have
-g1forRelWithDebInfo, because your binaries are becoming too big - Want to improve build times in Debug mode with
-gsplit-dwarf - Want to link to a different version of the CRT
- Want to enable all possible warnings from the compiler
Lastly, we want to do all this without putting if clauses in the code, and manually changing the CMAKE_<LANG>_FLAGS variables.
The rule of thumb is: if you have to change compiler flags, you should do it in a toolchain file!

) to have a QNX 7.0 license I tried to compile and run the recently released CMake 3.13.0 for the QNX 7.0 x86_64 target!
Also important not to forget about the installation of the VirtualBox
Guest Additions.

