sfml_build/
lib.rs

1use std::env::var;
2
3// Add search path for CSFML library files
4pub fn link_csfml(lib_name: &str) {
5    // Figure out the path to libraries within the CSFML base folder
6    // based on the operating system
7    let lib_path = if std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap() == "windows" {
8        if std::env::var("CARGO_CFG_TARGET_ENV").unwrap() == "msvc" {
9            "lib/msvc"
10        } else {
11            "lib/gcc"
12        }
13    } else {
14        "lib"
15    };
16
17    // CSFML_HOME points to the base CSFML directory
18    // Let cargo find the CSFML library files there
19    if let Ok(csfml_home) = var("CSFML_HOME") {
20        let search_path = format!("{}/{}", csfml_home, lib_path);
21        println!("cargo:warning=CSFML search path is {}", search_path);
22        println!("cargo:rustc-link-search=native={}", search_path);
23    }
24
25    // Link to the csfml library
26    println!("cargo:rustc-link-lib=csfml-{}", lib_name);
27}