@@ -293,7 +293,6 @@ fn patch_sdl2(sdl2_source_path: &Path) {
293
293
#[ cfg( feature = "bundled" ) ]
294
294
fn compile_sdl2 ( sdl2_build_path : & Path , target_os : & str ) -> PathBuf {
295
295
let mut cfg = cmake:: Config :: new ( sdl2_build_path) ;
296
- cfg. profile ( "release" ) ;
297
296
298
297
// Override __FLTUSED__ to keep the _fltused symbol from getting defined in the static build.
299
298
// This conflicts and fails to link properly when building statically on Windows, likely due to
@@ -411,11 +410,24 @@ fn link_sdl2(target_os: &str) {
411
410
412
411
#[ cfg( feature = "static-link" ) ]
413
412
{
413
+ // There's no way to extract this from `cmake::Config` so we have to emulate their
414
+ // behaviour here (see the source for `cmake::Config::build`).
415
+ let debug_postfix = match (
416
+ & env:: var ( "OPT_LEVEL" ) . unwrap_or_default ( ) [ ..] ,
417
+ & env:: var ( "PROFILE" ) . unwrap_or_default ( ) [ ..] ,
418
+ ) {
419
+ ( "1" , _) | ( "2" , _) | ( "3" , _) | ( "s" , _) | ( "z" , _) => "" ,
420
+ ( "0" , _) => "d" ,
421
+ ( _, "debug" ) => "d" ,
422
+ // ("0", _) => "",
423
+ // (_, "debug") => "",
424
+ ( _, _) => "" ,
425
+ } ;
414
426
if cfg ! ( feature = "bundled" )
415
427
|| ( cfg ! ( feature = "use-pkgconfig" ) == false && cfg ! ( feature = "use-vcpkg" ) == false )
416
428
{
417
- println ! ( "cargo:rustc-link-lib=static=SDL2main" ) ;
418
- println ! ( "cargo:rustc-link-lib=static=SDL2" ) ;
429
+ println ! ( "cargo:rustc-link-lib=static=SDL2main{}" , debug_postfix ) ;
430
+ println ! ( "cargo:rustc-link-lib=static=SDL2{}" , debug_postfix ) ;
419
431
}
420
432
421
433
// Also linked to any required libraries for each supported platform
0 commit comments