Skip to content

Commit

Permalink
Try fix msvc error and cmake error on android
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Lyudvichenko committed Aug 19, 2015
1 parent fc9795b commit 93a372f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
11 changes: 6 additions & 5 deletions modules/dnn/3rdparty/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ 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)
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()
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()

# Easier to support different versions of protobufs
Expand Down Expand Up @@ -171,6 +172,6 @@ if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(libprotobuf PROPERTIES FOLDER "3rdparty")
endif()

#if(NOT BUILD_SHARED_LIBS)
# ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
#endif()
if(NOT BUILD_SHARED_LIBS)
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stl_util.h>
#include <algorithm>

namespace google {
namespace protobuf {
Expand Down Expand Up @@ -63,7 +64,7 @@ ArrayInputStream::~ArrayInputStream() {

bool ArrayInputStream::Next(const void** data, int* size) {
if (position_ < size_) {
last_returned_size_ = min(block_size_, size_ - position_);
last_returned_size_ = std::min(block_size_, size_ - position_);
*data = data_ + position_;
*size = last_returned_size_;
position_ += last_returned_size_;
Expand Down Expand Up @@ -116,7 +117,7 @@ ArrayOutputStream::~ArrayOutputStream() {

bool ArrayOutputStream::Next(void** data, int* size) {
if (position_ < size_) {
last_returned_size_ = min(block_size_, size_ - position_);
last_returned_size_ = std::min(block_size_, size_ - position_);
*data = data_ + position_;
*size = last_returned_size_;
position_ += last_returned_size_;
Expand Down Expand Up @@ -163,7 +164,7 @@ bool StringOutputStream::Next(void** data, int* size) {
// that the new size is at least kMinimumSize.
STLStringResizeUninitialized(
target_,
max(old_size * 2,
std::max(old_size * 2,
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
}

Expand All @@ -190,7 +191,7 @@ int CopyingInputStream::Skip(int count) {
char junk[4096];
int skipped = 0;
while (skipped < count) {
int bytes = Read(junk, min(count - skipped,
int bytes = Read(junk, std::min(count - skipped,
implicit_cast<int>(sizeof(junk))));
if (bytes <= 0) {
// EOF or read error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
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.
#define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE) \
template <> \
Expand Down
18 changes: 8 additions & 10 deletions modules/dnn/cmake/find_protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ endif()

if(NOT BUILD_LIBPROTOBUF_FROM_SOURCES AND PROTOBUF_FOUND AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
message(STATUS "The protocol buffer compiler and libprotobuf were found")

PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS src/caffe/caffe.proto)
add_definitions(-DHAVE_PROTOBUF=1)
else()
Expand All @@ -18,19 +17,18 @@ else()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf)
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(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.cc
${CMAKE_CURRENT_BINARY_DIR}/caffe.pb.h
OUTPUT ${PROTOBUF_SRCS} ${PROTOBUF_HDRS}
COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/src/caffe/compiled/caffe.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Unpacking compiled caffe protobuf files"
VERBATIM
)

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)
set_source_files_properties(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} PROPERTIES GENERATED TRUE)
endif()

0 comments on commit 93a372f

Please sign in to comment.