File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ install(
106106 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /executorch/kernels/portable/
107107)
108108
109+ if (EXECUTORCH_BUILD_SHARED)
110+ executorch_add_shared_library (
111+ executorch_portable_ops portable_ops_lib portable_kernels executorch_shared
112+ )
113+ endif ()
114+
109115# Build the portable custom ops AOT library for registering custom ops into
110116# PyTorch. Requires find_package(Torch), which must be called at root scope
111117# before this subdirectory is processed. Not targeting ARM_BAREMETAL as aot_lib
Original file line number Diff line number Diff line change @@ -211,3 +211,29 @@ function(executorch_target_copy_mlx_metallib target)
211211 endif ()
212212 endif ()
213213endfunction ()
214+
215+ # Create and install a shared library composed from dependency libraries. The
216+ # target links the provided dependencies and carries VERSION/SOVERSION.
217+ function (executorch_add_shared_library target_name )
218+ set (_empty_source_name "${target_name} _empty.cpp" )
219+ file (WRITE "${CMAKE_CURRENT_BINARY_DIR} /${_empty_source_name} "
220+ "// intentionally empty"
221+ )
222+ add_library (
223+ ${target_name} SHARED "${CMAKE_CURRENT_BINARY_DIR} /${_empty_source_name} "
224+ )
225+ target_link_libraries (${target_name} PRIVATE ${ARGN} )
226+ set_target_properties (
227+ ${target_name}
228+ PROPERTIES VERSION "${PROJECT_VERSION} "
229+ SOVERSION "${PROJECT_VERSION_MAJOR} "
230+ LINKER_LANGUAGE CXX
231+ )
232+ install (
233+ TARGETS ${target_name}
234+ EXPORT ExecuTorchTargets
235+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
236+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
237+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
238+ )
239+ endfunction ()
You can’t perform that action at this time.
0 commit comments