Skip to content

Commit 0188766

Browse files
committed
Explicitly set static crt
1 parent d67e6ac commit 0188766

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ A build dependency for running `cmake` to build a native library
1414
"""
1515

1616
[dependencies]
17-
gcc = "0.3.17"
17+
gcc = "0.3.46"

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub struct Config {
7272
build_args: Vec<OsString>,
7373
cmake_target: Option<String>,
7474
env: Vec<(OsString, OsString)>,
75+
static_crt: Option<bool>,
7576
}
7677

7778
/// Builds the native library rooted at `path` with the default cmake options.
@@ -112,6 +113,7 @@ impl Config {
112113
build_args: Vec::new(),
113114
cmake_target: None,
114115
env: Vec::new(),
116+
static_crt: None,
115117
}
116118
}
117119

@@ -191,6 +193,14 @@ impl Config {
191193
self
192194
}
193195

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+
194204
/// Add an argument to the final `cmake` build step
195205
pub fn build_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut Config {
196206
self.build_args.push(arg.as_ref().to_owned());
@@ -232,13 +242,15 @@ impl Config {
232242
.debug(false)
233243
.target(&target)
234244
.host(&host)
245+
.static_crt(self.static_crt.unwrap_or(false))
235246
.get_compiler();
236247
let cxx_compiler = gcc::Config::new().cargo_metadata(false)
237248
.cpp(true)
238249
.opt_level(0)
239250
.debug(false)
240251
.target(&target)
241252
.host(&host)
253+
.static_crt(self.static_crt.unwrap_or(false))
242254
.get_compiler();
243255

244256
let dst = self.out_dir.clone().unwrap_or_else(|| {

0 commit comments

Comments
 (0)