[CMake] Adding debug definitions to OSX Xcode projects

Eric Sokolowsky esok.osg at gmail.com
Fri Mar 20 14:38:39 EDT 2009


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


More information about the CMake mailing list