Creating symbol table for gdb using cmake

compile in Release mode optimized but adding debug symbols, useful for profiling :

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ...

or compile with NO optimization and adding debug symbols :

cmake -DCMAKE_BUILD_TYPE=Debug ...

If you're using QtCreator, remove (or comment out) any line containing CMAKE_BUILD_TYPE:

# set(CMAKE_BUILD_TYPE Debug) 
# set(CMAKE_BUILD_TYPE Release) <- comment out such lines 

Reason: if you explicitly set CMAKE_BUILD_TYPE in your CmakeLists.txt, QtCreator will not allow you to set any other target.


Add this line to the file CMakeLists.txt:

set(CMAKE_BUILD_TYPE Debug)