diff --git a/modules/dnn/3rdparty/protobuf/CMakeLists.txt b/modules/dnn/3rdparty/protobuf/CMakeLists.txt index 1ec897298..d247c0129 100644 --- a/modules/dnn/3rdparty/protobuf/CMakeLists.txt +++ b/modules/dnn/3rdparty/protobuf/CMakeLists.txt @@ -89,16 +89,16 @@ if(WIN32 AND BUILD_SHARED_LIBS AND MSVC) add_definitions(-DLIBPROTOBUF_EXPORTS) endif() -add_definitions( -D_GNU_SOURCE=1 ) -add_definitions( -DHAVE_CONFIG_H ) +#add_definitions( -DGOOGLE_PROTOBUF_NO_THREAD_SAFETY ) #we don't need thread safety +add_definitions( -D_GNU_SOURCE=1 ) #it's maybe useful +add_definitions( -DHAVE_CONFIG_H ) #we will use config.h configure_file("cmake/config.h.in" "config.h") if(MSVC) add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 ) - ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /w4398 /w4510 /w4610 /w4244 /w4702 /w4389) + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 /wd4702) else() ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef) - ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang endif() # Easier to support different versions of protobufs @@ -116,6 +116,12 @@ endfunction() set(PROTOBUF_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +if(MSVC) + set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc) +else() + set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc) +endif() + append_if_exist(PROTOBUF_SRCS ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc @@ -139,8 +145,7 @@ append_if_exist(PROTOBUF_SRCS ${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc ${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc ${PROTOBUF_ROOT}/src/google/protobuf/service.cc - ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc - ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc + ${ATOMICOPS_INTERNALS} ${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc @@ -151,7 +156,7 @@ append_if_exist(PROTOBUF_SRCS ${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc ${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc ${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc -# ${PROTOBUF_ROOT}/src/google/protobuf/stubs/hash.cc + #${PROTOBUF_ROOT}/src/google/protobuf/stubs/hash.cc ) if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)) diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 4f1acb799..06aa91714 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -10,6 +10,7 @@ include(cmake/find_protobuf.cmake) ocv_add_module(dnn opencv_imgproc opencv_core opencv_highgui WRAP python matlab) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo -Wmissing-declarations -Wmissing-prototypes) +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701) ocv_glob_module_sources(${PROTOBUF_SRCS} ${PROTOBUF_HDRS}) ocv_source_group("Src\\protobuf" FILES ${PROTOBUF_SRCS} ${PROTOBUF_HDRS}) ocv_module_include_directories(include ${PROTOBUF_INCLUDE_DIR}) @@ -31,6 +32,7 @@ endif() OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer" OFF) if(${the_module}_BUILD_TORCH_IMPORTER) add_definitions(-DENABLE_TORCH_IMPORTER=1) + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) endif() OCV_OPTION(${the_module}_BUILD_TORCH_TESTS "Build Torch tests (installed Torch7 with nn module is required)" ON IF BUILD_TESTS AND ${the_module}_BUILD_TORCH_IMPORTER) diff --git a/modules/dnn/cmake/.gitignore b/modules/dnn/cmake/.gitignore deleted file mode 100644 index fe06a514f..000000000 --- a/modules/dnn/cmake/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build -build-* diff --git a/modules/dnn/cmake/find_protobuf.cmake b/modules/dnn/cmake/find_protobuf.cmake index 28c5b0ea4..8adb5ad45 100644 --- a/modules/dnn/cmake/find_protobuf.cmake +++ b/modules/dnn/cmake/find_protobuf.cmake @@ -31,4 +31,7 @@ else() VERBATIM ) set_source_files_properties(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} PROPERTIES GENERATED TRUE) + + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter) + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702) endif() \ No newline at end of file diff --git a/modules/dnn/src/torch/torch_importer.cpp b/modules/dnn/src/torch/torch_importer.cpp index e1b70dab6..522c8d31a 100644 --- a/modules/dnn/src/torch/torch_importer.cpp +++ b/modules/dnn/src/torch/torch_importer.cpp @@ -99,7 +99,7 @@ struct TorchImporter : public ::cv::dnn::Importer inline bool readBool() { - return readInt(); + return readInt() != 0; } inline double readDouble() @@ -439,7 +439,7 @@ struct TorchImporter : public ::cv::dnn::Importer CV_Assert(tensorParams.count("weight")); layerParams.learnedBlobs.push_back(tensorParams["weight"]); - bool bias = tensorParams.count("bias"); + bool bias = tensorParams.count("bias") != 0; layerParams.set("bias_term", bias); if (bias) layerParams.learnedBlobs.push_back(tensorParams["bias"]); @@ -471,7 +471,7 @@ struct TorchImporter : public ::cv::dnn::Importer Blob weightBlob = tensorParams["weight"]; layerParams.learnedBlobs.push_back(weightBlob); - bool bias = tensorParams.count("bias"); + bool bias = tensorParams.count("bias") != 0; if (bias) layerParams.learnedBlobs.push_back(tensorParams["bias"]); layerParams.set("bias_term", bias);