[Cmake] Adding a debug switch with CMake

Bill Hoffman bill . hoffman at kitware . com
Tue, 10 Jun 2003 09:26:40 -0400


At 09:18 AM 6/10/2003, Andy Cedilnik wrote:
>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...


To clarify:
ADD_CUSTOM_TARGET(debug
  ${CMAKE_COMMAND} -DMAKE_BUILD_TYPE:STRING=Debug ${PROJECT_SOURCE_DIR})

ADD_CUSTOM_TARGET(release
  ${CMAKE_COMMAND} -DMAKE_BUILD_TYPE:STRING=Release ${PROJECT_SOURCE_DIR})


There is no need to make an extra option, you can just use
CMAKE_BUILD_TYPE.


>                        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
>
>_______________________________________________
>Cmake mailing list
>Cmake at public . kitware . com
>http://public . kitware . com/mailman/listinfo/cmake