Add generator expression to get the absolute file paths for SOURCES
Hi CMake developers,
I need to write all source files of a target via file(GENERATE)
to a text file that is reused later in some project specific custom command.
However if I use the generator expression $<TARGET_PROPERTY:a,SOURCES>
then I may get relative paths which I can't resolve properly in my custom command. I may of course add some additional information to the file (e.g. write <$TARGET_PROPERTY:a,SOURCE_DIR>
to the file) and do the calculation manually, but I would like to have a generator expression that already provides the information.
Two solutions are in my mind:
# General expression that transforms either a single value or a list to a value/list with absolute file paths
# Syntax: $<TO_ABSOLUTE:value_or_list,base_dir>
# Example (see below)
$<TO_ABSOLUTE:$<TARGET_PROPERTY:a,SOURCES>,$<TARGET_PROPERTY:a,SOURCE_DIR>>
# Explicit solution that only works for the SOURCES property
# Syntax: $<TARGET_SOURCES:tgt>
# Example (see below)
$<TARGET_SOURCES:a>
I think such a generator expression makes sense - not only for the scenario I have.
Best regards, Markus