fn main() { // for Apple Mac M1 // use brew to install // brew install boost // brew install open-babel // brew install sqlite // // export RECGEN_LIB=/opt/homebrew/lib/:/opt/homebrew/sqlite/lib // export RECGEN_INCL=/opt/homebrew/include:/opt/homebrew/include/openbabel3:/opt/homebrew/opt/sqlite/include // for Mac OS x86_64 // use conda to install // conda install -c conda-forge boost-cpp // conda install -c anaconda sqlite // conda install -c conda-forge openbabel // // # export RECGEN_LIB=~/miniconda3/envs/openbabel/lib // # export RECGEN_INCL=~/miniconda3/envs/openbabel/include:~/miniconda3/envs/openbabel/include/openbabel3 // for Ubuntu, use apt // sudo apt-get install -y libboost-all-dev libsqlite3-dev libopenbabel-dev // export RECGEN_INCL=/usr/include:/usr/include/openbabel3 // export RECGEN_LIB=/usr/lib/x86_64-linux-gnu let recgen_incl_o = std::env::var_os("RECGEN_INCL"); if recgen_incl_o.is_none() { println!("cargo:warning={}", "Set environment variable RECGEN_INCL for header files first"); return; } let recgen_incl_raw = recgen_incl_o.unwrap().into_string().unwrap(); let recgen_incls = recgen_incl_raw.split(":"); let recgen_lib_o = std::env::var_os("RECGEN_LIB"); if recgen_lib_o.is_none() { println!("cargo:warning={}", "Set environment variable RECGEN_LIB for libraries first"); return; } let recgen_lib_raw = recgen_lib_o.unwrap().into_string().unwrap(); let recgen_libs = recgen_lib_raw.split(":"); cxx_build::bridge("src/lib.rs") .file("deps/ReCGen/src/WrapSQLite.cpp") .file("deps/ReCGen/src/ECMol.cpp") .file("deps/ReCGen/src/Overlap.cpp") .file("deps/ReCGen/src/Unit.cpp") .file("deps/ReCGen/src/Frame.cpp") .file("deps/ReCGen/src/BBMol.cpp") .file("deps/ReCGen/src/Build.cpp") .file("deps/ReCGen/src/SSS.cpp") .file("deps/ReCGen/src/Fragmentation.cpp") .file("deps/ReCGen/src/ECFP-build.cpp") .file("src/wrapper.cpp") .includes(recgen_incls) .include("deps/ReCGen/src") .include("src") .flag("-DREV=465") // required by ReCGEN .flag_if_supported("-std=c++14") .flag_if_supported("-Wno-c++11-extensions") .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-variable") .flag_if_supported("-Wno-sign-compare") .flag_if_supported("-Wno-for-loop-analysis") .flag_if_supported("-Wno-ignored-qualifiers") .flag_if_supported("-Wno-return-type") .flag_if_supported("-Wno-deprecated-declarations") .warnings(false) .compile("recgen"); for p in recgen_libs { println!("cargo:rustc-link-search=native={}", p); } println!("cargo:rustc-link-lib=dylib=openbabel"); println!("cargo:rustc-link-lib=dylib=boost_iostreams"); println!("cargo:rustc-link-lib=dylib=sqlite3"); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=src/wrapper.h"); println!("cargo:rerun-if-changed=src/wrapper.cpp"); }