|
| 1 | +if(WINRT) |
| 2 | + ocv_module_disable(dnn) |
| 3 | +endif() |
| 4 | + |
| 5 | +include(${OpenCV_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake) |
| 6 | +if(NOT Protobuf_FOUND) |
| 7 | + ocv_module_disable(opencv_dnn) |
| 8 | +endif() |
| 9 | + |
| 10 | +set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass") |
| 11 | + |
| 12 | +ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab) |
| 13 | +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo |
| 14 | + -Wmissing-declarations -Wmissing-prototypes |
| 15 | +) |
| 16 | +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100) |
| 17 | + |
| 18 | +if(MSVC) |
| 19 | + add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 ) |
| 20 | + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 |
| 21 | + /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 |
| 22 | + /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506 |
| 23 | + ) |
| 24 | +else() |
| 25 | + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow |
| 26 | + -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo |
| 27 | + -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra |
| 28 | + -Wunused-function -Wunused-const-variable -Wdeprecated-declarations |
| 29 | + ) |
| 30 | +endif() |
| 31 | + |
| 32 | +if(APPLE_FRAMEWORK) |
| 33 | + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshorten-64-to-32) |
| 34 | +endif() |
| 35 | + |
| 36 | +if(ANDROID) |
| 37 | + add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING) |
| 38 | +endif() |
| 39 | + |
| 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 | +) |
| 49 | + |
| 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) |
| 63 | +endif() |
| 64 | + |
| 65 | +ocv_source_group("Src\\protobuf" FILES ${Protobuf_SRCS} ${Protobuf_HDRS}) |
| 66 | +ocv_module_include_directories(include ${Protobuf_INCLUDE_DIRS}) |
| 67 | + |
| 68 | +ocv_glob_module_sources(${Protobuf_SRCS} ${Protobuf_HDRS} ${CBLAS_H_PROXY_PATH}) |
| 69 | +ocv_create_module(${Protobuf_LIBRARIES} ${LAPACK_LIBRARIES}) |
| 70 | +ocv_add_samples() |
| 71 | +ocv_add_accuracy_tests() |
| 72 | +ocv_add_perf_tests() |
| 73 | + |
| 74 | +# ---------------------------------------------------------------------------- |
| 75 | +# Torch7 importer of blobs and models, produced by Torch.nn module |
| 76 | +# ---------------------------------------------------------------------------- |
| 77 | +OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer" ON) |
| 78 | +if(${the_module}_BUILD_TORCH_IMPORTER) |
| 79 | + message(STATUS "Torch importer has been enabled. To run the tests you have to install Torch " |
| 80 | + "('th' executable should be available) " |
| 81 | + "and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.") |
| 82 | + add_definitions(-DENABLE_TORCH_IMPORTER=1) |
| 83 | + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) #supress warnings in original torch files |
| 84 | +endif() |
0 commit comments