[Cmake] Adding a debug switch with CMake

Andy Cedilnik andy . cedilnik at kitware . com
10 Jun 2003 09:18:05 -0400


Hi Neil,

The most straightforward way I can think of is to create two custom
target called debug and release.

Then you would say something like:

make debug all
make release all

The custom targets would look like this:

ADD_CUSTOM_TARGET(debug
  ${CMAKE_COMMAND} -DDEBUG:BOOL=ON ${PROJECT_SOURCE_DIR})

and:

ADD_CUSTOM_TARGET(release
  ${CMAKE_COMMAND} -DDEBUG:BOOL=OFF ${PROJECT_SOURCE_DIR})

Now, you will need to do make clean to clean the object files. Also, you
should be really using CMAKE_BUILD_TYPE and set it to Debug, Release...

			Andy

On Mon, 2003-06-09 at 23:18, Neil Killeen wrote:
> I'd like my system to be so that I can build
> with the debugger if need be.
> 
> Ideally, I'd like to be able to turn the debugger on
> for selected code only.
> 
> With CMake, it seems to me that I have to turn it
> on for everything.  Thus, in CMakeLists.txt I have
> at present
> 
> # Debug ?
> OPTION (DEBUG "Turn on the debugging compiler options ?" OFF)
> 
> IF (DEBUG)
>   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
> ENDIF (DEBUG)
> 
> 
> 
> this means the user must rerun cmake and regenerate the
> Makefiles which will enable global debugging.
> 
> I'd prefer it if I could have the user issue the command
> 
> % make debug
> 
> and for that directory the debugger is turned on.
> 
> Is it possible to configure CMake to have a 'debug'
> target in this way ?
> 
> thanks
> Neil
> 
> 
> 
> _______________________________________________
> Cmake mailing list
> Cmake at public . kitware . com
> http://public . kitware . com/mailman/listinfo/cmake