[cmake-developers] source_group and generator expressions

Brad King brad.king at kitware.com
Tue May 16 11:21:18 EDT 2017


On 05/16/2017 10:18 AM, Sebastian Holtermann wrote:
> I thought per configuration source were supported already :/.

They are supported by Makefile and Ninja generators but not by others.

> Would TARGETNAME_autogen/moc_compilation_$<CONFIG>.cpp work with the
> current state of VS and XCode? The file name is pretty much unique.

Yes, though some work would still be needed to add the right exclusion
code to Xcode.

> AddSource method that takes a second configuration parameter

No, the code model representation for per-config sources is based on
generator expressions.  At best such a method would just construct
the corresponding genex internally.

> AUTOGEN generated files the properties "GENERATED" and "SKIP_AUTOGEN"
> must be set. This requires access to the cmSourceFile which is not
> available when using the $<CONFIG> generator expression in the current
> cmGeneratorTarget::AddSource.

Use cmMakefile::GetOrCreateSource for each of the per-config names
(and no generator expression) to get a `cmSourceFile*` and set its
properties.  Then add the source to the target with the generator
expression in its name.  The generators should match them up properly.

> Also cmGeneratorTarget::AddIncludeDirectory with configuration parameter
> would be required to pass per configuration include directories.

Pass include directories that contain generator expressions to filter
or name by configuration.

-Brad


More information about the cmake-developers mailing list