I’ve been hit by a difference between $<0:x>
and $<IF:c,x,y>
which I considered unexpected, and wanted to ask whether it’s intentional.
In these example, assume target foo
does not exist. Tested with CMake 3.18.3.
The following genex evaluates to the empty string just fine:
$<$<TARGET_EXISTS:foo>:$<TARGET_LINKER_FILE:foo>>
However, if we use $<IF>
instead:
$<IF:$<TARGET_EXISTS:foo>,$<TARGET_LINKER_FILE:foo>,>
we get an error saying
No target “foo”
This means that both branches of $<IF>
must be fully valid, regardless of the condition. From my view, it severly diminishes the usability of $<IF>
if I have to think about whether the condition affects the validity of both branches, instead of using it automatically whenever I need an if-else.
Is this behaviour intentional, or should I file a bug?