[CMake] Recompile with different flags

Adam Weiss cseadam+cmake at gmail.com
Mon Jan 19 19:48:09 EST 2009


I thought only LINK_FLAGS could be added there, I'll try it when I get
back to my work machine.

As for ignoring the flags, I don't think that will work since several files have

#ifndef VAR_NAME
<code>
#else
<code>
#endif

Again, this method bothers me, but I'm supposed to make a few code
changes as possible.

Thanks

On Mon, Jan 19, 2009 at 5:48 PM, Philip Lowman <philip at yhbt.com> wrote:
> On Mon, Jan 19, 2009 at 4:44 PM, Adam Weiss <cseadam+cmake at gmail.com> wrote:
>>
>> I am still fairly new to cmake, and I am not sure how to make
>> configurations.  Let me see if I can provide some more details.
>>
>> The hope is that a third party can run:
>>
>> mkdir build
>> cd build
>> cmake ..
>> make
>>
>> and have both libraries built.  A less graceful way I was considering
>> was to have cmake copy all the files that need the flag set and then
>> use the copies to build the second version of the library.  If you
>> could elaborate on how to build configurations of a library I would
>> appreciate it.
>
> Sounds like you could call add_library() twice and use the COMPILE_FLAGS
> property on each target?
>
> set(my_SRCS foo.h foo.cc)
>
> add_library(foo ${my_SRCS})
> set_target_properties(foo PROPERTIES COMPILE_FLAGS "-DFOO")
>
> add_library(foo2 ${my_SRCS})
> set_target_properties(foo2 PROPERTIES COMPILE_FLAGS "-DFOO2")
>
>
> --
> Philip Lowman
>


More information about the CMake mailing list