darling/cmake/architecture.cmake
Thomas A. 0b6b8a3e5c Set Fall Back Arch To The Primary Arch For MIG
I was looking through the build scripts in XNU to see how MIG is being used. While there are some cases where we need to explicitly set the arch to its 32-bit equivalent (ex: i386 instead of x86-64), those situations seem to be the exception rather than the norm.

As a result, I don't think we should be hardcoding i386 as a fallback. We should use the primary architecture instead.
2024-05-07 18:20:14 -07:00

39 lines
1.1 KiB
CMake

macro(generate_architecture)
if (TARGET_x86_64)
set(APPLE_ARCH_64BIT "x86_64")
else ()
set(APPLE_ARCH_64BIT "")
endif ()
if (TARGET_i386)
set(APPLE_ARCH_32BIT "i386")
else ()
set(APPLE_ARCH_32BIT "")
endif ()
if (TARGET_x86_64)
set(BUILD_TARGET_64BIT TRUE)
set(APPLE_TARGET_TRIPLET_64BIT "x86_64-apple-darwin20")
else ()
set(BUILD_TARGET_64BIT FALSE)
set(APPLE_TARGET_TRIPLET_64BIT "")
endif ()
if (TARGET_i386)
set(BUILD_TARGET_32BIT TRUE)
set(APPLE_TARGET_TRIPLET_32BIT "i386-apple-darwin20")
else ()
set(BUILD_TARGET_32BIT FALSE)
set(APPLE_TARGET_TRIPLET_32BIT "")
endif ()
if (BUILD_TARGET_64BIT)
set(APPLE_TARGET_TRIPLET_PRIMARY ${APPLE_TARGET_TRIPLET_64BIT})
set(APPLE_ARCH_PRIMARY ${APPLE_ARCH_64BIT})
elseif (BUILD_TARGET_32BIT)
set(APPLE_TARGET_TRIPLET_PRIMARY ${APPLE_TARGET_TRIPLET_32BIT})
set(APPLE_ARCH_PRIMARY ${APPLE_ARCH_32BIT})
else ()
set(APPLE_TARGET_TRIPLET_PRIMARY "")
endif ()
endmacro()