CMake GUI and CodeBlocks Project Generation

To generate the CodeBlocks project from any CMake project.

[codesyntax lang=”bash”]

cmake -G"CodeBlocks - Unix Makefiles"

[/codesyntax]

A top-level folder is created relative to the subdirectory containing the CMakeFileLists.txt.

I start CMake-Gui and add the following parameters to enable debugging symbols in the executable.

[codesyntax lang=”bash”]

CMAKE_BUILD_TYPE Debug

[/codesyntax]

Then in CMake-GUI add the following parameter.

[codesyntax lang=”bash”]

CMAKE_CXX_FLAGS_DEBUG_INIT = "g"

[/codesyntax]

The new entry is type string and the “g” to generate debug symbols option is enclosed in double-quotes.

Click the Configure button followed by the Generate button on the CMake-GUI application.  After the processes are successful, traverse to the location where the Makefile was created and issue the following command.

[codesyntax lang=”bash”]

make

[/codesyntax]

We now have an executable file with the symbols included which is ready for debugging.  The CodeBlocks debugger has issues with this approach but there is a GUI for debugging that saves the day.

KDbg should be downloaded and created using CMake.  After the interactive debug tool is installed load the executable program into the debugger.  Set a breakpoint and click the run option.  Program execution halts and the designated breakpoint.


We are now set to debug our application.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

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