-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
31 lines (27 loc) · 948 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extern crate pkg_config;
fn main() {
let lib = "geos_c";
if std::env::var("CARGO_FEATURE_STATIC").is_ok() {
let geos_path = std::env::var("DEP_GEOSSRC_SEARCH").unwrap();
println!("cargo:rustc-link-lib=static=geos_c");
println!("cargo:rustc-link-lib=static=geos");
println!("cargo:rustc-link-search=native={}", geos_path);
println!("cargo:includedir={}/include", geos_path)
} else {
match pkg_config::Config::new().probe(lib) {
Ok(_) => {}
Err(_) => {
println!("cargo:rustc-link-lib=dylib={}", lib);
}
}
}
// TODO: handle library versions like this!
//
// pkg_config::probe_library("geos_c")
// .map(|lib| {
// if lib.version.starts_with("2.") {
// println!(r#"cargo:rustc-cfg=feature="v2""#);
// }
// })
// .expect("GEOS library not found");
}