14 ms·
Is the 64bit check in CMakeLists correct? I'm no CMake expert, but this looks odd: https://github.com/picotorrent/picotorrent/blob/develop/CMakeLists.txt#L24-
by cm3 11y ago
Is the 64bit check in CMakeLists correct?
I'm no CMake expert, but this looks odd:
https://github.com/picotorrent/picotorrent/blob/develop/CMakeLists.txt#L24-L29 https://github.com/picotorrent/picotorrent/blob/develop/CMak...
# Get current architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PICO_ARCH "x64" )
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PICO_ARCH "x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
EDIT: this is just CMake's very odd syntax and it's actually a single condition.
- viktorelofsson 11y agoIt should be correct - or at least, it works for what I use it for :) What is odd about it?
- cm3 11y 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 11y agoI get the syntax now. This is a single condition, but it has to be repeated three times. Odd syntax.
- pilif 11y 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 11y 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 11y 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 11y agoYes, came to the same conclusion, seeing how it's the same "string" in IF, ELSE, and ENDIF. Very, very odd syntax.
- seanp2k2 11y 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?