rename OPENCV_PKGCONFIG_NAME to OPENCV_PACKAGE_NAME
MODIFY
README.md
README.md
@@ -159,10 +159,11 @@ Path specified by `LD_LIBRARY_PATH` must contain `libopencv_*.so` files.
The directory in that environment variable should contain `opencv2` dir, e.g. `/usr/include` for
OpenCV-3.4.x or `/usr/include/opencv4` for OpenCV-4.x.
-* `OPENCV_PKGCONFIG_NAME`
- In some cases you might want to override the pkgconfig package name, you can use `OPENCV_PKGCONFIG_NAME`
- environment variable for that. If you set it pkgconfig will expect to find the file with that name
- and `.pc` extension in the package directory.
+* `OPENCV_PACKAGE_NAME`
+ In some cases you might want to override the pkgconfig or vcpkg package name, you can use this environment
+ variable for that. If you set it pkgconfig will expect to find the file with that name and `.pc` extension
+ in the package directory. And vcpkg will use that name to try to find package in `packages` directory under
+ `VCPKG_ROOT`. For compatibility reasons `OPENCV_PKGCONFIG_NAME` is also supported as variable name.
* `OPENCV_PYTHON3_BIN`
During the build crate uses Python 3 to run header parsing and generation. The binary is usually

MODIFY
build.rs
build.rs
@@ -172,7 +172,8 @@ impl Library {
None
};
let pkg_name = if cfg!(feature = "opencv-32") || cfg!(feature = "opencv-34") {
- env::var("OPENCV_PKGCONFIG_NAME")
+ env::var("OPENCV_PACKAGE_NAME")
+ .or_else(|_| env::var("OPENCV_PKGCONFIG_NAME"))
.map(|x| Cow::Owned(x))
.unwrap_or_else(|_| if cfg!(target_env = "msvc") && env_vars.is_none() {
"opencv3".into() // the package name in vcpkg for OpenCV3.x is different: https://github.com/microsoft/vcpkg/tree/master/ports/opencv3
@@ -180,7 +181,8 @@ impl Library {
"opencv".into()
})
} else if cfg!(feature = "opencv-41") {
- env::var("OPENCV_PKGCONFIG_NAME")
+ env::var("OPENCV_PACKAGE_NAME")
+ .or_else(|_| env::var("OPENCV_PKGCONFIG_NAME"))
.map(|x| Cow::Owned(x))
.unwrap_or_else(|_| "opencv4".into())
} else {
@@ -532,6 +534,7 @@ fn build_wrapper(opencv_header_dir: &PathBuf) -> Result<()> {
println!("cargo:rerun-if-changed=hdr_parser.py");
println!("cargo:rerun-if-changed=gen_rust.py");
println!("cargo:rerun-if-env-changed=OPENCV_HEADER_DIR");
+ println!("cargo:rerun-if-env-changed=OPENCV_PACKAGE_NAME");
println!("cargo:rerun-if-env-changed=OPENCV_PKGCONFIG_NAME");
println!("cargo:rerun-if-env-changed=OPENCV_LINK_LIBS");
println!("cargo:rerun-if-env-changed=OPENCV_LINK_PATHS");

rename OPENCV_PKGCONFIG_NAME to OPENCV_PACKAGE_NAME