Skip to content

Commit

Permalink
Fix for 'windows-gcc' target
Browse files Browse the repository at this point in the history
  • Loading branch information
manpat authored and Cobrand committed Mar 31, 2018
1 parent 162441b commit 58d6e17
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions sdl2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ fn download_sdl2() -> PathBuf {

// compile a shared or static lib depending on the feature
#[cfg(feature = "bundled")]
fn compile_sdl2(sdl2_build_path: &Path) -> PathBuf {
let install_path = if cfg!(feature = "static-link") {
cmake::Config::new(sdl2_build_path)
.define("SDL_SHARED", "OFF")
.define("SDL_STATIC", "ON")
.build()
fn compile_sdl2(sdl2_build_path: &Path, target_os: &str) -> PathBuf {
let mut cfg = cmake::Config::new(sdl2_build_path);

if target_os == "windows-gnu" {
cfg.define("VIDEO_OPENGLES", "OFF");
}

if cfg!(feature = "static-link") {
cfg.define("SDL_SHARED", "OFF");
cfg.define("SDL_STATIC", "ON");
} else {
cmake::Config::new(sdl2_build_path)
.define("SDL_SHARED", "ON")
.define("SDL_STATIC", "OFF")
.build()
};
cfg.define("SDL_SHARED", "ON");
cfg.define("SDL_STATIC", "OFF");
}

install_path
cfg.build()
}

#[cfg(not(feature = "bundled"))]
Expand Down Expand Up @@ -168,7 +170,7 @@ fn link_sdl2(target_os: &str) {
}

// Also linked to any required libraries for each supported platform
if target_os == "windows-msvc" {
if target_os.contains("windows") {
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=gdi32");
println!("cargo:rustc-link-lib=winmm");
Expand Down Expand Up @@ -203,7 +205,7 @@ fn main() {

#[cfg(feature = "bundled")] {
let sdl2_source_path = download_sdl2();
let sdl2_compiled_path = compile_sdl2(sdl2_source_path.as_path());
let sdl2_compiled_path = compile_sdl2(sdl2_source_path.as_path(), target_os);

let sdl2_downloaded_include_path = sdl2_source_path.join("include");
let sdl2_compiled_lib_path = sdl2_compiled_path.join("lib");
Expand Down

0 comments on commit 58d6e17

Please sign in to comment.