Skip to content

Commit 532ee7e

Browse files
committed
fix build on modern MacOS systems
apple switched c++ stdlibs to support c++1z features, and deprecated the old one. the ways that interacts with cmake are vast and unknowable. apparently they haven't gotten around to fixing that yet, which affects libui's cmake-based build toolchain. what this patch does is essentially just force the new stdlib on apple systems. i don't think this will cause issues with old (ie, pre-Sierra) macos versions, but perhaps further testing would be helpful. at any rate, it fixes a problem that was basically blocking anyone on a modern macos install from using libui-rs, which is nice.
1 parent 89f97b5 commit 532ee7e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ui-sys/build.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ fn main() {
4242
.write_to_file(out_path.join("bindings.rs"))
4343
.expect("Couldn't write bindings");
4444

45-
// Deterimine if we're building for MSVC
45+
// Deterimine build platform
4646
let target = env::var("TARGET").unwrap();
4747
let msvc = target.contains("msvc");
48+
let apple = target.contains("apple");
49+
4850
// Build libui if needed. Otherwise, assume it's in lib/
4951
let mut dst;
5052
if cfg!(feature = "build") {
51-
dst = Config::new("libui").build_target("").profile("release").build();
53+
let mut cfg = Config::new("libui");
54+
cfg.build_target("").profile("release");
55+
if apple {
56+
cfg.cxxflag("--stdlib=libc++");
57+
}
58+
dst = cfg.build();
5259

5360
let mut postfix = Path::new("build").join("out");
5461
if msvc {
@@ -62,7 +69,7 @@ fn main() {
6269
}
6370

6471
let libname;
65-
if msvc {
72+
if msvc {
6673
libname = "libui";
6774
} else {
6875
libname = "ui";

0 commit comments

Comments
 (0)