diff --git a/src/lib.rs b/src/lib.rs index 428b6f9c1..346aaaca0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1587,20 +1587,6 @@ impl Build { ToolFamily::Msvc { .. } => { cmd.push_cc_arg("-nologo".into()); - let crt_flag = match self.static_crt { - Some(true) => "-MT", - Some(false) => "-MD", - None => { - let features = self - .getenv("CARGO_CFG_TARGET_FEATURE") - .unwrap_or(String::new()); - if features.contains("crt-static") { - "-MT" - } else { - "-MD" - } - } - }; cmd.push_cc_arg(crt_flag.into()); match &opt_level[..] { @@ -1649,6 +1635,23 @@ impl Build { } } + if target.contains("msvc") { + let crt_flag = match self.static_crt { + Some(true) => "-MT", + Some(false) => "-MD", + None => { + let features = self + .getenv("CARGO_CFG_TARGET_FEATURE") + .unwrap_or(String::new()); + if features.contains("crt-static") { + "-MT" + } else { + "-MD" + } + } + }; + } + if self.get_debug() { if self.cuda { // NVCC debug flag