-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
0004-fix-detection-for-protobuf-23.x.patch
38 lines (35 loc) · 1.4 KB
/
0004-fix-detection-for-protobuf-23.x.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 0913b73bff8085886dc3f554f552a46e063986d4 Mon Sep 17 00:00:00 2001
From: Silvio Traversaro <silvio@traversaro.it>
Date: Sun, 4 Jun 2023 19:21:33 +0200
Subject: [PATCH 4/4] fix detection for protobuf 23.x
---
cmake/OpenCVFindProtobuf.cmake | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/cmake/OpenCVFindProtobuf.cmake b/cmake/OpenCVFindProtobuf.cmake
index 8835347d1d..6c5b04db2d 100644
--- a/cmake/OpenCVFindProtobuf.cmake
+++ b/cmake/OpenCVFindProtobuf.cmake
@@ -31,7 +31,23 @@ if(BUILD_PROTOBUF)
set(HAVE_PROTOBUF TRUE)
else()
unset(Protobuf_VERSION CACHE)
- find_package(Protobuf QUIET)
+ # First look for protobuf-config.cmake, and only later use
+ # FindProtobuf.cmake shipped with CMake, for compatibility
+ # with protobuf >= 22
+ set(protobuf_MODULE_COMPATIBLE TRUE CACHE INTERNAL "")
+ find_package(Protobuf CONFIG QUIET)
+ if(Protobuf_FOUND)
+ # if protobuf-config.cmake is used, we need to explicitly
+ # support the case in which we are cross-compiling and we want
+ # to explicitly specify via CMake command line the protoc to use
+ if(Protobuf_PROTOC_EXECUTABLE)
+ set_target_properties(protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_PROTOC_EXECUTABLE}"
+ )
+ endif()
+ else()
+ find_package(Protobuf QUIET)
+ endif()
# Backwards compatibility
# Define camel case versions of input variables