Skip to content

Commit e7d2cd8

Browse files
Merge cross compile support from cmake_example
1 parent 15156d1 commit e7d2cd8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import os
3+
import re
34
import sys
45
import subprocess
56

@@ -49,6 +50,12 @@ def build_extension(self, ext):
4950
]
5051
build_args += ["--config", cfg]
5152

53+
if sys.platform.startswith("darwin"):
54+
# Cross-compile support for macOS - respect ARCHFLAGS if set
55+
archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
56+
if archs:
57+
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
58+
5259
# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
5360
# across all generators.
5461
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:

0 commit comments

Comments
 (0)