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)
I currently get:
I propose that the result should instead be:
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? (
- How to expand a series of lines instead of a single line? (if there were a newline between
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.