use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-env-changed=COINHSL_DIR");
let Ok(coinhsl_dir) = env::var("COINHSL_DIR").map(PathBuf::from) else {
println!(
"cargo:warning=COINHSL_DIR not set; pounce-hsl compiled without link directives. \
Selecting the `ma57` feature in a downstream crate without setting COINHSL_DIR will \
fail at link time. Build CoinHSL from https://www.hsl.rl.ac.uk/ipopt/ and set \
COINHSL_DIR to its install root to enable MA57."
);
return;
};
let lib_dir = coinhsl_dir.join("lib");
assert!(
lib_dir.is_dir(),
"COINHSL lib directory not found: {}",
lib_dir.display(),
);
let Some(lib_dir_str) = lib_dir.to_str() else {
panic!("COINHSL lib path is not valid UTF-8: {}", lib_dir.display());
};
println!("cargo:rustc-link-search=native={lib_dir_str}");
println!("cargo:rustc-link-lib=dylib=coinhsl");
println!("cargo:rustc-link-lib=dylib=openblas");
println!("cargo:rustc-link-arg=-Wl,-rpath,{lib_dir_str}");
}