diff --git a/conanfile.txt b/conanfile.txt index 33413b613db..a5aecb83b53 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -2,7 +2,7 @@ ade/0.1.2a onetbb/[>=2021.2.1] pugixml/[>=1.10] -protobuf/[>=3.20.3] +protobuf/3.21.9 ittapi/[>=3.23.0] zlib/[>=1.2.8] opencl-icd-loader/2023.04.17 @@ -19,7 +19,7 @@ flatbuffers/[>=22.9.24] [tool_requires] cmake/[>=3.15] patchelf/[>=0.12] -protobuf/[>=3.20.3] +protobuf/3.21.9 flatbuffers/[>=22.9.24] [options] diff --git a/src/frontends/common/shutdown_protobuf/CMakeLists.txt b/src/frontends/common/shutdown_protobuf/CMakeLists.txt index 4b0c2309abb..affac6ef605 100644 --- a/src/frontends/common/shutdown_protobuf/CMakeLists.txt +++ b/src/frontends/common/shutdown_protobuf/CMakeLists.txt @@ -9,3 +9,4 @@ add_library(${TARGET_NAME} STATIC shutdown_protobuf.cpp) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $>) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) +target_compile_features(${TARGET_NAME} PRIVATE $) diff --git a/src/frontends/onnx/frontend/src/frontend.cpp b/src/frontends/onnx/frontend/src/frontend.cpp index 4108070c4f2..3ed28b64737 100644 --- a/src/frontends/onnx/frontend/src/frontend.cpp +++ b/src/frontends/onnx/frontend/src/frontend.cpp @@ -2,7 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include +#if PROTOBUF_VERSION >= 4022000 // protobuf 4.22 +# define OV_PROTOBUF_ABSL_IS_USED +#endif +#include + +#ifndef OV_PROTOBUF_ABSL_IS_USED +# include +#endif #include #include @@ -37,7 +45,9 @@ ONNX_FRONTEND_C_API void* get_front_end_data() { }; #ifndef OPENVINO_DEBUG_ENABLE // disable protobuf logging +# ifndef OV_PROTOBUF_ABSL_IS_USED google::protobuf::SetLogHandler(nullptr); +# endif #endif return res; } diff --git a/src/frontends/paddle/src/frontend.cpp b/src/frontends/paddle/src/frontend.cpp index 340f3e9722a..3ad7c9955de 100644 --- a/src/frontends/paddle/src/frontend.cpp +++ b/src/frontends/paddle/src/frontend.cpp @@ -4,7 +4,15 @@ #include "openvino/frontend/paddle/frontend.hpp" -#include +#include +#if PROTOBUF_VERSION >= 4022000 // protobuf 4.22 +# define OV_PROTOBUF_ABSL_IS_USED +#endif +#include + +#ifndef OV_PROTOBUF_ABSL_IS_USED +# include +#endif #include #include @@ -551,7 +559,9 @@ PADDLE_C_API void* get_front_end_data() { #ifndef OPENVINO_DEBUG_ENABLE // disable protobuf logging +# ifndef OV_PROTOBUF_ABSL_IS_USED google::protobuf::SetLogHandler(nullptr); +# endif #endif return res; } diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake index e815baa80ce..c209d9ae44c 100644 --- a/thirdparty/dependencies.cmake +++ b/thirdparty/dependencies.cmake @@ -446,8 +446,16 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND if(CMAKE_VERBOSE_MAKEFILE) set(Protobuf_DEBUG ON) endif() - # Note: we also specify 'protobuf' in NAMES because vcpkg - find_package(Protobuf 3.20.3 REQUIRED NAMES Protobuf protobuf) + # Note: we also specify 'protobuf' in NAMES because of vcpkg + set(find_package_protobuf_names Protobuf protobuf) + # try to find newer version first (major is changed) + # see https://protobuf.dev/support/version-support/ and + # https://github.com/protocolbuffers/protobuf/commit/d61f75ff6db36b4f9c0765f131f8edc2f86310fa + find_package(Protobuf 4.22.0 QUIET NAMES ${find_package_protobuf_names}) + if(NOT Protobuf_FOUND) + # otherwise, fallback to existing default + find_package(Protobuf 3.20.3 REQUIRED NAMES ${find_package_protobuf_names}) + endif() set(PROTOC_EXECUTABLE protobuf::protoc) else() add_subdirectory(thirdparty/protobuf EXCLUDE_FROM_ALL) diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index 05eb9ac964f..19d8aabd4ef 100644 --- a/thirdparty/onnx/CMakeLists.txt +++ b/thirdparty/onnx/CMakeLists.txt @@ -49,7 +49,6 @@ endforeach() if(WIN32) # from onnx==1.13.1 it requires C++17 when compiling on Windows target_compile_features(onnx PRIVATE cxx_std_17) - set_target_properties(onnx PROPERTIES CXX_STANDARD 17) # OPTIONAL is a reserved word for mingw at least if(MINGW) target_compile_definitions(onnx PRIVATE OPTIONAL=OPTIONAL_PLACEHOLDER) diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt index 2c05ba7360c..1e782987d01 100644 --- a/thirdparty/protobuf/CMakeLists.txt +++ b/thirdparty/protobuf/CMakeLists.txt @@ -22,6 +22,7 @@ set(protobuf_VERBOSE ON) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE) set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE) set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support" FORCE) +set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "Abseil protogate CXX standard to dependent targets" FORCE) # note: HOST_AARCH64 AND X86_64 are not handled for Apple explicitly, because it can work via Rosetta if(CMAKE_CROSSCOMPILING OR @@ -38,8 +39,14 @@ if(NOT DEFINED protobuf_MSVC_STATIC_RUNTIME) set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link protobuf to static runtime libraries" FORCE) endif() -add_subdirectory(protobuf/cmake EXCLUDE_FROM_ALL) -get_directory_property(protobuf_VERSION DIRECTORY protobuf/cmake DEFINITION protobuf_VERSION) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/protobuf/CMakeLists.txt") + set(protobuf_dir protobuf) +else() + set(protobuf_dir protobuf/cmake) +endif() + +add_subdirectory(${protobuf_dir} EXCLUDE_FROM_ALL) +get_directory_property(protobuf_VERSION DIRECTORY ${protobuf_dir} DEFINITION protobuf_VERSION) set(Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/src) @@ -61,7 +68,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) endif() -if(protobuf_VERSION VERSION_LESS "3.9") +if(protobuf_VERSION VERSION_LESS 3.9) message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0 (provided ${protobuf_VERSION})") endif() @@ -76,7 +83,7 @@ if(NOT protobuf_BUILD_PROTOC_BINARIES) CMAKE_ARGS "-Dprotobuf_VERBOSE=${protobuf_VERBOSE}" "-Dprotobuf_BUILD_TESTS=${protobuf_BUILD_TESTS}" "-Dprotobuf_WITH_ZLIB=${protobuf_WITH_ZLIB}" - NATIVE_SOURCE_SUBDIR "protobuf/cmake" + NATIVE_SOURCE_SUBDIR "${protobuf_dir}" NATIVE_TARGETS protoc libprotobuf-lite) set(PROTOC_EXECUTABLE "${HOST_PROTOC_INSTALL_DIR}/bin/protoc")