Skip to content

Commit

Permalink
Merge pull request #47872 from fastly/jkarneges/boost-include-dir
Browse files Browse the repository at this point in the history
add BOOST_INCLUDE_DIR build option
  • Loading branch information
jkarneges authored Jan 9, 2024
2 parents b821a6d + 3479ed6 commit afeac5a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn write_postbuild_conf_pri(
Ok(())
}

fn get_boost_path() -> Result<PathBuf, Box<dyn Error>> {
fn find_boost_include_dir() -> Result<PathBuf, Box<dyn Error>> {
let possible_paths = vec!["/usr/local/include", "/usr/include"];
let boost_version = "boost/version.hpp";

Expand Down Expand Up @@ -204,8 +204,6 @@ fn main() -> Result<(), Box<dyn Error>> {

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"])
Expand All @@ -218,6 +216,12 @@ fn main() -> Result<(), Box<dyn Error>> {
.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),
Expand Down Expand Up @@ -253,8 +257,8 @@ fn main() -> Result<(), Box<dyn Error>> {

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(
Expand Down

0 comments on commit afeac5a

Please sign in to comment.