1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
From 8a2a2327e89fb62bb74ced121cbdf8c3a59ad04f Mon Sep 17 00:00:00 2001
From: Alejandro Alvarez Ayllon <a.alvarezayllon@gmail.com>
Date: Sat, 24 Feb 2024 14:48:45 +0100
Subject: [PATCH 0/6] Build shared libraries and fix install location
---
CMakeLists.txt | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dd56b6e..7f79cc9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -470,7 +470,7 @@
list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src})
list(APPEND ONNX_SRCS ${__tmp_srcs})
-add_library(onnx_proto ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS})
+add_library(onnx_proto SHARED ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS})
add_dependencies(onnx_proto gen_onnx_operators_proto gen_onnx_data_proto)
target_include_directories(onnx_proto PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
@@ -495,6 +495,8 @@
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
+ set_target_properties(onnx_proto PROPERTIES VERSION ${ONNX_VERSION}
+ SOVERSION ${ONNX_VERSION})
endif()
target_compile_definitions(onnx_proto PRIVATE ${ONNX_API_DEFINE})
target_compile_features(onnx_proto PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
@@ -519,10 +521,12 @@
# So, create a object library
add_library(onnx OBJECT ${ONNX_SRCS})
else()
- add_library(onnx ${ONNX_SRCS})
+ add_library(onnx SHARED ${ONNX_SRCS})
+ set_target_properties(onnx PROPERTIES VERSION ${ONNX_VERSION}
+ SOVERSION ${ONNX_VERSION})
endif()
-set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET hidden)
-set_target_properties(onnx PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
+set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET default)
+set_target_properties(onnx PROPERTIES VISIBILITY_INLINES_HIDDEN OFF)
target_include_directories(onnx PUBLIC
$<BUILD_INTERFACE:${ONNX_ROOT}>
@@ -669,6 +673,17 @@
FILES_MATCHING
PATTERN "*.h")
+install(DIRECTORY ${ONNX_ROOT}/onnx
+ DESTINATION "${PY_SITEARCH}"
+ FILES_MATCHING
+ PATTERN "*.py"
+ PATTERN "test/*" EXCLUDE )
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/onnx
+ DESTINATION "${PY_SITEARCH}"
+ FILES_MATCHING
+ PATTERN "*.py"
+ PATTERN "test/*" EXCLUDE )
+
configure_file(
${PROJECT_SOURCE_DIR}/cmake/ONNXConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/ONNXConfigVersion.cmake
@@ -727,7 +742,9 @@
install(TARGETS
onnx onnx_proto
EXPORT ONNXTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
-
+install(TARGETS
+ onnx_cpp2py_export
+ DESTINATION "${PY_SITEARCH}/onnx")
if(ONNX_BUILD_TESTS)
include(${ONNX_ROOT}/cmake/unittest.cmake)
endif()
--
2.43.0
|