@@ -71,6 +71,7 @@ pub struct Config {
71
71
env : Vec < ( OsString , OsString ) > ,
72
72
static_crt : Option < bool > ,
73
73
uses_cxx11 : bool ,
74
+ always_configure : bool ,
74
75
}
75
76
76
77
/// Builds the native library rooted at `path` with the default cmake options.
@@ -112,7 +113,8 @@ impl Config {
112
113
cmake_target : None ,
113
114
env : Vec :: new ( ) ,
114
115
static_crt : None ,
115
- uses_cxx11 : false
116
+ uses_cxx11 : false ,
117
+ always_configure : true ,
116
118
}
117
119
}
118
120
@@ -234,6 +236,15 @@ impl Config {
234
236
self
235
237
}
236
238
239
+ /// Forces CMake to always run before building the custom target.
240
+ ///
241
+ /// In some cases, when you have a big project, you can disable
242
+ /// subsequents runs of cmake to make `cargo build` faster.
243
+ pub fn always_configure ( & mut self , always_configure : bool ) -> & mut Config {
244
+ self . always_configure = always_configure;
245
+ self
246
+ }
247
+
237
248
/// Run this configuration, compiling the library with all the configured
238
249
/// options.
239
250
///
@@ -496,7 +507,10 @@ impl Config {
496
507
cmd. env ( k, v) ;
497
508
}
498
509
499
- run ( cmd. env ( "CMAKE_PREFIX_PATH" , cmake_prefix_path) , "cmake" ) ;
510
+ if self . always_configure || !build. join ( "CMakeCache.txt" ) . exists ( ) {
511
+ println ! ( "CMake project was already configured. Skipping configuration step." ) ;
512
+ run ( cmd. env ( "CMAKE_PREFIX_PATH" , cmake_prefix_path) , "cmake" ) ;
513
+ }
500
514
501
515
let mut makeflags = None ;
502
516
let mut parallel_args = Vec :: new ( ) ;
0 commit comments