Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Fix cmake install for static libraries (#38017)

Oleg Pipikin0ce26b811790
diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake
index e1683fe4796..285323032ef 100644
--- a/cmake/developer_package/packaging/packaging.cmake
+++ b/cmake/developer_package/packaging/packaging.cmake
@@ -166,46 +166,6 @@ macro(ov_install_static_deps _ov_isd_targets_var _ov_isd_comp)
unset(_ov_isd_all)
endmacro()
-#
-# ov_register_static_deps_in_export(<targets-list-variable> <export-set-name>)
-#
-# Registers every target in <targets-list-variable> and all of their
-# non-imported transitive link dependencies into a NAMED export set without
-# the BUILD_SHARED_LIBS guard that ov_install_static_deps has.
-#
-macro(ov_register_static_deps_in_export _ov_rsde_targets_var _ov_rsde_export)
- _ov_static_deps_new_epoch()
- set_property(GLOBAL PROPERTY _OV_STATIC_DEP_RESULT "")
- foreach(_ov_rsde_root IN LISTS ${_ov_rsde_targets_var})
- if(TARGET "${_ov_rsde_root}")
- _ov_collect_static_deps_impl("${_ov_rsde_root}")
- endif()
- endforeach()
- get_property(_ov_rsde_all GLOBAL PROPERTY _OV_STATIC_DEP_RESULT)
- foreach(_ov_rsde_dep IN LISTS _ov_rsde_all)
- get_target_property(_ov_rsde_alias "${_ov_rsde_dep}" ALIASED_TARGET)
- if(_ov_rsde_alias)
- set(_ov_rsde_real "${_ov_rsde_alias}")
- else()
- set(_ov_rsde_real "${_ov_rsde_dep}")
- endif()
- get_target_property(_ov_rsde_imp "${_ov_rsde_real}" IMPORTED)
- if(NOT _ov_rsde_imp)
- install(TARGETS "${_ov_rsde_real}"
- EXPORT "${_ov_rsde_export}"
- ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR}
- COMPONENT ${OV_CPACK_COMP_CORE}
- ${OV_CPACK_COMP_CORE_EXCLUDE_ALL})
- endif()
- endforeach()
- unset(_ov_rsde_root)
- unset(_ov_rsde_dep)
- unset(_ov_rsde_real)
- unset(_ov_rsde_alias)
- unset(_ov_rsde_imp)
- unset(_ov_rsde_all)
-endmacro()
-
#
# ov_install_static_lib(<target> <comp>)
#
diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt
index 8250c65246e..82291751e87 100644
--- a/thirdparty/onnx/CMakeLists.txt
+++ b/thirdparty/onnx/CMakeLists.txt
@@ -69,6 +69,7 @@ set(ONNX_USE_PROTOBUF_SHARED_LIBS OFF CACHE BOOL "Use dynamic protobuf by ONNX l
set(ONNX_NAMESPACE ${OV_ONNX_NAMESPACE})
set(ONNX_USE_LITE_PROTO ${ONNX_USE_LITE_PROTO_DEFAULT} CACHE BOOL "Use protobuf lite for ONNX library" FORCE)
set(ONNX_ML ON CACHE BOOL "Use ONNX ML" FORCE)
+set(ONNX_INSTALL OFF CACHE BOOL "Install ONNX targets, headers and CMake config files" FORCE)
set(ONNX_CUSTOM_PROTOC_EXECUTABLE "${PROTOC_EXECUTABLE}")
# build targets
@@ -99,28 +100,3 @@ ov_disable_all_warnings(onnx onnx_proto)
ov_install_static_lib(onnx ${OV_CPACK_COMP_CORE})
ov_install_static_lib(onnx_proto ${OV_CPACK_COMP_CORE})
-
-# WA for ONNX: protobuf must be findable via an export set when CMake validates
-# install(EXPORT ONNXTargets ...) at configure time.
-if(NOT ENABLE_SYSTEM_PROTOBUF)
- if(ONNX_USE_LITE_PROTO)
- set(_onnx_protobuf_root libprotobuf-lite)
- else()
- set(_onnx_protobuf_root libprotobuf)
- endif()
-
- if(BUILD_SHARED_LIBS)
- # Shared build: register libprotobuf and ALL transitive deps in ONNXTargets.
- set(_onnx_pb_roots "${_onnx_protobuf_root}")
- ov_register_static_deps_in_export(_onnx_pb_roots ONNXTargets)
- unset(_onnx_pb_roots)
- else()
- # Static build: add just libprotobuf to ONNXTargets (original WA).
- install(TARGETS "${_onnx_protobuf_root}" EXPORT ONNXTargets
- ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR}
- COMPONENT ${OV_CPACK_COMP_CORE}
- ${OV_CPACK_COMP_CORE_EXCLUDE_ALL})
- endif()
-
- unset(_onnx_protobuf_root)
-endif()