28 ms·
It should be correct - or at least, it works for what I use it for :) What is odd about it?
by viktorelofsson 10y ago
It should be correct - or at least, it works for what I use it for :)
What is odd about it?
- cm3 10y agoI don't know much about CMake, but to me the two conditions look the same, but maybe this is just how CMake magically works.
- cm3 10y agoI get the syntax now. This is a single condition, but it has to be repeated three times. Odd syntax.
- pilif 10y agoIt's very unusual, but at least it tells a reader what it's an else of. In code-reviews I still occasionally have to complain about the if (condition){ // 100 lines of code }else{ // 20 lines of code } pattern. As we're dealing with a language that has a proper subroutines and a return statement, this can just be refactored away. But CMake might not have either of those (I don't know - I have only ever written a single trivial CMakeLists.txt), so it might just force this pattern and then it's helpful to also enforce the else to restate the condition.
- cm3 10y agoThat makes sense, though the way this seems to be required to write in CMakeLists isn't maintainable. I can only guess they have diagnostics that would warn if you typo'd that easy to mistype string.
- viktorelofsson 10y agoOh, yeah, it seems as it is CMake standard to put the if-expression inside the else-parenthesis as well. It is not an elseif.
- cm3 10y agoYes, came to the same conclusion, seeing how it's the same "string" in IF, ELSE, and ENDIF. Very, very odd syntax.
- seanp2k2 10y agoWhoa, that took me reading it after each sibling comment here and one additional time to "get it". Why does it require the repetition like that?