gate forced 3rd party lib discovery behind a non-default feature
MODIFY
Cargo.toml
Cargo.toml
@@ -36,6 +36,7 @@ matches = "0.1"
[features]
default = ["opencv-34"]
buildtime-bindgen = []
+force-3rd-party-libs-discovery = []
opencv-32 = []
opencv-34 = []
opencv-41 = []

MODIFY
build.rs
build.rs
@@ -180,7 +180,11 @@ fn link_wrapper() -> Result<(pkg_config::Library, &'static str), Box<dyn Error>>
eprintln!("=== Using OpenCV library version: {} from: {}", opencv.version, pkg_config::get_variable(pkg_name, "libdir")?);
- // add 3rdparty lib dit. pkgconfig forgets it somehow.
+ // fixme: I wonder whether that kind of forced discovery is needed at all now
+ // It sure messes with cross-building when a lib is present in host, but not in target platform
+ // So for now let's hide it behind a non-default feature and check the breakage reports
+ if cfg!(feature = "force-3rd-party-libs-discovery") {
+ // add 3rdparty lib dir. pkgconfig forgets it somehow.
let third_party_dir1 = format!("{}/share/OpenCV/3rdparty/lib", pkg_config::get_variable(pkg_name, "prefix")?);
println!("cargo:rustc-link-search=native={}", third_party_dir1);
let third_party_dir2 = format!("{}/{}/3rdparty", pkg_config::get_variable(pkg_name, "libdir")?, pkg_name);
@@ -222,6 +226,7 @@ fn link_wrapper() -> Result<(pkg_config::Library, &'static str), Box<dyn Error>>
"zlib",
];
third_party_deps.iter().for_each(|&x| lookup_lib(&third_party_dirs, x));
+ }
Ok((opencv, pkg_name))
}

gate forced 3rd party lib discovery behind a non-default feature