Try fix msvc error and cmake error on android

pull/265/head
Vitaliy Lyudvichenko 10 years ago
parent fc9795b4bc
commit 93a372f58c
  1. 11
      modules/dnn/3rdparty/protobuf/CMakeLists.txt
  2. 9
      modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
  3. 2
      modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite_inl.h
  4. 18
      modules/dnn/cmake/find_protobuf.cmake

@ -95,9 +95,10 @@ configure_file("cmake/config.h.in" "config.h")
if(MSVC) if(MSVC)
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 ) add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305) 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)
else() else()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wshadow -Wmissing-declarations -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef) 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() endif()
# Easier to support different versions of protobufs # Easier to support different versions of protobufs
@ -171,6 +172,6 @@ if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(libprotobuf PROPERTIES FOLDER "3rdparty") set_target_properties(libprotobuf PROPERTIES FOLDER "3rdparty")
endif() endif()
#if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
# ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev) ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
#endif() endif()

@ -35,6 +35,7 @@
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stl_util.h> #include <google/protobuf/stubs/stl_util.h>
#include <algorithm>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -63,7 +64,7 @@ ArrayInputStream::~ArrayInputStream() {
bool ArrayInputStream::Next(const void** data, int* size) { bool ArrayInputStream::Next(const void** data, int* size) {
if (position_ < size_) { if (position_ < size_) {
last_returned_size_ = min(block_size_, size_ - position_); last_returned_size_ = std::min(block_size_, size_ - position_);
*data = data_ + position_; *data = data_ + position_;
*size = last_returned_size_; *size = last_returned_size_;
position_ += last_returned_size_; position_ += last_returned_size_;
@ -116,7 +117,7 @@ ArrayOutputStream::~ArrayOutputStream() {
bool ArrayOutputStream::Next(void** data, int* size) { bool ArrayOutputStream::Next(void** data, int* size) {
if (position_ < size_) { if (position_ < size_) {
last_returned_size_ = min(block_size_, size_ - position_); last_returned_size_ = std::min(block_size_, size_ - position_);
*data = data_ + position_; *data = data_ + position_;
*size = last_returned_size_; *size = last_returned_size_;
position_ += last_returned_size_; position_ += last_returned_size_;
@ -163,7 +164,7 @@ bool StringOutputStream::Next(void** data, int* size) {
// that the new size is at least kMinimumSize. // that the new size is at least kMinimumSize.
STLStringResizeUninitialized( STLStringResizeUninitialized(
target_, target_,
max(old_size * 2, std::max(old_size * 2,
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness. kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
} }
@ -190,7 +191,7 @@ int CopyingInputStream::Skip(int count) {
char junk[4096]; char junk[4096];
int skipped = 0; int skipped = 0;
while (skipped < count) { while (skipped < count) {
int bytes = Read(junk, min(count - skipped, int bytes = Read(junk, std::min(count - skipped,
implicit_cast<int>(sizeof(junk)))); implicit_cast<int>(sizeof(junk))));
if (bytes <= 0) { if (bytes <= 0) {
// EOF or read error. // EOF or read error.

@ -284,7 +284,7 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
return true; return true;
} }
// Specializations of ReadRepeatedPrimitive for the fixed size types, which use // Specializations of ReadRepeatedPrimitive for the fixed size types, which use
// the optimized code path. // the optimized code path.
#define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE) \ #define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE) \
template <> \ template <> \

@ -4,7 +4,6 @@ endif()
if(NOT BUILD_LIBPROTOBUF_FROM_SOURCES AND PROTOBUF_FOUND AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) if(NOT BUILD_LIBPROTOBUF_FROM_SOURCES AND PROTOBUF_FOUND AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
message(STATUS "The protocol buffer compiler and libprotobuf were found") message(STATUS "The protocol buffer compiler and libprotobuf were found")
PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS src/caffe/caffe.proto) PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS src/caffe/caffe.proto)
add_definitions(-DHAVE_PROTOBUF=1) add_definitions(-DHAVE_PROTOBUF=1)
else() else()
@ -18,19 +17,18 @@ else()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf)
endif() endif()
set(PROTOBUF_LIBRARIES libprotobuf)
set(PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf/src ${CMAKE_CURRENT_BINARY_DIR})
set(PROTOBUF_SRCS ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.cc)
set(PROTOBUF_HDRS ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.h)
add_definitions(-DHAVE_PROTOBUF=1)
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.cc OUTPUT ${PROTOBUF_SRCS} ${PROTOBUF_HDRS}
${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.h
COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/src/caffe/compiled/caffe.tar.gz COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/src/caffe/compiled/caffe.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Unpacking compiled caffe protobuf files" COMMENT "Unpacking compiled caffe protobuf files"
VERBATIM VERBATIM
) )
set_source_files_properties(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} PROPERTIES GENERATED TRUE)
set(PROTOBUF_LIBRARIES libprotobuf)
set(PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf/src ${CMAKE_CURRENT_BINARY_DIR})
set(PROTOBUF_SRCS ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.cc)
set(PROTOBUF_HDRS ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.h)
set(PROTOBUF_PROTOC_EXECUTABLE "")
add_definitions(-DHAVE_PROTOBUF=1)
endif() endif()
Loading…
Cancel
Save