build/python/cmake: set CMAKE_OSX_SYSROOT on macOS
This commit is contained in:
parent
f8cfeb39e9
commit
d105985d78
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from build.project import Project
|
from build.project import Project
|
||||||
|
@ -31,6 +32,26 @@ set(CMAKE_CXX_FLAGS "{toolchain.cxxflags} {toolchain.cppflags}")
|
||||||
__write_cmake_compiler(f, 'C', toolchain.cc)
|
__write_cmake_compiler(f, 'C', toolchain.cc)
|
||||||
__write_cmake_compiler(f, 'CXX', toolchain.cxx)
|
__write_cmake_compiler(f, 'CXX', toolchain.cxx)
|
||||||
|
|
||||||
|
if cmake_system_name == 'Darwin':
|
||||||
|
# On macOS, cmake forcibly adds an "-isysroot" flag even if
|
||||||
|
# one is already present in the flags variable; this breaks
|
||||||
|
# cross-compiling for iOS, and can be worked around by setting
|
||||||
|
# the CMAKE_OSX_SYSROOT variable
|
||||||
|
# (https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html).
|
||||||
|
m = re.search(r'-isysroot +(\S+)', toolchain.cflags)
|
||||||
|
if m:
|
||||||
|
sysroot = m.group(1)
|
||||||
|
|
||||||
|
print(f'set(CMAKE_OSX_SYSROOT {sysroot})', file=f)
|
||||||
|
|
||||||
|
# search libraries and headers only in the sysroot, not on
|
||||||
|
# the build host
|
||||||
|
f.write(f"""
|
||||||
|
set(CMAKE_FIND_ROOT_PATH "{toolchain.install_prefix};{sysroot}")
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
""")
|
||||||
|
|
||||||
def configure(toolchain, src, build, args=(), env=None):
|
def configure(toolchain, src, build, args=(), env=None):
|
||||||
cross_args = []
|
cross_args = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue