Try fix msvc warnings

pull/265/head
Vitaliy Lyudvichenko 10 years ago
parent 93a372f58c
commit 44e52a08fa
  1. 17
      modules/dnn/3rdparty/protobuf/CMakeLists.txt
  2. 2
      modules/dnn/CMakeLists.txt
  3. 2
      modules/dnn/cmake/.gitignore
  4. 3
      modules/dnn/cmake/find_protobuf.cmake
  5. 6
      modules/dnn/src/torch/torch_importer.cpp

@ -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

@ -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)

@ -1,2 +0,0 @@
build
build-*

@ -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()

@ -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);

Loading…
Cancel
Save