[cmake-developers] source_group and generator expressions

Brad King brad.king at kitware.com
Tue May 16 09:11:52 EDT 2017


On 05/16/2017 05:52 AM, Sebastian Holtermann wrote:
> There are two ways to achieve this
> 1) Put TARGETNAME_autogen/$<CONFIG>/moc_compilation.cpp
>    into AUTOGEN_SOURCE_GROUP
>    - Requires gen. exp. support in source_group
> 
> 2) Manually replace $<CONFIG> for all configurations and put all
>    variants into the AUTOGEN_SOURCE_GROUP
>    - Does not require gen. exp. support in source_group
>    - May flood the source_group with files from an other configurations?
>      Are source groups even configuration aware?
> 
> I'd prefer 1) but does source_group support generator expressions?

I don't think so, but it could be taught to do so.  The main challenge
is supporting per-configuration sources, and that would have to be
solved for either approach.

Source groups are used in IDE generators to organize source files.
The IDE project file formats tend to not have the Configuration
as a parameter to their source groups.  Instead all sources for
all configurations get listed and then individual sources can be
marked with conditions on a per-configuration basis.

Recently I refactored the VS generators to support per-config
source generation (via per-config exclusion rules).  Currently
it is limited somewhat artificially but the main generation
infrastructure is there.

OTOH the Xcode generator does not have a good way to do per-config
source files.  It has very limited support for excluding source
files on a per-config basis but only by the *file name* ignoring
the directory.

-Brad



More information about the cmake-developers mailing list