From 02258841274d0e954e2f0101dffbe3e51f5c2209 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 18 Aug 2015 10:23:03 -0700 Subject: 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. --- libssh2-sys/build.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'libssh2-sys/build.rs') 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()); +} -- cgit v1.2.3