[CMake] replace an entry in add_definitions()?

Philip Lowman philip at yhbt.com
Thu Mar 5 01:27:33 EST 2009


On Wed, Mar 4, 2009 at 3:21 PM, Bill O'Hara <billtohara at gmail.com> wrote:

> 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?


Have you tried remove_definitions()?

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090305/f8a635b5/attachment.htm>


More information about the CMake mailing list