@@ -70,6 +70,7 @@ pub struct Config {
7070 cmake_target : Option < String > ,
7171 env : Vec < ( OsString , OsString ) > ,
7272 static_crt : Option < bool > ,
73+ uses_cxx11 : bool ,
7374}
7475
7576/// Builds the native library rooted at `path` with the default cmake options.
@@ -111,6 +112,7 @@ impl Config {
111112 cmake_target : None ,
112113 env : Vec :: new ( ) ,
113114 static_crt : None ,
115+ uses_cxx11 : false
114116 }
115117 }
116118
@@ -221,15 +223,33 @@ impl Config {
221223 self
222224 }
223225
226+ /// Alters the default target triple on OSX to ensure that c++11 is
227+ /// available. Does not change the target triple if it is explicitly
228+ /// specified.
229+ ///
230+ /// This does not otherwise affect any CXX flags, i.e. it does not set
231+ /// -std=c++11 or -stdlib=libc++.
232+ pub fn uses_cxx11 ( & mut self ) -> & mut Config {
233+ self . uses_cxx11 = true ;
234+ self
235+ }
236+
224237 /// Run this configuration, compiling the library with all the configured
225238 /// options.
226239 ///
227240 /// This will run both the build system generator command as well as the
228241 /// command to build the library.
229242 pub fn build ( & mut self ) -> PathBuf {
230- let target = self . target . clone ( ) . unwrap_or_else ( || {
231- getenv_unwrap ( "TARGET" )
232- } ) ;
243+ let target = match self . target . clone ( ) {
244+ Some ( t) => t,
245+ None => {
246+ let mut t = getenv_unwrap ( "TARGET" ) ;
247+ if t. ends_with ( "-darwin" ) && self . uses_cxx11 {
248+ t = t + "11"
249+ }
250+ t
251+ }
252+ } ;
233253 let host = self . host . clone ( ) . unwrap_or_else ( || {
234254 getenv_unwrap ( "HOST" )
235255 } ) ;
0 commit comments