fn main() {
if std::env::var("DOCS_RS") == Ok("1".to_string()) {
return;
}
let mut pkg_config = pkg_config::Config::new();
pkg_config.env_metadata(true);
match pkg_config.probe("libthemis") {
Ok(_) => {
}
Err(error) => {
eprintln!(
"
`libthemis-sys` could not find Themis installation in your system.
Please make sure you have appropriate development package installed.
On Linux it's called `libthemis-dev`, not just `libthemis`.
On macOS Homebrew formula is called `libthemis`.
Please refer to the documentation for installation instructions:
https://github.com/cossacklabs/themis#quickstart
This crate uses `pkg-config` to locate the library. If you use
non-standard installation of Themis then you can help pkg-config
to locate your library by setting the PKG_CONFIG_PATH environment
variable to the path where `libthemis.pc` file is located.
"
);
eprintln!("{}", error);
if try_system_themis() {
eprintln!(
"\
`libthemis-sys` tried using standard system paths and it seems that Themis
is available on your system. (However, pkg-config failed to find it.)
We will link against the system library.
"
);
} else {
eprintln!(
"\
`libthemis-sys` also tried to use standard system paths, but without success.
It seems that Themis is really not installed in your system.
"
);
panic!("Themis Core not installed");
}
}
}
}
fn try_system_themis() -> bool {
let mut build = cc::Build::new();
build.file("src/dummy.c");
build.flag("-lthemis");
let result = build.try_compile("dummy");
if result.is_ok() {
println!("cargo:rustc-link-lib=dylib=themis");
}
result.is_ok()
}