pub fn from_config(config: Config) -> Result<Self> {
        let mut targets = Targets::new(config);

        // OUT_DIR
        if let Ok(dir) = std::env::var("OUT_DIR") {
            let out_dir = PathBuf::from(dir);
            targets.seek(&out_dir);
        }

        // pkg-config
        if let Ok(lib) = pkg_config::Config::new()
            .cargo_metadata(false)
            .probe(&config.name())
        {
            for path in lib.link_paths {
                targets.seek(&path);
            }

            // assumes following directory structure:
            //
            // - mkl
            //   - include      <- lib.include_paths detects this
            //   - lib/intel64
            for path in lib.include_paths {
                targets.seek(&path.join("../lib/intel64"));
            }
        }

        // $XDG_DATA_HOME/intel-mkl-tool
        let path = xdg_home_path().join(config.name());
        targets.seek(&path);

        // $MKLROOT
        let mkl_root = std::env::var("MKLROOT").map(|path| PathBuf::from(path));
        if let Ok(path) = mkl_root {
            if path.exists() {
                targets.seek(path.join("lib/intel64"));
            }
        }

        // /opt/intel/mkl
        let opt_mkl = PathBuf::from("/opt/intel/mkl");
        if opt_mkl.exists() {
            targets.seek(opt_mkl.join("lib/intel64"));
        }

        // Default setting for Windows installer
        let windows_mkl =
            PathBuf::from("C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows");
        if windows_mkl.exists() {
            targets.seek(windows_mkl.join("mkl/lib/intel64"));
            targets.seek(windows_mkl.join("compiler/lib/intel64"));
        }

        if targets.found_any() {
            return Ok(Self { config, targets });
        } else {
            // None found
            bail!("No library found for {}", config.name());
        }
    }
/// Get the directory where the library exists
///
/// This will seek followings in this order:
///
/// - `$OUT_DIR`
///   - Only for build.rs
///   - This exists only when the previous build downloads archive here
/// - pkg-config `${name}`
///   - Installed by package manager or official downloader
/// - `$XDG_DATA_HOME/intel-mkl-tool/${name}`
///   - Downloaded by this crate
///
/// Returns error if no library found
///
Get the directory where the library exists
This will seek followings in this order.



Returns error if no library found
Get the directory where the library exists This will seek followings in this order . Returns error if no library found
pub fn from_config(config: Config) -> Result<Self> {
        let mut targets = Targets::new(config);
        // OUT_DIR
        if let Ok(dir) = std::env::var("OUT_DIR") {
            let out_dir = PathBuf::from(dir);
            targets.seek(&out_dir);
        }
        // pkg-config
        if let Ok(lib) = pkg_config::Config::new()
            .cargo_metadata(false)
            .probe(&config.name())
        {
            for path in lib.link_paths {
                targets.seek(&path);
            }
            // assumes following directory structure:
            //
            // - mkl
            //   - include      <- lib.include_paths detects this
            //   - lib/intel64
            for path in lib.include_paths {
                targets.seek(&path.join("../lib/intel64"));
            }
        }
        // $XDG_DATA_HOME/intel-mkl-tool
        let path = xdg_home_path().join(config.name());
        targets.seek(&path);
        // $MKLROOT
        let mkl_root = std::env::var("MKLROOT").map(|path| PathBuf::from(path));
        if let Ok(path) = mkl_root {
            if path.exists() {
                targets.seek(path.join("lib/intel64"));
            }
        }
        // /opt/intel/mkl
        let opt_mkl = PathBuf::from("/opt/intel/mkl");
        if opt_mkl.exists() {
            targets.seek(opt_mkl.join("lib/intel64"));
        }
        // Default setting for Windows installer
        let windows_mkl =
            PathBuf::from("C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows");
        if windows_mkl.exists() {
            targets.seek(windows_mkl.join("mkl/lib/intel64"));
            targets.seek(windows_mkl.join("compiler/lib/intel64"));
        }
        if targets.found_any() {
            return Ok(Self { config, targets });
        } else {
            // None found
            bail!("No library found for {}", config.name());
        }
    }
pub fn from_config ( config : Config ) -> Result < Self > { let mut targets = Targets :: new ( config ) ; // OUT_DIR if let Ok ( dir ) = std :: env :: var ( " " ) { let out_dir = PathBuf :: from ( dir ) ; targets . seek ( & out_dir ) ; } // pkg-config if let Ok ( lib ) = pkg_config :: Config :: new ( ) . cargo_metadata ( false ) . probe ( & config . name ( ) ) { for path in lib . link_paths { targets . seek ( & path ) ; } // assumes following directory structure: // // - mkl //   - include      <- lib.include_paths detects this //   - lib/intel64 for path in lib . include_paths { targets . seek ( & path . join ( " " ) ) ; } } // $XDG_DATA_HOME/intel-mkl-tool let path = xdg_home_path ( ) . join ( config . name ( ) ) ; targets . seek ( & path ) ; // $MKLROOT let mkl_root = std :: env :: var ( " " ) . map ( | path | PathBuf :: from ( path ) ) ; if let Ok ( path ) = mkl_root { if path . exists ( ) { targets . seek ( path . join ( " " ) ) ; } } // /opt/intel/mkl let opt_mkl = PathBuf :: from ( " " ) ; if opt_mkl . exists ( ) { targets . seek ( opt_mkl . join ( " " ) ) ; } // Default setting for Windows installer let windows_mkl = PathBuf :: from ( " " ) ; if windows_mkl . exists ( ) { targets . seek ( windows_mkl . join ( " " ) ) ; targets . seek ( windows_mkl . join ( " " ) ) ; } if targets . found_any ( ) { return Ok ( Self { config , targets } ) ; } else { // None found bail ! ( " " config name ( ) ) ; } }
Get the directory where the library exists
This will seek followings in this order:
Get the directory where the library exists This will seek followings in this order :
config
Config
config
Config