Skip to content

Commit 3272fe0

Browse files
committed
Added x86 toolset fix for Visual Studio 2019
1 parent b3900d9 commit 3272fe0

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/lib.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,25 @@ impl Config {
413413
} else {
414414
using_nmake_generator = self.generator.as_ref().unwrap() == "NMake Makefiles";
415415
}
416-
if target.contains("x86_64") && !is_ninja && !using_nmake_generator {
417-
cmd.arg("-Thost=x64");
418-
cmd.arg("-DCMAKE_GENERATOR_PLATFORM=x64");
416+
if !is_ninja && !using_nmake_generator {
417+
if target.contains("x86_64") {
418+
cmd.arg("-Thost=x64");
419+
cmd.arg("-Ax64");
420+
} else if target.contains("i686") {
421+
use cc::windows_registry::{find_vs_version, VsVers};
422+
match find_vs_version() {
423+
Ok(VsVers::Vs16) => {
424+
// 32-bit x86 toolset used to be the default for all hosts,
425+
// but Visual Studio 2019 changed the default toolset to match the host,
426+
// so we need to manually override it for x86 targets
427+
cmd.arg("-Thost=x86");
428+
cmd.arg("-AWin32");
429+
}
430+
_ => {}
431+
};
432+
} else {
433+
panic!("unsupported msvc target: {}", target);
434+
}
419435
}
420436
} else if target.contains("redox") {
421437
if !self.defined("CMAKE_SYSTEM_NAME") {

0 commit comments

Comments
 (0)