Browse Source

Merge pull request #311 from tomaka/cxxstdlib

Allow overwriting the default cpp_link_stdlib
cl-test
Alex Crichton 7 years ago
committed by GitHub
parent
commit
a4790a6255
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      src/lib.rs

30
src/lib.rs

@ -582,6 +582,8 @@ impl Build {
/// The default value of this property depends on the current target: On /// The default value of this property depends on the current target: On
/// OS X `Some("c++")` is used, when compiling for a Visual Studio based /// OS X `Some("c++")` is used, when compiling for a Visual Studio based
/// target `None` is used and for other targets `Some("stdc++")` is used. /// target `None` is used and for other targets `Some("stdc++")` is used.
/// If the `CXXSTDLIB` environment variable is set, its value will
/// override the default value.
/// ///
/// A value of `None` indicates that no automatic linking should happen, /// A value of `None` indicates that no automatic linking should happen,
/// otherwise cargo will link against the specified library. /// otherwise cargo will link against the specified library.
@ -1716,17 +1718,25 @@ impl Build {
match self.cpp_link_stdlib.clone() { match self.cpp_link_stdlib.clone() {
Some(s) => Ok(s), Some(s) => Ok(s),
None => { None => {
let target = self.get_target()?; if let Ok(stdlib) = self.get_var("CXXSTDLIB") {
if target.contains("msvc") { if stdlib.is_empty() {
Ok(None) Ok(None)
} else if target.contains("apple") { } else {
Ok(Some("c++".to_string())) Ok(Some(stdlib))
} else if target.contains("freebsd") { }
Ok(Some("c++".to_string()))
} else if target.contains("openbsd") {
Ok(Some("c++".to_string()))
} else { } else {
Ok(Some("stdc++".to_string())) let target = self.get_target()?;
if target.contains("msvc") {
Ok(None)
} else if target.contains("apple") {
Ok(Some("c++".to_string()))
} else if target.contains("freebsd") {
Ok(Some("c++".to_string()))
} else if target.contains("openbsd") {
Ok(Some("c++".to_string()))
} else {
Ok(Some("stdc++".to_string()))
}
} }
} }
} }

Loading…
Cancel
Save