[CMake] scope of set_source_files_properties?

Simmons, Aaron asimmons at rosettastone.com
Tue Mar 23 11:34:39 EDT 2010


>Generally per-source flags should be reserved for tweaking 
>and workarounds such as using -O0 to disable buggy optimizations.

Well, I have lots of sources that don't work that way.  These sources need flags defined that turn on and off certain features.  Some of them won't even compile without the flags set.  For an open-source example, take a look at RtAudio.  You have to send in a flag that tells it what audio api to use on which OS.

> Are all these sources going into a single executable?
> If so, I suggest using an add_library() to create a static
> library for each feature.  Then link the executable to all
> of them.
>
>Oh, and then you can specify per-feature flags as target
>flags on each static library.

All the sources are going into a single *library*.  I could make a bunch of static libraries corresponding to each folder, but I'm not sure how to subsequently link all them into a single static library.  (It's been mentioned elsewhere on this list, but the answer was vague.)

At any rate, it seems like a rather elaborate workaround...



aaron


More information about the CMake mailing list