# configure\_file feature request

**URL:** https://discourse.cmake.org/t/configure-file-feature-request/8462
**Category:** Development
**Created:** [July 5, 2023, 6:51am UTC](https://discourse.cmake.org/t/configure-file-feature-request/8462 "2023-07-05T06:51:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![robiwano](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robiwano/32/1027_2.png) [@robiwano](https://discourse.cmake.org/u/robiwano)
#### Post date: [July 5, 2023, 6:51am UTC](https://discourse.cmake.org/t/configure-file-feature-request/8462/1 "2023-07-05T06:51:25Z")

</div>

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.

Regards  
/Robert

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [July 5, 2023, 11:49am UTC](https://discourse.cmake.org/t/configure-file-feature-request/8462/2 "2023-07-05T11:49:18Z")

</div>

`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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 9, 2023, 4:32pm UTC](https://discourse.cmake.org/t/configure-file-feature-request/8462/3 "2023-07-09T16:32:01Z")

</div>

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.
