Only call pkg_config if the feature is enabled (#66)

This commit is contained in:
Hans Ole Hatzel
2023-05-24 21:49:22 +02:00
committed by Till Höppner
parent 0be10ddd49
commit 8c9cd56556
+19 -29
View File
@@ -515,40 +515,30 @@ fn main() {
}
// Fallback to pkg-config
else {
pkg_config::Config::new()
.statik(statik)
.probe("libavformat")
.unwrap();
pkg_config::Config::new()
.statik(statik)
.probe("libavfilter")
.unwrap();
pkg_config::Config::new()
.statik(statik)
.probe("libavdevice")
.unwrap();
pkg_config::Config::new()
.statik(statik)
.probe("libavresample")
.unwrap();
pkg_config::Config::new()
.statik(statik)
.probe("libavutil")
.unwrap();
.unwrap()
.include_paths;
pkg_config::Config::new()
.statik(statik)
.probe("libswscale")
.unwrap();
let libs = vec![
("libavformat", "AVFORMAT"),
("libavfilter", "AVFILTER"),
("libavdevice", "AVDEVICE"),
("libavresample", "AVRESAMPLE"),
("libswscale", "SWSCALE"),
("libswresample", "SWRESAMPLE"),
];
pkg_config::Config::new()
.statik(statik)
.probe("libswresample")
.unwrap();
for (lib_name, env_variable_name) in libs.iter() {
if env::var(format!("CARGO_FEATURE_{}", env_variable_name)).is_ok() {
pkg_config::Config::new()
.statik(statik)
.probe(lib_name)
.unwrap()
.include_paths;
}
};
pkg_config::Config::new()
.statik(statik)