File make-onnx_proto-shared-lib.patch of Package python-onnxruntime

From 4cf9a3d82710cc16671ebc635f168197d18627f6 Mon Sep 17 00:00:00 2001
From: Christian Goll <cgoll@suse.de>
Date: Tue, 7 Jul 2020 11:22:40 +0200
Subject: [PATCH] make onnx_proto shared lib

---
 cmake/onnx/CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cmake/onnx/CMakeLists.txt b/cmake/onnx/CMakeLists.txt
index 79177911d..8ecdf5b2d 100644
--- a/cmake/onnx/CMakeLists.txt
+++ b/cmake/onnx/CMakeLists.txt
@@ -3,7 +3,8 @@
 
 #TODO: if protobuf is a shared lib and onnxruntime_USE_FULL_PROTOBUF is ON, then onnx_proto should be built as a shared lib instead of a static lib. Otherwise any code outside onnxruntime.dll can't use onnx protobuf definitions if they share the protobuf.dll with onnxruntime. For example, if protobuf is a shared lib and onnx_proto is a static lib then onnxruntime_perf_test won't work.
 
-add_library(onnx_proto ${ONNXRUNTIME_ROOT}/core/protobuf/onnx-ml.proto ${ONNXRUNTIME_ROOT}/core/protobuf/onnx-operators-ml.proto)
+add_library(onnx_proto SHARED ${ONNXRUNTIME_ROOT}/core/protobuf/onnx-ml.proto ${ONNXRUNTIME_ROOT}/core/protobuf/onnx-operators-ml.proto)
+target_link_libraries(onnx_proto PUBLIC protobuf)
 target_include_directories(onnx_proto PUBLIC $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES> "${CMAKE_CURRENT_BINARY_DIR}/..")
 target_compile_definitions(onnx_proto PUBLIC $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>)
 onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${ONNXRUNTIME_ROOT}/core/protobuf TARGET onnx_proto)
@@ -36,7 +37,8 @@ if (MSVC)
 endif()
 
 list(REMOVE_ITEM onnx_src ${onnx_exclude_src})
-add_library(onnx ${onnx_src})
+add_library(onnx SHARED ${onnx_src})
+target_link_libraries(onnx PUBLIC onnx_proto)
 add_dependencies(onnx onnx_proto)
 target_include_directories(onnx PUBLIC "${ONNX_SOURCE_ROOT}")
 target_include_directories(onnx PUBLIC $<TARGET_PROPERTY:onnx_proto,INTERFACE_INCLUDE_DIRECTORIES>)
-- 
2.26.2

openSUSE Build Service is sponsored by