hi,
I’m trying to determinate the os platform that is being used so I can create a definition and pass it to my code.
From what I checked from old mails (~2011).
It is possible by checking the size of void like so:
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# is 64 bit
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
# is 32 bit
endif()
This is still the way or it was introduced a new way since then?
Yes I’m cross compiling too, but I needed cmake to get that info for me since it’s manipulable later on.
If I can query the “is_64bit” in WIndows and Linux then it’s ok and I also need to count with arm too.
is_64bit will work for the host but not for the target. That said I did not cross-compile with CMake for a loooong time. May be other more active cross-compiler can give more valuable information about that.
Every method that ist differs between 32 and 64 bit will e.g. fail for amd64. While all of this is also considered cross-compiling, it is sometimes easier to achieve than having to write a toolchain file. And it should only be used for selecting e.g library files for linking, not for setting defines for code.