[RFC] Add ability to create source_group at target level and derive it via PUBLIC/INTERFACE/PRIVATE

Currently, source_group() is restricted to subdirectories, which is not convenient then we have a base library with sets of headers (inside some target possibly).
While we could use the `target_sources( INTERFACE) for adding some headers/file sets, we can’t group it in a target itself.
It would be convenient if we could also optionally store the source_groups inside the targets and derive it as a property.

Possible design thoughts:

  1. source_group(TARGET <target_name> [PUBLIC|PRIVATE|INTERFACE] <old args>)
  2. target_sources(<target_name> FILE_SET <set_name> SOURCE_GROUP NAME <group_name >[PUBLIC|PRIVATE|INTERFACE] ....)
1 Like

Cc: @kyle.edwards @ben.boeckel

The source_group functionality is one of the last few pieces of the older directory-based model that hasn’t been updated to target-based equivalents. I agree with (2) in the original post that target_sources may be a reasonable place to specify source groups.

I expect people will want to control source groups both for normal sources and those in a FILE_SET, and perhaps map sources in the same file set to multiple different source groups.

1 Like

yes, we may just add the something like…
target_sources(<target> SOURCE_GROUP <name> FILES <files....>)