[CMake] replace an entry in add_definitions()?

Bill O'Hara billtohara at gmail.com
Wed Mar 4 15:21:45 EST 2009


Hi All,

Say I have a CMakeLists.txt that  does

add_definitions(-DFOO=1)
add_subdirectory(bar)

and in bar the CMakeLists.txt does

add_definitions(-DFOO=2)

The intention being that the code in the subdirectory needs the different
definition of FOO. Is there a straightforward way to temporarily override
the -DFOO? That is, when we go back up to the parent that -DFOO=1 now has
effect? My naive attempt above means that -DFOO=1 -DFOO=2 ends up in the
compiler arguments which causes things to break (the compiler doesn't like
FOO being redefined like that).

Any hints?

thanks
b.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090304/fa504b2b/attachment.htm>


More information about the CMake mailing list