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

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:

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?

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

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

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)

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