forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOpenCVFindLibProtobuf.cmake
33 lines (30 loc) · 1.35 KB
/
OpenCVFindLibProtobuf.cmake
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
# By default, we use protobuf sources from 3rdparty subdirectory and pre-generated .proto files
# Note: In case of .proto model updates these variables should be used:
# - Protobuf_PROTOC_EXECUTABLE (required)
# - Protobuf_INCLUDE_DIRS
# - Protobuf_LIBRARIES or Protobuf_LIBRARY / Protobuf_LIBRARY_DEBUG for find_package()
OCV_OPTION(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON)
OCV_OPTION(PROTOBUF_UPDATE_FILES "Force to rebuild .proto files" OFF)
if(PROTOBUF_UPDATE_FILES)
if(NOT DEFINED Protobuf_PROTOC_EXECUTABLE)
find_package(Protobuf QUIET)
endif()
if(DEFINED Protobuf_PROTOC_EXECUTABLE AND EXISTS ${Protobuf_PROTOC_EXECUTABLE})
message(STATUS "The protocol buffer compiler is found (${Protobuf_PROTOC_EXECUTABLE})")
else()
message(FATAL_ERROR "The protocol buffer compiler is not found (Protobuf_PROTOC_EXECUTABLE='${Protobuf_PROTOC_EXECUTABLE}')")
endif()
endif()
if(NOT BUILD_PROTOBUF AND NOT (DEFINED Protobuf_INCLUDE_DIRS AND DEFINED Protobuf_LIBRARIES))
find_package(Protobuf QUIET)
endif()
if(Protobuf_FOUND)
# nothing
else()
set(Protobuf_LIBRARIES libprotobuf)
set(Protobuf_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/protobuf/src")
if(NOT TARGET ${Protobuf_LIBRARIES})
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/protobuf" "${OpenCV_BINARY_DIR}/3rdparty/protobuf")
endif()
set(Protobuf_FOUND 1)
endif()