Debugger problem with CMake project



  • I'm unable to use the debugger with CMake projects, it ignores the breakpoints because the executable is build without debugging info. Imported project has only one configuration (there are no Debug and Release configurations)

    The way around this is to create a custom build step that runs before make. It should invoke cmake.exe passing "-DCMAKE_BUILD_TYPE=Debug ." as an argument.

    Why is this needed? Is there something I can add to my CMakeLists.txt to configure this properly and have both Debug and Release configurations?



  • When you open the project in Creator (by opening the CMakeLists.txt), it asks you to run cmake. At that step, enter "-DCMAKE_BUILD_TYPE=Debug" in the options field. That should do it.



  • Thanks, but this solves only first half of the problem. Is there a way to get both configurations and be able to switch between them like in Visual Studio?


  • Moderators

    You are free to set up several build directories, each with a different configuration (e.g. one debug one release). Switching between configurations is then a matter of changing the build directory. As far as I know there is no way to automatically set up several build directories at once with cmake.

    If you are using Qt Creator: The IDE could in theory do that for you, but currently does not. Patches to improve cmake support are welcome.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.