[CMake] Adding debug definitions to OSX Xcode projects

David Cole david.cole at kitware.com
Fri Mar 20 14:50:14 EDT 2009


CMAKE_BUILD_TYPE is irrelevant with build systems that handle multiple
configurations (like Xcode and Visual Studio). Makefile based systems still
need CMAKE_BUILD_TYPE defined to select the type of build.

The flags you are setting need double quotes to work as you intend them,
like this:
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG=3")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG=4")

I don't know about COMPILE_DEFINITIONS_DEBUG.


HTH,
David

On Fri, Mar 20, 2009 at 2:38 PM, Eric Sokolowsky <esok.osg at gmail.com> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090320/5d67e453/attachment.htm>


More information about the CMake mailing list