CMakeLists.txt 6.72 KB
Newer Older
1 2 3 4
project(libprotobuf)

include(CheckIncludeFiles)

5 6 7 8
if(NOT MSVC)
  check_include_files("pthread.h" HAVE_PTHREAD)
  if(HAVE_PTHREAD)
    add_definitions(-DHAVE_PTHREAD=1)
9 10 11 12 13
  endif()
endif()

if(MSVC)
  add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
14 15 16 17
  ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
                                       /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
                                       /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
  )
18
else()
19 20 21 22
  ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
                                       -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
                                       -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
                                       -Wunused-function -Wunused-const-variable
23
  )
24
endif()
25 26 27 28 29
if(CV_ICC)
  ocv_warnings_disable(CMAKE_CXX_FLAGS
      -wd265 -wd858 -wd873 -wd2196
  )
endif()
30 31 32 33 34 35 36 37 38 39 40 41 42 43

# Easier to support different versions of protobufs
function(append_if_exist OUTPUT_LIST)
    set(${OUTPUT_LIST})
    foreach(fil ${ARGN})
        if(EXISTS ${fil})
            list(APPEND ${OUTPUT_LIST} "${fil}")
        else()
            message(WARNING "file missing: ${fil}")
        endif()
    endforeach()
    set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE)
endfunction()

Maksim Shabunin's avatar
Maksim Shabunin committed
44
set(PROTOBUF_ROOT "${PROTOBUF_CPP_ROOT}")
45 46 47 48 49 50 51

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

52

53
append_if_exist(PROTOBUF_SRCS
54 55 56
# libprotobuf-lite
  ${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
57 58 59 60 61 62 63 64
  ${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc
  ${ATOMICOPS_INTERNALS}
65
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
66
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
67
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
68
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
69 70 71
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringpiece.cc
72 73 74
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/time.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc
# libprotobuf
  ${PROTOBUF_ROOT}/src/google/protobuf/any.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/any.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/api.pb.cc
#  ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc
#  ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/duration.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/empty.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/map_field.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/message.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/service.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/source_context.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/struct.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/mathlimits.cc
104 105
  ${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc
106 107
  ${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
108
  ${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  ${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/default_value_objectwriter.cc
#  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/error_listener.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/field_mask_utility.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_escaping.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_objectwriter.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_stream_parser.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/object_writer.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/proto_writer.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectsource.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectwriter.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info.cc
#  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info_test_helper.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/utility.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/json_util.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/message_differencer.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/time_util.cc
  ${PROTOBUF_ROOT}/src/google/protobuf/util/type_resolver_util.cc
129
  ${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc
130
  ${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc
131 132
)

133
if(CMAKE_VERSION VERSION_LESS 2.8.9 AND UNIX)
134 135 136 137
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()

add_library(libprotobuf STATIC ${PROTOBUF_SRCS})
138
include_directories(${PROTOBUF_ROOT}/src)
139 140 141

set_target_properties(libprotobuf
    PROPERTIES
142 143
    FOLDER "3rdparty"
    POSITION_INDEPENDENT_CODE 1    # CMake 2.8.9+
144 145 146 147 148 149 150
    OUTPUT_NAME libprotobuf
    DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
    ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
    )

if(NOT BUILD_SHARED_LIBS)
  ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
151
endif()