Enable debugging with cmake

How to enable debugging with cmake?

If we use cmake to build the project, we may want to enabling the debuging mode that cmake invoke gcc with the -g so that we can debug the compiled program with gdb.

This can be enabled by adding the CMAKE_BUILD_TYPE parameter to cmake:

cmake -DCMAKE_BUILD_TYPE=Debug .

Then the compiled program can be debugged with gdb.

Answered by anonymous.

Leave a Reply

Your email address will not be published. Required fields are marked *