[CMake] Adding debug definitions to OSX Xcode projects

Michael Jackson mike.jackson at bluequartz.net
Fri Mar 20 14:46:30 EDT 2009


Actually, if someone on OS X decides to generate Makefiles then  
CMAKE_BUILD_TYPE can be very important.

You can simply do what you are doing and it _should_ work. The order  
of operations in a CMake file, like any other language, is important.  
It just depends on what is after those lines that you insert will  
determine what gets used and what does not.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Mar 20, 2009, at 2:38 PM, Eric Sokolowsky wrote:

> How do you tell Cmake to add a compiler flag to a project's Debug  
> target?
>
> In a project I'm trying to fix (OpenSceneGraph) it looks like Cmake
> generates an Xcode project file containing all four of the build  
> types:
> Debug, Release, ReleaseMinSize, and RelWithDebInfo. These types can be
> selected from within Xcode. Is it therefore true that there is no need
> to set CMAKE_BUILD_TYPE on OSX? To gain understanding of what cmake is
> doing, I have the following lines at the beginning of the  
> CMakeLists.txt:
>
> SET(COMPILE_DEFINITIONS_DEBUG ${COMPILE_DEFINITIONS_DEBUG} -D_DEBUG=2)
> SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG=3)
> SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} -D_DEBUG=4)
> add_definitions(-D_DEBUG=5)
>
> And I put these lines at the end of the file:
>
> SET(COMPILE_DEFINITIONS_DEBUG ${COMPILE_DEFINITIONS_DEBUG} -D_DEBUG=6)
> SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG=7)
> SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} -D_DEBUG=8)
> add_definitions(-D_DEBUG=9)
>
> When I look in the build directory I only see instances of "- 
> D_DEBUG=5"
> and "-D_DEBUG=9". The Cmake documentation implies that at least one of
> the other lines should do *something*, but they appear to do nothing.
>
> Can anyone explain what is going on? Thanks.
>
> -Eric
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list