Skip to content

Commit 893b30a

Browse files
committed
Add iOS checks to build.rs
This adds some basic checks for iOS and passes them along to CMake to build SDL properly. I'm not sure why CMake can't figure this out, but this works!
1 parent ffc7392 commit 893b30a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

build.rs

+12
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ fn main() {
6666
if arch == "aarch64" {
6767
cm.define("CMAKE_OSX_ARCHITECTURES", "arm64");
6868
}
69+
70+
// When building against the iOS SDK, we need to tell CMake as much
71+
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "ios" {
72+
cm.define("CMAKE_SYSTEM_NAME", "iOS");
73+
if arch == "aarch64" {
74+
// All shipping iPhones are a 64-bit arm target
75+
cm.define("CMAKE_OSX_SYSROOT", "iphoneos");
76+
} else if arch == "x86_64" {
77+
// The iPhone Simulator is an x86_64 target (TODO: Even on M1 macs?)
78+
cm.define("CMAKE_OSX_SYSROOT", "iphonesimulator");
79+
}
80+
}
6981
}
7082

7183
cm.profile("Release");

0 commit comments

Comments
 (0)