# How do you evaluate a generator expression without the surrounding quotes?

**URL:** https://discourse.cmake.org/t/how-do-you-evaluate-a-generator-expression-without-the-surrounding-quotes/6017
**Category:** Usage
**Created:** [July 7, 2022, 3:47am UTC](https://discourse.cmake.org/t/how-do-you-evaluate-a-generator-expression-without-the-surrounding-quotes/6017 "2022-07-07T03:47:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marstaik](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marstaik/32/2230_2.png) [@marstaik](https://discourse.cmake.org/u/marstaik)
#### Post date: [July 7, 2022, 3:47am UTC](https://discourse.cmake.org/t/how-do-you-evaluate-a-generator-expression-without-the-surrounding-quotes/6017/1 "2022-07-07T03:47:48Z")

</div>

So this is probably a bit of a silly question, maybe?

I’m not sure how to output the result of a generator expression without quotes…

IE:

```cmake
add_custom_command(
      OUTPUT ${output_file}
      COMMAND
        refl_exe -i ${file} -o ${output_file}
        $<$<BOOL:${id}>:-I$<JOIN:${id}, -I>>
        $<$<BOOL:${iid}>:-I$<JOIN:${iid}, -I>>
        $<$<BOOL:${co}>:-O$<JOIN:${co}, -O>>
        $<$<BOOL:${ico}>:-O$<JOIN:${ico}, -O>>
        $<$<BOOL:${cd}>:-D$<JOIN:${cd}, -D>>
        $<$<BOOL:${icd}>:-D$<JOIN:${icd}, -D>>
      MAIN_DEPENDENCY ${file}
      DEPENDS refl_exe VERBATIM)

```

If I don’t wrap the generator expressions in quotes, the output literally contains the generator expressions.

If I quote the generator expressions, they evaluate, but then the output also has quotes around it!

How do I get it to evaluate without quotes?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [July 7, 2022, 8:54am UTC](https://discourse.cmake.org/t/how-do-you-evaluate-a-generator-expression-without-the-surrounding-quotes/6017/2 "2022-07-07T08:54:51Z")

</div>

You can’t. Generator expressions **must** be specified inside quotes.

To avoid surrounding quotes, I suggest to use `COMMAND_EXPAND_LISTS` option:

```cmake
add_custom_command(
      OUTPUT ${output_file}
      COMMAND
        refl_exe -i ${file} -o ${output_file}
        "$<$<BOOL:${id}>:-I$<JOIN:${id},$<SEMICOLON>-I>>"
        "$<$<BOOL:${iid}>:-I$<JOIN:${iid},$<SEMICOLON>-I>>"
        "$<$<BOOL:${co}>:-O$<JOIN:${co},$<SEMICOLON>-O>>"
        "$<$<BOOL:${ico}>:-O$<JOIN:${ico},$<SEMICOLON>-O>>"
        "$<$<BOOL:${cd}>:-D$<JOIN:${cd},$<SEMICOLON>-D>>"
        "$<$<BOOL:${icd}>:-D$<JOIN:${icd},$<SEMICOLON>-D>>"
      MAIN_DEPENDENCY ${file}
      DEPENDS refl_exe VERBATIM
      COMMAND_EXPAND_LISTS)

```

---

<div class="post-metadata">

### Author: ![marstaik](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marstaik/32/2230_2.png) [@marstaik](https://discourse.cmake.org/u/marstaik)
#### Post date: [July 7, 2022, 5:15pm UTC](https://discourse.cmake.org/t/how-do-you-evaluate-a-generator-expression-without-the-surrounding-quotes/6017/3 "2022-07-07T17:15:29Z")

</div>

I see, so you have to re-glue it into a list with a semicolon and then have it be re-expanded.

Wow, honestly not the most elegant solution… but it works
