$<0> genex doesn't evaluate argument, $<IF> evaluates both. Is that intentional?

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:


However, if we use $<IF> instead:


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?

Sounds like the same concern:
IF Generator expression evaluates both branches eagerly

Yes, that’s the same issue. Thanks for finding the ticket.

So it seems the answer to “Is that intentional?” is “No, but it’s not practical to address.” Unfortunate, but understandable; I can live with that.