if (generator-expression) should warn/fail
We had a piece of cmake code in our project that looked like
if ($<CONFIG:Debug>)
# Do stuff
else()
# Do other stuff
endif()
Now on first glance this seems just fine: Do stuff if the config is Debug and do other stuff if it is not. The thing with this however is that this if-statement always evaluates to the else-block.
The reason is somewhat simple: Generator expressions are resolved at compile-time and not at the initial configuration stage.
In my opinion though this example looks valid enough that it would justify explicitly checking for this pattern and then warning about it. Maybe cmake should even emit an error and fail the configuration due to this as I don't see a use-case in which this (using generator-expressions as the condition of an if-statement) would produce valid results.