Skip to content

Commit e6f63c7

Browse files
committed
Merge pull request #1247 from alalek:protobuf_sources
2 parents 637e82d + 8f5c0e0 commit e6f63c7

File tree

3 files changed

+28
-229
lines changed

3 files changed

+28
-229
lines changed

modules/dnn/3rdparty/protobuf/CMakeLists.txt

Lines changed: 0 additions & 151 deletions
This file was deleted.

modules/dnn/CMakeLists.txt

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ if(WINRT)
22
ocv_module_disable(dnn)
33
endif()
44

5-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake)
6-
if(NOT DEFINED PROTOBUF_INCLUDE_DIR)
5+
include(${OpenCV_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake)
6+
if(NOT Protobuf_FOUND)
77
ocv_module_disable(opencv_dnn)
88
endif()
99

@@ -37,28 +37,36 @@ if(ANDROID)
3737
add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
3838
endif()
3939

40-
# ----------------------------------------------------------------------------
41-
# Resolve libprotobuf dependency
42-
# ----------------------------------------------------------------------------
43-
if(NOT PROTOBUF_FOUND)
44-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf "${PROTOBUF_CPP_PATH}")
45-
add_definitions(-DHAVE_PROTOBUF=1)
40+
#supress warnings in autogenerated caffe.pb.* files
41+
add_definitions(-DHAVE_PROTOBUF=1)
42+
ocv_warnings_disable(CMAKE_CXX_FLAGS
43+
-Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
44+
-Wdeprecated-declarations
45+
/wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
46+
/wd4456 /wd4510 /wd4610 /wd4800
47+
-wd858 -wd2196
48+
)
4649

47-
#supress warnings in autogenerated caffe.pb.* files
48-
ocv_warnings_disable(CMAKE_CXX_FLAGS
49-
-Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
50-
-Wdeprecated-declarations
51-
/wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
52-
/wd4456 /wd4510 /wd4610 /wd4800
53-
-wd858 -wd2196
54-
)
50+
if(PROTOBUF_UPDATE_FILES)
51+
file(GLOB proto_files src/tensorflow/*.proto)
52+
list(APPEND proto_files src/caffe/caffe.proto)
53+
PROTOBUF_GENERATE_CPP(Protobuf_HDRS Protobuf_SRCS ${proto_files})
54+
else()
55+
file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
56+
file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
57+
list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
58+
list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
59+
list(APPEND Protobuf_SRCS ${fw_srcs})
60+
list(APPEND Protobuf_HDRS ${fw_hdrs})
61+
list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
62+
list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow)
5563
endif()
5664

57-
ocv_source_group("Src\\protobuf" FILES ${PROTOBUF_SRCS} ${PROTOBUF_HDRS})
58-
ocv_module_include_directories(include ${PROTOBUF_INCLUDE_DIR})
65+
ocv_source_group("Src\\protobuf" FILES ${Protobuf_SRCS} ${Protobuf_HDRS})
66+
ocv_module_include_directories(include ${Protobuf_INCLUDE_DIRS})
5967

60-
ocv_glob_module_sources(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} ${CBLAS_H_PROXY_PATH})
61-
ocv_create_module(${PROTOBUF_LIBRARIES} ${LAPACK_LIBRARIES})
68+
ocv_glob_module_sources(${Protobuf_SRCS} ${Protobuf_HDRS} ${CBLAS_H_PROXY_PATH})
69+
ocv_create_module(${Protobuf_LIBRARIES} ${LAPACK_LIBRARIES})
6270
ocv_add_samples()
6371
ocv_add_accuracy_tests()
6472
ocv_add_perf_tests()

modules/dnn/cmake/OpenCVFindLibProtobuf.cmake

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)