build: Use pkg-config to find vlc

master
Romain Roffé 2022-05-09 14:26:33 +02:00
parent 55310d8bd3
commit 12a22eb8a4
1 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,6 @@
use std::env;
use std::path::PathBuf;
use pkg_config;
#[cfg(feature = "bindgen")]
fn generate_bindings() {
@ -46,6 +47,12 @@ fn copy_pregenerated_bindings()
.expect("Couldn't find pregenerated bindings!");
}
fn link_vlc_with_pkgconfig() -> Result<pkg_config::Library, pkg_config::Error> {
pkg_config::Config::new()
.print_system_libs(false)
.probe("libvlc")
}
#[cfg(target_os = "windows")]
mod windows {
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
@ -164,8 +171,13 @@ fn main() {
copy_pregenerated_bindings();
// Link
#[cfg(target_os = "windows")]
windows::link_vlc();
if let Err(err) = link_vlc_with_pkgconfig() {
#[cfg(target_os = "windows")]
windows::link_vlc();
#[cfg(not(target_os = "windows"))]
panic!("libvlc not found: {:?}", err);
}
println!("cargo:rustc-link-lib=vlc");
}