make cross compilation possible on macOS with CMake
Sync CMAKE_SYSTEM_PROCESSOR to CMAKE_OSX_ARCHITECTURES. This doesn't support universal binaries, but does allow cross-compiling for a single architecture by setting -DCMAKE_OSX_ARCHITECTURES=(arm64|x86_64)
This commit is contained in:
parent
71ce0b8c3e
commit
2203c13d25
@ -306,6 +306,15 @@ if(HAVE_NETINET_IP_H)
|
|||||||
add_definitions(-DHAVE_NETINET_IP_H)
|
add_definitions(-DHAVE_NETINET_IP_H)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# This isn't ready for universal binaries yet, since we do conditional
|
||||||
|
# compilation based on the architecture, but this makes cross compiling for a
|
||||||
|
# single architecture work on macOS at least.
|
||||||
|
#
|
||||||
|
# Don't set CMAKE_OSX_ARCHITECTURES to more than a single value for now.
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_OSX_ARCHITECTURES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)")
|
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)")
|
||||||
set(HOST_AARCH64 true)
|
set(HOST_AARCH64 true)
|
||||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user