onnxruntime/cmake/patches/ngraph/ngraph_protobuf.patch
2020-02-12 14:47:00 -08:00

66 lines
2.8 KiB
Diff

cmake/external_protobuf.cmake | 21 ++++++++++++++-------
src/ngraph/frontend/onnx_import/CMakeLists.txt | 4 ++--
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/cmake/external_protobuf.cmake b/cmake/external_protobuf.cmake
index 32217f5d6..d33e9c631 100644
--- a/cmake/external_protobuf.cmake
+++ b/cmake/external_protobuf.cmake
@@ -23,7 +23,7 @@ include(ExternalProject)
# This version of PROTOBUF is required by Microsoft ONNX Runtime.
set(NGRAPH_PROTOBUF_GIT_REPO_URL "https://github.com/protocolbuffers/protobuf")
-set(NGRAPH_PROTOBUF_GIT_TAG "v3.5.2")
+set(NGRAPH_PROTOBUF_GIT_TAG "v3.11.3")
if (WIN32)
ExternalProject_Add(
@@ -84,12 +84,19 @@ else()
endif()
set(Protobuf_LIBRARIES ${Protobuf_LIBRARY})
-if (NOT TARGET protobuf::libprotobuf)
- add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
- set_target_properties(protobuf::libprotobuf PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
- IMPORTED_LOCATION "${Protobuf_LIBRARY}")
- add_dependencies(protobuf::libprotobuf ext_protobuf)
+if (NOT TARGET libprotobuf)
+ add_library(libprotobuf INTERFACE)
+ if (WIN32)
+ target_link_libraries(libprotobuf INTERFACE
+ debug ${Protobuf_INSTALL_PREFIX}/lib/libprotobufd.lib
+ optimized ${Protobuf_INSTALL_PREFIX}/lib/libprotobuf.lib)
+ else()
+ target_link_libraries(libprotobuf INTERFACE
+ ${Protobuf_INSTALL_PREFIX}/lib/libprotobuf.a)
+ endif()
+ set_target_properties(libprotobuf PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}")
+ add_dependencies(libprotobuf ext_protobuf)
endif()
if (NOT TARGET protobuf::protoc)
diff --git a/src/ngraph/frontend/onnx_import/CMakeLists.txt b/src/ngraph/frontend/onnx_import/CMakeLists.txt
index bf6e73d2c..381577159 100644
--- a/src/ngraph/frontend/onnx_import/CMakeLists.txt
+++ b/src/ngraph/frontend/onnx_import/CMakeLists.txt
@@ -194,13 +194,13 @@ add_library(onnx_import STATIC
set(ONNX_IMPORT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
-add_dependencies(onnx_import_interface protobuf::libprotobuf onnx::libonnx onnx::libonnx_proto)
+add_dependencies(onnx_import_interface libprotobuf onnx::libonnx onnx::libonnx_proto)
add_dependencies(onnx_import onnx_import_interface)
set_property(TARGET onnx_import PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(onnx_import PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
-target_link_libraries(onnx_import PRIVATE ${Protobuf_LIBRARIES} ${ONNX_PROTO_LIBRARY})
+target_link_libraries(onnx_import PRIVATE libprotobuf ${ONNX_PROTO_LIBRARY})
target_compile_definitions(onnx_import PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
--
2.13.0.windows.1