From 44fb94f7a1e2a269ce06dfade7a42ea79ef47a7b Mon Sep 17 00:00:00 2001 From: Wentsing Nee <28091833+WentsingNee@users.noreply.github.com> Date: Wed, 8 May 2024 11:38:17 +0800 Subject: [PATCH] [opencv4] Fix build failure when dnn feature is not enabled (#38594) Given the following manifest (when `dnn` feature is not included): ```json "dependencies": [ { "name": "opencv4", "version>=": "4.8.0#18", "default-features": false, "features": [ "png" ] } ] ``` it failed and here is what `vcpkg/buildtrees/opencv4/config-x64-linux-out.log` said: ``` ... CMake Error at /home/peter/open-source/git/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package): Could not find a package configuration file provided by "flatbuffers" with any of the following names: flatbuffersConfig.cmake flatbuffers-config.cmake Add the installation prefix of "flatbuffers" to CMAKE_PREFIX_PATH or set "flatbuffers_DIR" to a directory containing one of the above files. If "flatbuffers" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:759 (find_package) ... ``` This problem is introduced by [commit 6d2c9714](https://github.com/microsoft/vcpkg/commit/6d2c97145828d01040d654c136831b16cc43e4a3) contributed by @jimwang118 In the patch `vcpkg/ports/opencv4/0023-fix-no-flatbuffers.patch`, Jim disabled the procedure of `Flatbuffers` detection introduced by the previous patch `0017-fix-flatbuffers.patch`, which has correctly fixed the `flatbuffers`-related issues. ```patch ... --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -756,7 +756,7 @@ include(cmake/OpenCVFindLibsVideo.cmake) include(cmake/OpenCVFindLibsPerf.cmake) include(cmake/OpenCVFindLAPACK.cmake) include(cmake/OpenCVFindProtobuf.cmake) -include(cmake/OpenCVDetectFlatbuffers.cmake) +find_package(flatbuffers CONFIG REQUIRED) ... ``` In `vcpkg/ports/opencv4/vcpkg.json` we can see, `flatbuffers` is only the dependency of feature `dnn`: ```json "dependencies": [ ... "dnn": { "description": "Enable dnn module", "dependencies": [ "flatbuffers", { "name": "flatbuffers", "host": true, "default-features": false }, "protobuf" ] }, ... ``` and when `dnn` is not enabled, it broke down at the line `find_package(flatbuffers CONFIG REQUIRED)` And this change is unnecessary either: ```patch - list(APPEND libs ocv.3rdparty.flatbuffers) + list(APPEND libs flatbuffers::flatbuffers) ``` Thus, we'd better to revert those changes. Co-authored-by: WentsingNee <8090395+wentsingnee@user.noreply.gitee.com> --- ports/opencv4/0023-fix-no-flatbuffers.patch | 26 --------------------- ports/opencv4/portfile.cmake | 1 - ports/opencv4/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/o-/opencv4.json | 5 ++++ 5 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 ports/opencv4/0023-fix-no-flatbuffers.patch diff --git a/ports/opencv4/0023-fix-no-flatbuffers.patch b/ports/opencv4/0023-fix-no-flatbuffers.patch deleted file mode 100644 index 53ee3645dc..0000000000 --- a/ports/opencv4/0023-fix-no-flatbuffers.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5b6e382..29a81f0 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -756,7 +756,7 @@ include(cmake/OpenCVFindLibsVideo.cmake) - include(cmake/OpenCVFindLibsPerf.cmake) - include(cmake/OpenCVFindLAPACK.cmake) - include(cmake/OpenCVFindProtobuf.cmake) --include(cmake/OpenCVDetectFlatbuffers.cmake) -+find_package(flatbuffers CONFIG REQUIRED) - if(WITH_TENGINE) - include(cmake/OpenCVFindTengine.cmake) - endif() -diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt -index 804b78e..86d9d45 100644 ---- a/modules/dnn/CMakeLists.txt -+++ b/modules/dnn/CMakeLists.txt -@@ -133,7 +133,7 @@ if(TARGET ocv.3rdparty.flatbuffers AND OPENCV_DNN_TFLITE) - if(NOT HAVE_FLATBUFFERS) - message(FATAL_ERROR "DNN: TFLite is not supported without enabled 'flatbuffers'. Check build configuration.") - endif() -- list(APPEND libs ocv.3rdparty.flatbuffers) -+ list(APPEND libs flatbuffers::flatbuffers) - list(APPEND fw_hdrs "${CMAKE_CURRENT_LIST_DIR}/misc/tflite/schema_generated.h") - list(APPEND fw_inc "${CMAKE_CURRENT_LIST_DIR}/misc/tflite") - diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 1c0f4550da..125a396588 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -32,7 +32,6 @@ vcpkg_from_github( 0021-static-openvino.patch # https://github.com/opencv/opencv/pull/23963 "${ARM64_WINDOWS_FIX}" 0022-fix-supportqnx.patch - 0023-fix-no-flatbuffers.patch ) # Disallow accidental build of vendored copies file(REMOVE_RECURSE "${SOURCE_PATH}/3rdparty/openexr") diff --git a/ports/opencv4/vcpkg.json b/ports/opencv4/vcpkg.json index d46e172f13..e73bcce3e8 100644 --- a/ports/opencv4/vcpkg.json +++ b/ports/opencv4/vcpkg.json @@ -1,7 +1,7 @@ { "name": "opencv4", "version": "4.8.0", - "port-version": 18, + "port-version": 19, "description": "computer vision library", "homepage": "https://github.com/opencv/opencv", "license": "Apache-2.0", diff --git a/versions/baseline.json b/versions/baseline.json index b1f7347bdf..495fc64b27 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6438,7 +6438,7 @@ }, "opencv4": { "baseline": "4.8.0", - "port-version": 18 + "port-version": 19 }, "opendnp3": { "baseline": "3.1.1", diff --git a/versions/o-/opencv4.json b/versions/o-/opencv4.json index c84a6f88d9..91eb8a0198 100644 --- a/versions/o-/opencv4.json +++ b/versions/o-/opencv4.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "85685a5e45ef916a21769da98c8346462ef179d0", + "version": "4.8.0", + "port-version": 19 + }, { "git-tree": "b69ea5e7ef839490d21d1ef5aed614d19d54e203", "version": "4.8.0",