@@ -70,6 +70,7 @@ pub struct Config {
70
70
cmake_target : Option < String > ,
71
71
env : Vec < ( OsString , OsString ) > ,
72
72
static_crt : Option < bool > ,
73
+ uses_cxx11 : bool ,
73
74
}
74
75
75
76
/// Builds the native library rooted at `path` with the default cmake options.
@@ -111,6 +112,7 @@ impl Config {
111
112
cmake_target : None ,
112
113
env : Vec :: new ( ) ,
113
114
static_crt : None ,
115
+ uses_cxx11 : false
114
116
}
115
117
}
116
118
@@ -221,15 +223,33 @@ impl Config {
221
223
self
222
224
}
223
225
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
+
224
237
/// Run this configuration, compiling the library with all the configured
225
238
/// options.
226
239
///
227
240
/// This will run both the build system generator command as well as the
228
241
/// command to build the library.
229
242
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
+ } ;
233
253
let host = self . host . clone ( ) . unwrap_or_else ( || {
234
254
getenv_unwrap ( "HOST" )
235
255
} ) ;
0 commit comments