@@ -57,6 +57,7 @@ use std::process::Command;
57
57
/// Builder style configuration for a pending CMake build.
58
58
pub struct Config {
59
59
path : PathBuf ,
60
+ generator : Option < OsString > ,
60
61
cflags : OsString ,
61
62
defines : Vec < ( OsString , OsString ) > ,
62
63
deps : Vec < String > ,
@@ -94,6 +95,7 @@ impl Config {
94
95
pub fn new < P : AsRef < Path > > ( path : P ) -> Config {
95
96
Config {
96
97
path : env:: current_dir ( ) . unwrap ( ) . join ( path) ,
98
+ generator : None ,
97
99
cflags : OsString :: new ( ) ,
98
100
defines : Vec :: new ( ) ,
99
101
deps : Vec :: new ( ) ,
@@ -106,6 +108,12 @@ impl Config {
106
108
}
107
109
}
108
110
111
+ /// Sets the build-tool generator (`-G`) for this compilation.
112
+ pub fn generator < T : AsRef < OsStr > > ( & mut self , generator : T ) -> & mut Config {
113
+ self . generator = Some ( generator. as_ref ( ) . to_owned ( ) ) ;
114
+ self
115
+ }
116
+
109
117
/// Adds a custom flag to pass down to the compiler, supplementing those
110
118
/// that this library already passes.
111
119
pub fn cflag < P : AsRef < OsStr > > ( & mut self , flag : P ) -> & mut Config {
@@ -237,7 +245,9 @@ impl Config {
237
245
// On MinGW we need to coerce cmake to not generate a visual
238
246
// studio build system but instead use makefiles that MinGW can
239
247
// use to build.
240
- cmd. arg ( "-G" ) . arg ( "MSYS Makefiles" ) ;
248
+ if self . generator . is_none ( ) {
249
+ cmd. arg ( "-G" ) . arg ( "MSYS Makefiles" ) ;
250
+ }
241
251
} else {
242
252
// If we're cross compiling onto windows, then set some
243
253
// variables which will hopefully get things to succeed. Some
@@ -262,7 +272,12 @@ impl Config {
262
272
} else if msvc {
263
273
// If we're on MSVC we need to be sure to use the right generator or
264
274
// otherwise we won't get 32/64 bit correct automatically.
265
- cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
275
+ if self . generator . is_none ( ) {
276
+ cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
277
+ }
278
+ }
279
+ if let Some ( ref generator) = self . generator {
280
+ cmd. arg ( "-G" ) . arg ( generator) ;
266
281
}
267
282
let profile = self . profile . clone ( ) . unwrap_or_else ( || {
268
283
match & getenv_unwrap ( "PROFILE" ) [ ..] {
0 commit comments