- if cfg!(windows) {
- // On windows, libraries are just searched in the executable directory,
- // system directories, PWD, and PATH, in that order. PATH is the only one
- // we can change for this.
- cmd.env(
- "PATH",
- env::join_paths(
- std::iter::once(work.to_owned())
- .chain(std::iter::once(path.clone()))
- .chain(env::split_paths(&env::var_os("PATH").unwrap())),
- )
- .unwrap(),
- );
- } else {
- cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display()));
+ let mut paths = vec![work.to_owned(), path.clone()];
+ if let Some(library_path) = env::var_os(library_path) {
+ paths.extend(env::split_paths(&library_path));