aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2023-07-04 12:36:57 +0300
committerBrent Cook <busterb@gmail.com>2023-07-04 12:36:57 +0300
commit2203c13d25cfc83a45e306df40bb3b5624cace2f (patch)
tree0645e4d2b1a5025f1bdfe40be0f8802529fa97db
parent71ce0b8c3e07079a40011d2f3515969e3bdf302e (diff)
downloadportable-2203c13d25cfc83a45e306df40bb3b5624cace2f.tar.gz
portable-2203c13d25cfc83a45e306df40bb3b5624cace2f.tar.bz2
portable-2203c13d25cfc83a45e306df40bb3b5624cace2f.zip
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)
-rw-r--r--CMakeLists.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7847830..b8863c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -306,6 +306,15 @@ if(HAVE_NETINET_IP_H)
306 add_definitions(-DHAVE_NETINET_IP_H) 306 add_definitions(-DHAVE_NETINET_IP_H)
307endif() 307endif()
308 308
309# This isn't ready for universal binaries yet, since we do conditional
310# compilation based on the architecture, but this makes cross compiling for a
311# single architecture work on macOS at least.
312#
313# Don't set CMAKE_OSX_ARCHITECTURES to more than a single value for now.
314if(APPLE)
315 set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_OSX_ARCHITECTURES}")
316endif()
317
309if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)") 318if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)")
310 set(HOST_AARCH64 true) 319 set(HOST_AARCH64 true)
311elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") 320elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")