check_type_size generates wrong code for iOS simulator
According to documentation, the <variable>_CODE
variable should contain the C preprocessor code to the size of the type.
However, when targeting iOS simulator and iOS Mac Catalyst, I get the following output:
CMAKE_OSX_ARCHITECTURES: armv7;armv7s;arm64;i386;x86_64
SIZEOF_LONG: 0
SIZEOF_LONG_CODE: #if defined(__ARM_ARCH_7A__)
# define SIZEOF_LONG 4
#elif defined(__ARM_ARCH_7S__)
# define SIZEOF_LONG 4
#elif defined(__aarch64__)
# define SIZEOF_LONG 8
#else
# error SIZEOF_LONG unknown
#endif
for the following cmake code:
check_type_size("long" SIZEOF_LONG)
message( "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}" )
message( "SIZEOF_LONG: ${SIZEOF_LONG}" )
message( "SIZEOF_LONG_CODE: ${SIZEOF_LONG_CODE}" )
And this fails to compile on x86_64
slices for iOS simulator and Mac Catalyst as defines for Intel slices are missing.
I'm using CMake 3.23.1 on MacOS 12.3.1 on M1 Pro chipset.