#[cfg(feature = "intel_mkl")]
use std::env;
#[cfg(feature = "intel_mkl")]
fn validate_intel_setvars_completed() {
let intel_setvars_completed = match env::var("SETVARS_COMPLETED") {
Ok(v) => v == "1",
Err(_) => false,
};
if !intel_setvars_completed {
panic!("\n\nBUILD ERROR: Intel setvars.sh need to be sourced first.\nYou must execute the following command (just once):\nsource /opt/intel/oneapi/setvars.sh\n\n")
}
}
#[cfg(not(feature = "intel_mkl"))]
fn validate_intel_setvars_completed() {}
#[cfg(not(feature = "intel"))]
#[cfg(not(feature = "mpich"))]
fn get_information() -> (Vec<&'static str>, Vec<&'static str>, Vec<&'static str>) {
(
vec![
"/usr/lib/x86_64-linux-gnu/openmpi/include/", "/usr/local/opt/open-mpi/include", "/opt/homebrew/include/", ],
vec![
"/usr/lib/x86_64-linux-gnu/openmpi/", "/usr/local/opt/open-mpi/lib/", "/opt/homebrew/lib/", ],
vec![
"mpi", ],
)
}
#[cfg(feature = "intel")]
#[cfg(not(feature = "mpich"))]
fn get_information() -> (Vec<&'static str>, Vec<&'static str>, Vec<&'static str>) {
(
vec![
"/opt/intel/oneapi/mpi/latest/include/", ],
vec![
"/opt/intel/oneapi/mpi/latest/lib/", ],
vec![
"mpi", ],
)
}
#[cfg(feature = "mpich")]
#[cfg(not(feature = "intel"))]
fn get_information() -> (Vec<&'static str>, Vec<&'static str>, Vec<&'static str>) {
(
vec![
"/usr/include/x86_64-linux-gnu/mpich/", ],
vec![
"/usr/lib/x86_64-linux-gnu/", ],
vec![
"mpich", ],
)
}
fn main() {
validate_intel_setvars_completed();
let (inc_dirs, lib_dirs, libs) = get_information();
cc::Build::new().file("c_code/interface_mpi.c").includes(&inc_dirs).compile("c_code_interface_mpi");
for d in &lib_dirs {
println!("cargo:rustc-link-search=native={}", *d);
}
for l in &libs {
println!("cargo:rustc-link-lib=dylib={}", *l);
}
println!("cargo:rerun-if-changed=c_code/constants.h");
println!("cargo:rerun-if-changed=c_code/interface_mpi.c");
}