[CMake] -g3 ?

Brad King brad.king at kitware.com
Wed Feb 23 09:16:55 EST 2005


Luca Cappa wrote:
> Hello,
> 
> I'm trying to get the flag "-g3" during the compilation process. If I 
> use in my CMakeLists.txt file this statement
> 
> SET(CMAKE_BUILD_TYPE Debug)
> 
> I will get only the "-g" flag, and not the "-g3" one: in poor words I 
> dont know how to control the level of the debugging information.
> Actually I'm using this hack:
> 
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
> 
> Any hints to do this better?

If this is just a per-build-tree decision then you can change the flags 
at CMake time without modifying the source tree at all.  When running 
CMakeSetup or ccmake turn on advanced cache options and find these settings:

CMAKE_BUILD_TYPE
CMAKE_CXX_FLAGS_DEBUG

You can modify the value of the debug flags to replace -g with -g3 and 
then set the build type to Debug.

If you want to force use of this flag from the CMake source code 
(probably a bad idea as it is a platform-specific flag) then you can 
just use

SET(CMAKE_CXX_FLAGS_DEBUG "-g3")

to override any value set in the cache.  With this line that flag will 
be used no matter what the cache viewer in CMakeSetup or ccmake says.

-Brad


More information about the CMake mailing list