Using the following list gives me an error in add_link_option, but not in target_link_option.
In particular $<$CONFIG:Release:XXX; returns $<0:""> .So the second generator expression doesn’t work. it seems to work with target_link_option.
I don’t think you can do all the whitespace splitting you’re doing there. The explicit ; characters likely aren’t helping either. I think this needs to be something like:
Ah, the embedded ; in the genex element confuses the list parser. I would just add the genex entries directly to the target_compile_options command instead of using an intermediate variable. CMake’s list encoding is not really that great, unfortunately, but we’re stuck with it .