Skip to content

Commit ee79753

Browse files
Always build SFML with Release CMake profile
See rust-lang/cc-rs#1230 for context
1 parent 678d69a commit ee79753

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

build.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,11 @@ fn main() {
7777
let feat_window = env::var("CARGO_FEATURE_WINDOW").is_ok();
7878
let feat_graphics = env::var("CARGO_FEATURE_GRAPHICS").is_ok();
7979
let mut cmake = cmake::Config::new("SFML");
80-
let cmake_debug = cmake.get_profile() == "Debug";
81-
let msvc_rt = if cmake_debug {
82-
"MultiThreadedDebug"
83-
} else {
84-
"MultiThreaded"
85-
};
80+
// Due to complications with static linking of MSVC runtime (debug version),
81+
// we cannot support debug builds of SFML.
82+
cmake.profile("Release");
8683
cmake
87-
.define("CMAKE_MSVC_RUNTIME_LIBRARY", msvc_rt)
84+
.define("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreaded")
8885
.define("SFML_USE_STATIC_STD_LIBS", "TRUE")
8986
.define("BUILD_SHARED_LIBS", "FALSE")
9087
.define("SFML_BUILD_NETWORK", "FALSE")
@@ -187,11 +184,7 @@ fn main() {
187184
// I have no idea why this is different on Windows and Linux
188185
let win_env = WinEnv::get();
189186
let link_search = if matches!(win_env, Some(WinEnv::Msvc)) {
190-
if cmake_debug {
191-
"build/lib/Debug"
192-
} else {
193-
"build/lib/Release"
194-
}
187+
"build/lib/Release"
195188
} else {
196189
"build/lib"
197190
};
@@ -200,7 +193,7 @@ fn main() {
200193
path.join(link_search).display()
201194
);
202195
println!("cargo:rustc-link-lib=static=rcsfml");
203-
link_sfml_subsystem("system", cmake_debug);
196+
link_sfml_subsystem("system");
204197
if is_unix && is_linux {
205198
static_link_linux(feat_window, feat_audio, feat_graphics);
206199
} else if is_windows {
@@ -214,17 +207,16 @@ fn main() {
214207
}
215208
}
216209
if feat_audio {
217-
link_sfml_subsystem("audio", cmake_debug);
210+
link_sfml_subsystem("audio");
218211
}
219212
if feat_window {
220-
link_sfml_subsystem("window", cmake_debug);
213+
link_sfml_subsystem("window");
221214
}
222215
if feat_graphics {
223-
link_sfml_subsystem("graphics", cmake_debug);
216+
link_sfml_subsystem("graphics");
224217
}
225218
}
226219

227-
fn link_sfml_subsystem(name: &str, debug: bool) {
228-
let suffix = if debug { "-d" } else { "" };
229-
println!("cargo:rustc-link-lib=static=sfml-{name}-s{suffix}");
220+
fn link_sfml_subsystem(name: &str) {
221+
println!("cargo:rustc-link-lib=static=sfml-{name}-s");
230222
}

0 commit comments

Comments
 (0)