@@ -72,6 +72,7 @@ pub struct Config {
72
72
build_args : Vec < OsString > ,
73
73
cmake_target : Option < String > ,
74
74
env : Vec < ( OsString , OsString ) > ,
75
+ static_crt : Option < bool > ,
75
76
}
76
77
77
78
/// Builds the native library rooted at `path` with the default cmake options.
@@ -112,6 +113,7 @@ impl Config {
112
113
build_args : Vec :: new ( ) ,
113
114
cmake_target : None ,
114
115
env : Vec :: new ( ) ,
116
+ static_crt : None ,
115
117
}
116
118
}
117
119
@@ -191,6 +193,14 @@ impl Config {
191
193
self
192
194
}
193
195
196
+ /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
197
+ ///
198
+ /// This option defaults to `false`, and affect only msvc targets.
199
+ pub fn static_crt ( & mut self , static_crt : bool ) -> & mut Config {
200
+ self . static_crt = Some ( static_crt) ;
201
+ self
202
+ }
203
+
194
204
/// Add an argument to the final `cmake` build step
195
205
pub fn build_arg < A : AsRef < OsStr > > ( & mut self , arg : A ) -> & mut Config {
196
206
self . build_args . push ( arg. as_ref ( ) . to_owned ( ) ) ;
@@ -232,13 +242,15 @@ impl Config {
232
242
. debug ( false )
233
243
. target ( & target)
234
244
. host ( & host)
245
+ . static_crt ( self . static_crt . unwrap_or ( false ) )
235
246
. get_compiler ( ) ;
236
247
let cxx_compiler = gcc:: Config :: new ( ) . cargo_metadata ( false )
237
248
. cpp ( true )
238
249
. opt_level ( 0 )
239
250
. debug ( false )
240
251
. target ( & target)
241
252
. host ( & host)
253
+ . static_crt ( self . static_crt . unwrap_or ( false ) )
242
254
. get_compiler ( ) ;
243
255
244
256
let dst = self . out_dir . clone ( ) . unwrap_or_else ( || {
0 commit comments