Determinate os platform

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:

# is 64 bit
# is 32 bit

This is still the way or it was introduced a new way since then?

Since CMake 3.10 or so there is a simpler way to check that

I assume that your are not cross-compiling.
If this is the case read indication here:

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.

Even without actual cross-compiling, will this work when generating a Win32 Visual Studio solution when running on 64-bit Windows?

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.

Looking at host bit size has limited value.