Issue
Variables like $<TARGET_OBJECTS:myTarget>
can contain a list. To pretty-print it I would like to transform like put a dash, or whatever. So the question is simple : can we call a function from a generator expression ?
I know generator expressions are evaluated at the end of the process, but for me it doesn't implies it can't call a function. However, it's not possible to return a value. If this is possible, is there a way to use it inside generator expressions ?
Solution
You cannot call a function for the result of a generator expression, because generator expressions are evaluated after the configuration stage, when all CMake functions are executed.
For pretty-printing a list you could use $<JOIN>
expression.
For example,
$<JOIN $<TARGET_OBJECTS:myTarget>,$<COMMA> >
will concatenate all objects and paste ,
between them.
Answered By - Tsyvarev Answer Checked By - Mary Flores (WPSolving Volunteer)