Skip to content

Commit fd34550

Browse files
committed
Add workaround for the wrong detected include path and linkage problems with vcpkg
1 parent 50a6fdd commit fd34550

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Installing OpenCV is easy through the following sources:
5656
* from [vcpkg](https://docs.microsoft.com/en-us/cpp/build/vcpkg), also install `llvm` package,
5757
necessary for building:
5858
```shell script
59-
vcpkg install llvm opencv4[contrib,nonfree]
59+
vcpkg install llvm opencv4[contrib,nonfree,opencl]
6060
```
6161
You most probably want to set environment variable `VCPKGRS_DYNAMIC` to "1" unless you're specifically
6262
targeting a static build.

build/library.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,21 @@ impl Library {
387387
}
388388
let opencv = opencv.ok_or_else(|| errors.join(", "))?;
389389

390-
let version = Self::version_from_include_paths(&opencv.include_paths);
390+
let mut opencv_include_paths = opencv.include_paths;
391+
392+
let mut version = Self::version_from_include_paths(&opencv_include_paths);
393+
// workaround for the wrong detected include path for vcpkg 2024.11.16+: https://github.com/twistedfall/opencv-rust/issues/640
394+
if version.is_none() {
395+
for include_path in &mut opencv_include_paths {
396+
if include_path.ends_with("include") {
397+
include_path.push("opencv4");
398+
version = Self::version_from_include_paths(&[include_path]);
399+
break;
400+
}
401+
}
402+
}
391403

392-
let include_paths = Self::process_env_var_list(include_paths, opencv.include_paths);
404+
let include_paths = Self::process_env_var_list(include_paths, opencv_include_paths);
393405

394406
let mut cargo_metadata = opencv.cargo_metadata;
395407

ci/install-macos-vcpkg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export VCPKG_DEFAULT_TRIPLET=arm64-osx
2828
set +e
2929
which cmake
3030
cmake --version
31-
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then
31+
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then
3232
for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do
3333
echo "=== $log"
3434
cat "$log"

ci/install-ubuntu-vcpkg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export VCPKG_DEFAULT_TRIPLET=x64-linux
3737
set +e
3838
which cmake
3939
cmake --version
40-
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then
40+
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then
4141
for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do
4242
echo "=== $log"
4343
cat "$log"

ci/install-windows-vcpkg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export VCPKG_DEFAULT_TRIPLET=x64-windows
3333
set +e
3434
which cmake
3535
cmake --version
36-
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade]"; then
36+
if ! ./vcpkg install --clean-after-build --recurse "opencv[contrib,nonfree,ade,opencl]"; then
3737
for log in "$VCPKG_ROOT/buildtrees"/**/*out.log; do
3838
echo "=== $log"
3939
cat "$log"

0 commit comments

Comments
 (0)