diff --git a/.github/workflows/opencv-rust.yml b/.github/workflows/opencv-rust.yml index 1ebb3c1c..034816f6 100644 --- a/.github/workflows/opencv-rust.yml +++ b/.github/workflows/opencv-rust.yml @@ -68,7 +68,7 @@ jobs: - windows-2022 - macos-14 vcpkg-version: - - 2024.10.21 + - 2024.12.16 runs-on: ${{ matrix.os-image }} env: VCPKG_VERSION: ${{ matrix.vcpkg-version }} diff --git a/INSTALL.md b/INSTALL.md index ef86b375..10ae92c6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -56,7 +56,7 @@ Installing OpenCV is easy through the following sources: * from [vcpkg](https://docs.microsoft.com/en-us/cpp/build/vcpkg), also install `llvm` package, necessary for building: ```shell script - vcpkg install llvm opencv4[contrib,nonfree] + vcpkg install llvm opencv4[contrib,nonfree,opencl] ``` You most probably want to set environment variable `VCPKGRS_DYNAMIC` to "1" unless you're specifically targeting a static build. diff --git a/build/library.rs b/build/library.rs index 56c23c44..4a0b6b6d 100644 --- a/build/library.rs +++ b/build/library.rs @@ -387,9 +387,20 @@ impl Library { } let opencv = opencv.ok_or_else(|| errors.join(", "))?; - let version = Self::version_from_include_paths(&opencv.include_paths); + let mut opencv_include_paths = opencv.include_paths; + // workaround for the wrong detected include path for vcpkg 2024.11.16+: https://github.com/twistedfall/opencv-rust/issues/640 + for include_path in &mut opencv_include_paths { + if include_path.ends_with("include") { + let fixed_include_path = include_path.join("opencv4"); + if fixed_include_path.exists() { + *include_path = fixed_include_path; + } + } + } - let include_paths = Self::process_env_var_list(include_paths, opencv.include_paths); + let version = Self::version_from_include_paths(&opencv_include_paths); + + let include_paths = Self::process_env_var_list(include_paths, opencv_include_paths); let mut cargo_metadata = opencv.cargo_metadata; diff --git a/ci/install-macos-vcpkg.sh b/ci/install-macos-vcpkg.sh index 95949616..10f55d0f 100755 --- a/ci/install-macos-vcpkg.sh +++ b/ci/install-macos-vcpkg.sh @@ -28,7 +28,7 @@ export VCPKG_DEFAULT_TRIPLET=arm64-osx set +e which cmake cmake --version - if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then + if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do echo "=== $log" cat "$log" diff --git a/ci/install-ubuntu-vcpkg.sh b/ci/install-ubuntu-vcpkg.sh index 45b79291..b47fb9d9 100755 --- a/ci/install-ubuntu-vcpkg.sh +++ b/ci/install-ubuntu-vcpkg.sh @@ -37,7 +37,7 @@ export VCPKG_DEFAULT_TRIPLET=x64-linux set +e which cmake cmake --version - if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then + if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do echo "=== $log" cat "$log" diff --git a/ci/install-windows-vcpkg.sh b/ci/install-windows-vcpkg.sh index 9eae7ad7..402f87d3 100755 --- a/ci/install-windows-vcpkg.sh +++ b/ci/install-windows-vcpkg.sh @@ -33,7 +33,7 @@ export VCPKG_DEFAULT_TRIPLET=x64-windows set +e which cmake cmake --version - if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then + if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do echo "=== $log" cat "$log"