From fcfba4e09d9cfce5a06edf52f1c4fb8d4a365688 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Sun, 4 Jun 2023 00:11:43 +0200 Subject: [PATCH] Use pkg-config in build.rs The previous approach relied on the library being in the linker's default paths. --- Cargo.toml | 1 + build.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e6fbdaa..699ac1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ use-bindgen = ["bindgen"] [build-dependencies] bindgen = { version = "0.63.0", optional = true } +pkg-config = "0.3.15" [package.metadata.release] diff --git a/build.rs b/build.rs index 5513de4..97988b5 100644 --- a/build.rs +++ b/build.rs @@ -2,11 +2,18 @@ use std::env; #[cfg(feature = "use-bindgen")] use std::path::PathBuf; +use std::process; fn main() { // Tell cargo to tell rustc to link the system heif // shared library. - println!("cargo:rustc-link-lib=heif"); + if let Err(err) = pkg_config::Config::new() + .atleast_version("1.14") + .probe("libheif") + { + println!("cargo:warning={}", err); + process::exit(1); + } #[cfg(feature = "use-bindgen")] {