use singe_cuda_find::{emit_rerun_if_env_changed, find_cuda_runtime, find_nccl};

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    emit_rerun_if_env_changed();

    link_libraries();
}

fn link_libraries() {
    if let Some(cudart) = find_cuda_runtime() {
        println!("cargo:rustc-link-search={}", cudart.library_path.display());
        println!("cargo:rustc-link-lib=static=cudart_static");
        println!("cargo:include={}", cudart.include_path.display());
    }

    if let Some(nccl) = find_nccl() {
        println!("cargo:rustc-link-search={}", nccl.library_path.display());
        println!("cargo:rustc-link-lib=nccl");
    }
}
