From fbb820c284d8aad7dcbc343def8aeea9a151d33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20=C5=9Aleszy=C5=84ski?= Date: Fri, 28 May 2021 10:46:50 +0200 Subject: [PATCH] [BH-357] Move protobuf to third-party dir * Use the CMakeLists.txt from lib authors. * Disable building libprotobuf in the all target. * Disable warnings in the libprotobuf-lite target. --- .gitmodules | 2 +- cmake/modules/PureCoverage.cmake | 2 +- doc/Doxyfile.in | 6 +- module-utils/CMakeLists.txt | 1 - module-utils/protobuf | 1 - module-utils/third-party/libphonenumber.cmake | 6 +- module-utils/third-party/protobuf-lite.cmake | 64 ------------------- third-party/CMakeLists.txt | 3 +- third-party/protobuf/CMakeLists.txt | 3 + third-party/protobuf/src | 1 + 10 files changed, 11 insertions(+), 78 deletions(-) delete mode 160000 module-utils/protobuf delete mode 100644 module-utils/third-party/protobuf-lite.cmake create mode 100644 third-party/protobuf/CMakeLists.txt create mode 160000 third-party/protobuf/src diff --git a/.gitmodules b/.gitmodules index 17fe83ecc..7569599a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,7 +17,7 @@ branch = rt1051 shallow = true [submodule "module-utils/protobuf"] - path = module-utils/protobuf + path = third-party/protobuf/src url = ../protobuf.git branch = rt1051 shallow = true diff --git a/cmake/modules/PureCoverage.cmake b/cmake/modules/PureCoverage.cmake index cc6e78397..25ac8ded5 100644 --- a/cmake/modules/PureCoverage.cmake +++ b/cmake/modules/PureCoverage.cmake @@ -19,6 +19,7 @@ if(COVERAGE_ENABLE) .*/test/.* .*/tests/.* .*/thirdparty/.* + .*/third-party/.* board/linux/libiosyscalls/.* host-tools/.* module-audio/Audio/decoder/dr_flac.h @@ -30,7 +31,6 @@ if(COVERAGE_ENABLE) module-utils/gsl/.* module-utils/json/.* module-utils/libphonenumber/.* - module-utils/protobuf/.* module-utils/re2/.* module-utils/segger/.* module-utils/taglib/.* diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index ff03bb991..a0a87e7b5 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -887,12 +887,9 @@ RECURSIVE = YES EXCLUDE = @PROJECT_SOURCE_DIR@/module-bluetooth/lib \ @PROJECT_SOURCE_DIR@/module-utils/tinyfsm \ - @PROJECT_SOURCE_DIR@/third-party/microtar \ @PROJECT_SOURCE_DIR@/module-utils/segger \ - @PROJECT_SOURCE_DIR@/third-party/crc32 \ @PROJECT_SOURCE_DIR@/module-utils/sbini \ @PROJECT_SOURCE_DIR@/module-utils/re2 \ - @PROJECT_SOURCE_DIR@/module-utils/protobuf \ @PROJECT_SOURCE_DIR@/module-utils/libphonenumber \ @PROJECT_SOURCE_DIR@/module-utils/test \ @PROJECT_SOURCE_DIR@/module-db/tests \ @@ -906,7 +903,8 @@ EXCLUDE = @PROJECT_SOURCE_DIR@/module-bluetooth/lib \ @PROJECT_SOURCE_DIR@/module-vfs/tests \ @PROJECT_SOURCE_DIR@/module-vfs/board \ @PROJECT_SOURCE_DIR@/module-bsp/board/rt1051/common \ - @PROJECT_SOURCE_DIR@/module-audio/Audio/decoder/taglib + @PROJECT_SOURCE_DIR@/module-audio/Audio/decoder/taglib \ + @PROJECT_SOURCE_DIR@/third-party # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/module-utils/CMakeLists.txt b/module-utils/CMakeLists.txt index eb850016d..201b47fbf 100644 --- a/module-utils/CMakeLists.txt +++ b/module-utils/CMakeLists.txt @@ -50,7 +50,6 @@ include(segger/rtt/CMakeLists.txt) # add third party libs include(third-party/re2.cmake) -include(third-party/protobuf-lite.cmake) include(third-party/libphonenumber.cmake) # link against libphonenumber diff --git a/module-utils/protobuf b/module-utils/protobuf deleted file mode 160000 index 1733c4f16..000000000 --- a/module-utils/protobuf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1733c4f163746471c720d99100110f078b5dcd44 diff --git a/module-utils/third-party/libphonenumber.cmake b/module-utils/third-party/libphonenumber.cmake index 5d5077550..5740b0e87 100644 --- a/module-utils/third-party/libphonenumber.cmake +++ b/module-utils/third-party/libphonenumber.cmake @@ -67,11 +67,7 @@ if (NOT RE2_TARGET) endif () target_link_libraries (${LIBPHONENUMBER_TARGET} PUBLIC ${RE2_TARGET}) -# protobuf dependency -if (NOT PROTOBUF_TARGET) - message (FATAL_ERROR "Protobuf is required for libphonenumber") -endif() -target_link_libraries (${LIBPHONENUMBER_TARGET} PUBLIC ${PROTOBUF_TARGET}) +target_link_libraries (${LIBPHONENUMBER_TARGET} PUBLIC protobuf::libprotobuf-lite) # turn on optimization in debug third_party_source_optimization (${LIBPHONENUMBER_SOURCES}) diff --git a/module-utils/third-party/protobuf-lite.cmake b/module-utils/third-party/protobuf-lite.cmake deleted file mode 100644 index 703e4d4c9..000000000 --- a/module-utils/third-party/protobuf-lite.cmake +++ /dev/null @@ -1,64 +0,0 @@ -include (thirdparty) - -# add sources -set (PROTOBUF_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/src) -set (PROTOBUF ${PROTOBUF_SRCDIR}/google/protobuf) -set (PROTOBUF_SOURCES - ${PROTOBUF}/any_lite.cc - ${PROTOBUF}/arena.cc - ${PROTOBUF}/extension_set.cc - ${PROTOBUF}/generated_enum_util.cc - ${PROTOBUF}/generated_message_table_driven_lite.cc - ${PROTOBUF}/generated_message_util.cc - ${PROTOBUF}/implicit_weak_message.cc - ${PROTOBUF}/io/coded_stream.cc - ${PROTOBUF}/io/io_win32.cc - ${PROTOBUF}/io/strtod.cc - ${PROTOBUF}/io/zero_copy_stream.cc - ${PROTOBUF}/io/zero_copy_stream_impl.cc - ${PROTOBUF}/io/zero_copy_stream_impl_lite.cc - ${PROTOBUF}/message_lite.cc - ${PROTOBUF}/parse_context.cc - ${PROTOBUF}/repeated_field.cc - ${PROTOBUF}/stubs/bytestream.cc - ${PROTOBUF}/stubs/common.cc - ${PROTOBUF}/stubs/int128.cc - ${PROTOBUF}/stubs/status.cc - ${PROTOBUF}/stubs/statusor.cc - ${PROTOBUF}/stubs/stringpiece.cc - ${PROTOBUF}/stubs/stringprintf.cc - ${PROTOBUF}/stubs/structurally_valid.cc - ${PROTOBUF}/stubs/strutil.cc - ${PROTOBUF}/stubs/time.cc - ${PROTOBUF}/wire_format_lite.cc -) - -# create static library for the third party -set (PROTOBUF_TARGET protobuf) -add_library (${PROTOBUF_TARGET} STATIC ${PROTOBUF_SOURCES}) - -# setup flags for the third party -third_party_target_setup (${PROTOBUF_TARGET}) - -# set compile definitions for third party libraries -target_compile_definitions (${PROTOBUF_TARGET} PUBLIC GOOGLE_PROTOBUF_NO_THREADS) - -# supress warnings for protobuf -set_source_files_properties (${PROTOBUF_SOURCES} - PROPERTIES COMPILE_FLAGS - "-Wno-stringop-truncation \ - -Wno-stringop-overflow \ - -Wno-sign-compare \ - -Wno-type-limits \ - -Wno-redundant-move \ - -Wno-maybe-uninitialized" -) - -# add include dir -target_include_directories (${PROTOBUF_TARGET} PUBLIC ${PROTOBUF_SRCDIR}) - -# module-os dependency (locking support) -target_link_libraries (${RE2_TARGET} PUBLIC module-os) - -# turn on optimization in debug -third_party_source_optimization (${PROTOBUF_SOURCES}) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index f54a067ed..8425b24ed 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(crc32) +add_subdirectory(crc32) add_subdirectory(magic_enum) add_subdirectory(microtar) add_subdirectory(date) @@ -7,3 +7,4 @@ add_subdirectory(sml) add_subdirectory(minimp3) add_subdirectory(tinyexpr) add_subdirectory(parallel-hashmap) +add_subdirectory(protobuf) diff --git a/third-party/protobuf/CMakeLists.txt b/third-party/protobuf/CMakeLists.txt new file mode 100644 index 000000000..b5b1ad086 --- /dev/null +++ b/third-party/protobuf/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(src/cmake) +set_target_properties(libprotobuf PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) +target_compile_options(libprotobuf-lite PRIVATE -w) diff --git a/third-party/protobuf/src b/third-party/protobuf/src new file mode 160000 index 000000000..2555e35fc --- /dev/null +++ b/third-party/protobuf/src @@ -0,0 +1 @@ +Subproject commit 2555e35fc68441e76618621be0815fe343201fdf