When using Qmake with QtCreator, both Release and Debug builds are configured and it is easy to switch between the two. CMake supports several build types including Release, Debug, Release With Debug Info and Minimum Size Release. The default is blank (which is probably similar to Release, but definitely does not turn on debug information). However, the CMake build types are not directly available in QtCreator except by specifying the CMAKE_BUILD_TYPE variable when running CMake.
During development it is obviously desirable to build the program with debug information. The CMAKE_BUILD_TYPE variable could simply be set to Debug in the CMakeLists.txt file. But then this would need to be changed when a release is made, so this is not a good solution.
Instead, the CMakeLists.txt file was setup to look for a CMAKE_BUILD_TYPE environment variable (CMake can access system environment variables). If this environment variable is set, then the CMake variable is set to the environment variable unless it has already been set. If the environment variable is not set, it behaves the way is did before.
This environment variable can be set in QtCreator by going to the Projects screen, selecting the Build Settings and adding this environment variable to the Build Environment with the desired Debug value. The Release With Debug Info (RelWithDebInfo) could also be used, but can make stepping through the program confusing since most of same optimizations are turned on as with Release and the compiler can rearrange statements for efficiency (execution will appear to jump around) or optimize out variables (the values of which cannot be viewed).
[commit 7ee8e7483c]
Wednesday, October 24, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)