From 3479ed60b20acadbfe7c59b063efbdd5a8716e4c Mon Sep 17 00:00:00 2001 From: Justin Karneges Date: Tue, 9 Jan 2024 13:43:19 -0800 Subject: [PATCH] add BOOST_INCLUDE_DIR build option --- build.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 598fdfc6..d2cea2a1 100644 --- a/build.rs +++ b/build.rs @@ -116,7 +116,7 @@ fn write_postbuild_conf_pri( Ok(()) } -fn get_boost_path() -> Result> { +fn find_boost_include_dir() -> Result> { let possible_paths = vec!["/usr/local/include", "/usr/include"]; let boost_version = "boost/version.hpp"; @@ -204,8 +204,6 @@ fn main() -> Result<(), Box> { check_version("qt", &qt_version, 5, 12)?; - let boost_path = get_boost_path()?; - let qt_install_libs = { let output = Command::new(&qmake_path) .args(["-query", "QT_INSTALL_LIBS"]) @@ -218,6 +216,12 @@ fn main() -> Result<(), Box> { .map_err(|_| format!("QT_INSTALL_LIBS dir {} not found", libs_dir.display()))? }; + let boost_include_dir = match env::var("BOOST_INCLUDE_DIR") { + Ok(s) => PathBuf::from(s), + Err(env::VarError::NotPresent) => find_boost_include_dir()?, + Err(env::VarError::NotUnicode(_)) => return Err("BOOST_INCLUDE_DIR not unicode".into()), + }; + let default_vars = { let prefix = match env::var("PREFIX") { Ok(s) => Some(s), @@ -253,8 +257,8 @@ fn main() -> Result<(), Box> { include_paths.push(out_dir.as_ref()); - if boost_path != Path::new("/usr/include") { - include_paths.push(boost_path.as_ref()); + if boost_include_dir != Path::new("/usr/include") { + include_paths.push(boost_include_dir.as_ref()); } write_cpp_conf_pri(