Skip to content

Commit 450d8bb

Browse files
authored
fix: universal2 build (scikit-build#90)
ExternalProject_add does not forward CMAKE_OSX_ARCHITECTURES to the external project. This leads to a broken universal2 build which only has the x86_64 binary. Let's forward a few variables to the external project to fix this.
1 parent 89ef2b5 commit 450d8bb

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,30 @@ if(UNIX AND NOT APPLE)
102102
)
103103
else()
104104
set(Ninja_BINARY_DIR ${CMAKE_BINARY_DIR}/Ninja-build)
105+
# cache arguments
106+
set(_cache_args )
107+
foreach(var_name IN ITEMS
108+
CMAKE_BUILD_TYPE
109+
CMAKE_TOOLCHAIN_FILE
110+
CMAKE_BUILD_PARALLEL_LEVEL
111+
CMAKE_JOB_POOLS
112+
CMAKE_JOB_POOL_COMPILE
113+
CMAKE_JOB_POOL_LINK
114+
CMAKE_OSX_DEPLOYMENT_TARGET
115+
CMAKE_OSX_ARCHITECTURES
116+
CMAKE_OSX_SYSROOT
117+
)
118+
if(DEFINED ${var_name})
119+
list(APPEND _cache_args
120+
-D${var_name}:STRING=${${var_name}}
121+
)
122+
message(STATUS "SuperBuild - ${var_name}: ${${var_name}}")
123+
endif()
124+
endforeach()
125+
# _cache_args should not be empty
126+
list(APPEND _cache_args
127+
-DNINJA_SUPERBUILD:BOOL=true
128+
)
105129
ExternalProject_add(build_ninja
106130
SOURCE_DIR ${Ninja_SOURCE_DIR}
107131
BINARY_DIR ${Ninja_BINARY_DIR}
@@ -111,6 +135,7 @@ else()
111135
USES_TERMINAL_CONFIGURE 1
112136
USES_TERMINAL_BUILD 1
113137
INSTALL_COMMAND ""
138+
CMAKE_CACHE_ARGS ${_cache_args}
114139
DEPENDS
115140
download_ninja_source
116141
)

scripts/repair_wheel.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess
66
import sys
77
import tempfile
8+
import zipfile
89
from pathlib import Path
910

1011
from convert_to_generic_platform_wheel import convert_to_generic_platform_wheel
@@ -58,6 +59,15 @@ def main():
5859
# we need to handle macOS x86_64 & arm64 here for now, let's use additional_platforms for this.
5960
additional_platforms = []
6061
if os_ == "macos":
62+
# delocate-wheel --require-archs does not seem to check executables...
63+
with tempfile.TemporaryDirectory() as tmpdir2_:
64+
tmpdir2 = Path(tmpdir2_)
65+
with zipfile.ZipFile(file, 'r') as zip_ref:
66+
zip_ref.extractall(tmpdir2)
67+
exe = list(tmpdir2.glob("**/bin/ninja"))
68+
assert len(exe) == 1, exe
69+
subprocess.run(["lipo", str(exe[0]), "-verify_arch", "x86_64", "arm64"], check=True, stdout=subprocess.PIPE)
70+
6171
# first, get the target macOS deployment target from the wheel
6272
match = re.match(r"^.*-macosx_(\d+)_(\d+)_.*\.whl$", file.name)
6373
assert match is not None, f"Couldn't match on {file.name}"

0 commit comments

Comments
 (0)