December 20, 2011

Deleted Member # 6019 Deleted Member # 6019
Lab Rat
2 posts

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?

3 replies

December 20, 2011

miroslav miroslav
Lab Rat
214 posts

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.

 Signature 

Mirko Boehm | .(JavaScript must be enabled to view this email address) | KDE e.V.
FSFE Fellow
Qt Certified Specialist

December 20, 2011

Deleted Member # 6019 Deleted Member # 6019
Lab Rat
2 posts

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?

December 20, 2011

Tobias Hunger Tobias Hunger
Hobby Entomologist
3373 posts

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.

 
  ‹‹ How to create "Plain C++ Project"      qmake subdirs project: Continue building beyond first error? ››

You must log in to post a reply. Not a member yet? Register here!