Skip to content

Commit 294fd67

Browse files
Try to fix MSVC build (at least on Release)
1 parent d5f6071 commit 294fd67

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

build.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ fn main() {
6060
let feat_window = env::var("CARGO_FEATURE_WINDOW").is_ok();
6161
let feat_graphics = env::var("CARGO_FEATURE_GRAPHICS").is_ok();
6262
let mut cmake = cmake::Config::new("SFML");
63+
let cmake_debug = cmake.get_profile() == "Debug";
64+
let msvc_rt = if cmake_debug {
65+
"MultiThreadedDebug"
66+
} else {
67+
"MultiThreaded"
68+
};
6369
cmake
70+
.define("CMAKE_MSVC_RUNTIME_LIBRARY", msvc_rt)
71+
.define("SFML_USE_STATIC_STD_LIBS", "TRUE")
6472
.define("BUILD_SHARED_LIBS", "FALSE")
6573
.define("SFML_BUILD_NETWORK", "FALSE")
6674
.define("SFML_INSTALL_PKGCONFIG_FILES", "FALSE")
@@ -159,10 +167,9 @@ fn main() {
159167
let is_linux = env::var("CARGO_CFG_TARGET_OS")
160168
.map(|os| os == "linux")
161169
.unwrap_or(false);
162-
let debug = cmake.get_profile() == "Debug";
163170
// I have no idea why this is different on Windows and Linux
164171
let link_search = if is_windows {
165-
if debug {
172+
if cmake_debug {
166173
"build/lib/Debug"
167174
} else {
168175
"build/lib/Release"
@@ -175,20 +182,20 @@ fn main() {
175182
path.join(link_search).display()
176183
);
177184
println!("cargo:rustc-link-lib=static=rcsfml");
178-
link_sfml_subsystem("system", debug);
185+
link_sfml_subsystem("system", cmake_debug);
179186
if is_unix && is_linux {
180187
static_link_linux(feat_window, feat_audio, feat_graphics);
181188
} else if is_windows {
182189
static_link_windows(feat_window, feat_audio, feat_graphics);
183190
}
184191
if feat_audio {
185-
link_sfml_subsystem("audio", debug);
192+
link_sfml_subsystem("audio", cmake_debug);
186193
}
187194
if feat_window {
188-
link_sfml_subsystem("window", debug);
195+
link_sfml_subsystem("window", cmake_debug);
189196
}
190197
if feat_graphics {
191-
link_sfml_subsystem("graphics", debug);
198+
link_sfml_subsystem("graphics", cmake_debug);
192199
}
193200
}
194201

0 commit comments

Comments
 (0)