[CMake] help me to resolve this issue

Philip Lowman philip at yhbt.com
Tue Nov 3 23:56:44 EST 2009


On Tue, Nov 3, 2009 at 10:40 PM, Alex H <aditya15417 at hotmail.com> wrote:

>  Okay here's what I've done so far:
>
> add_definitions(-DV_FILM)
> add_executable(hassel-film has-main.cpp)
>
> remove_definitions(-DV_FILM)
> add_definitions(-DV_DIGITAL)
> add_executable(hassel-digital has-main.cpp)
>
> What I want to do is after running cmake . and typing it make. I want to
> generate two executable, one is hassel-film which is has-main.cpp compiled
> with the flag -V_FILM
> and the other one is hassel-digital which is compiled with the flag
> -V_DIGITAL. How can I do this? The above code will compile with V_DIGITAL
> flag, which is not what I want.
>

It would sure be great if in a future policy of CMake, add_definitions()
behaved the way you describe it.  I remember trying something similar a long
time ago and being equally dumbfounded.  There are other inconsistencies in
how CMake behaves.  Changing the CMAKE_CXX_FLAGS in-between add_executable()
calls also doesn't seem to work for me, for example.

In the meantime you're probably can make do with set_target_properties(),
specifically the COMPILE_FLAGS property.
http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set_target_properties


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


More information about the CMake mailing list