I have a feature proposal for configure_file. Today, variables must be single element only, otherwise a ; is pasted into the configured file.
With the following multi element list:
set(TESTING “ONE” “TWO” “THREE” “FOUR” “FIVE”)
configure_file(input.c output.c @ONLY)
and input.c:
void function_@TESTING@(void);
I currently get:
void function_ONE;TWO;THREE;FOUR;FIVE(void);
I propose that the result should instead be:
void function_ONE(void);
void function_TWO(void);
void function_THREE(void);
void function_FOUR(void);
void function_FIVE(void);
This would make it much easier to configure enums f.i.
configure_file does simple string substitution only. There is no way to express what you’re requesting. Instead you can write a loop over TESTING to generate the expanded form of the code in a variable before the call to configure_file, and use the latter variable as the placeholder instead.
Even with such a feature, there are multiple things to consider that would complicate it:
What if there are multiple variables? (void function_@name@(@args@);)
How to expand a series of lines instead of a single line? (if there were a newline between void and function_ here)
By the time these are there, you’re most of the way to a templating tool like Jinja with the associated loops and such. I don’t think configure_file should gain these (as some places do want ;-separated lists and something needs to communicate this on a per-variable level). For such things, I suggest a tool that can express what you want properly.