[CMake] scope of set_source_files_properties?

Brad King brad.king at kitware.com
Tue Mar 23 11:42:42 EDT 2010


Simmons, Aaron wrote:
> You have to send in a flag that tells it what audio api to use on which OS.

We rarely create source files that depend on definitions from the command line
to function (which is one reason per-source flags are not solid in CMake).
Instead we use configure_file() to put options in header files which then
get included by the sources.  It's much more reliable because the configured
header gets included in dependency scanning.

>> 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.)

That's a "convenience" library approach, and it's not really supported
(partly because there is no way to implement it on some toolchains such
as MSVC).

-Brad


More information about the CMake mailing list