From b72c47f442250c226fdef073317b2f0281ed2527 Mon Sep 17 00:00:00 2001 From: Skyler Saleh Date: Sun, 2 May 2021 01:50:43 -0700 Subject: [PATCH] Apple M1: Enable CMake cross compilation Modify the build script to use CMake's cross compilation infrastructure instead of running CMake natively in x86_64 and arm64 mode to configure the two project files. This should fix the builds with CMake executables installed through homebrew and should pave the way for building universal binaries on x86_64 systems. --- BuildMacOSUniversalBinary.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BuildMacOSUniversalBinary.py b/BuildMacOSUniversalBinary.py index a4a41211b8..a876bbb63a 100755 --- a/BuildMacOSUniversalBinary.py +++ b/BuildMacOSUniversalBinary.py @@ -234,9 +234,12 @@ def build(config): env['CMAKE_OSX_ARCHITECTURES'] = arch subprocess.check_call([ - 'arch', '-'+arch, 'cmake', '../../', '-G', config['generator'], '-DCMAKE_BUILD_TYPE=' + config['build_type'], + # System name needs to be specified for CMake to use + # the specified CMAKE_SYSTEM_PROCESSOR + '-DCMAKE_SYSTEM_NAME=Darwin', + '-DCMAKE_SYSTEM_PROCESSOR='+arch, '-DCMAKE_OSX_DEPLOYMENT_TARGET=' + config[arch+"_mac_os_deployment_target"], '-DMACOS_CODE_SIGNING_IDENTITY=' @@ -249,8 +252,8 @@ def build(config): threads = multiprocessing.cpu_count() subprocess.check_call(['cmake', '--build', '.', - '--config', config['build_type'], - '--parallel', '{}'.format(threads)], cwd=arch) + '--config', config['build_type'], + '--parallel', '{}'.format(threads)], cwd=arch) dst_app = config["dst_app"]