diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-08-18 10:23:03 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-08-18 10:23:03 -0700 |
commit | 02258841274d0e954e2f0101dffbe3e51f5c2209 (patch) | |
tree | 25592e7aef73cdae51e12c93cdf3bbd7d327814a /libssh2-sys | |
parent | b5f4a0e03a4b2886b4d10d5f372209fd2a645a27 (diff) | |
download | ssh2-rs-02258841274d0e954e2f0101dffbe3e51f5c2209.zip |
Add back logic for PKG_CONFIG_PATH
Some CMake invocations will attempt to find libraries like OpenSSL through
pkg-config and these may have been built into a custom location, so be sure to
set up PKG_CONFIG_PATH to point to them.
Diffstat (limited to 'libssh2-sys')
-rw-r--r-- | libssh2-sys/build.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libssh2-sys/build.rs b/libssh2-sys/build.rs index 1af465d..26938c3 100644 --- a/libssh2-sys/build.rs +++ b/libssh2-sys/build.rs @@ -4,9 +4,12 @@ extern crate cmake; use std::env; use std::fs::File; use std::io::prelude::*; -use std::path::PathBuf; +use std::path::{PathBuf, Path}; fn main() { + register_dep("Z"); + register_dep("OPENSSL"); + if let Ok(lib) = pkg_config::find_library("libssh2") { for path in &lib.include_paths { println!("cargo:include={}", path.display()); @@ -85,3 +88,19 @@ fn main() { println!("cargo:rustc-link-search=native={}/lib", dst.display()); println!("cargo:include={}/include", dst.display()); } + +fn register_dep(dep: &str) { + match env::var(&format!("DEP_{}_ROOT", dep)) { + Ok(s) => { + prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); + } + Err(..) => {} + } +} + +fn prepend(var: &str, val: PathBuf) { + let prefix = env::var(var).unwrap_or(String::new()); + let mut v = vec![val]; + v.extend(env::split_paths(&prefix)); + env::set_var(var, &env::join_paths(v).unwrap()); +} |