diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index 4138aed19f4e77..4ab78f5cfabd00 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -117,6 +117,10 @@ function(ov_add_plugin) # install rules if(NOT OV_PLUGIN_SKIP_INSTALL OR NOT BUILD_SHARED_LIBS) string(TOLOWER "${OV_PLUGIN_DEVICE_NAME}" install_component) + if(NOT BUILD_SHARED_LIBS) + # in case of static libs everything is installed to 'core' + set(install_component ${OV_CPACK_COMP_CORE}) + endif() if(OV_PLUGIN_PSEUDO_DEVICE) set(plugin_hidden HIDDEN) diff --git a/cmake/features.cmake b/cmake/features.cmake index 5dca5b7b21bef1..070d5a6ad73e9b 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -23,7 +23,7 @@ endif() ie_dependent_option (ENABLE_INTEL_GPU "GPU OpenCL-based plugin for OpenVINO Runtime" ${ENABLE_INTEL_GPU_DEFAULT} "X86_64 OR AARCH64;NOT APPLE;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) -if (ANDROID OR MINGW OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) OR NOT BUILD_SHARED_LIBS) +if (ANDROID OR MINGW OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) OR (NOT BUILD_SHARED_LIBS AND ENABLE_INTEL_CPU)) # oneDNN doesn't support old compilers and android builds for now, so we'll build GPU plugin without oneDNN # also, in case of static build CPU's and GPU's oneDNNs will conflict, so we are disabling GPU's one in this case set(ENABLE_ONEDNN_FOR_GPU_DEFAULT OFF) diff --git a/cmake/templates/OpenVINOConfig.cmake.in b/cmake/templates/OpenVINOConfig.cmake.in index 9eb1cfdd35837b..7dda80d8a312fd 100644 --- a/cmake/templates/OpenVINOConfig.cmake.in +++ b/cmake/templates/OpenVINOConfig.cmake.in @@ -223,6 +223,10 @@ macro(_ov_find_tbb) PATHS ${_tbb_bind_dir} NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH) + if(TARGET TBBbind::tbbbind_2_5) + # To solve https://cmake.org/cmake/help/latest/policy/CMP0111.html warnings + set_property(TARGET TBBbind::tbbbind_2_5 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + endif() unset(_tbb_bind_dir) endif() unset(install_tbbbind) @@ -343,11 +347,15 @@ endmacro() macro(_ov_find_intel_cpu_dependencies) set(_OV_ENABLE_CPU_ACL "@DNNL_USE_ACL@") if(_OV_ENABLE_CPU_ACL) - set(_ov_in_install_tree "@PACKAGE_ARM_COMPUTE_LIB_DIR@") + set(_ov_in_install_tree "@PACKAGE_OPENVINO_LIB_DIR@") if(_ov_in_install_tree) - set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_ARM_COMPUTE_LIB_DIR@") + set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_OPENVINO_LIB_DIR@") set(ACL_DIR "${CMAKE_CURRENT_LIST_DIR}") else() + if(NOT TARGET arm_compute::arm_compute) + # for case when build tree is used separately, e.g. OpenVINODeveloperPackageConfig.cmake + set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_CMAKE_ARCHIVE_OUTPUT_DIRECTORY@") + endif() set_and_check(ACL_DIR "@PACKAGE_FIND_ACL_PATH@") endif() @@ -363,16 +371,50 @@ macro(_ov_find_intel_gpu_dependencies) set(_OV_ENABLE_INTEL_GPU "@ENABLE_INTEL_GPU@") set(_OV_ENABLE_SYSTEM_OPENCL "@ENABLE_SYSTEM_OPENCL@") if(_OV_ENABLE_INTEL_GPU AND _OV_ENABLE_SYSTEM_OPENCL) - set(_OV_OpenCLICDLoader_FOUND "@OpenCLICDLoader_FOUND@") - if(_OV_OpenCLICDLoader_FOUND) - _ov_find_dependency(OpenCLICDLoader) - else() - _ov_find_dependency(OpenCL) - endif() - unset(_OV_OpenCLICDLoader_FOUND) + _ov_find_dependency(OpenCL) endif() unset(_OV_ENABLE_INTEL_GPU) unset(_OV_ENABLE_SYSTEM_OPENCL) + + set(_OV_ENABLE_ONEDNN_FOR_GPU "@ENABLE_ONEDNN_FOR_GPU@") + if(_OV_ENABLE_ONEDNN_FOR_GPU AND NOT TARGET onednn_gpu_tgt) + set(_OV_DNNL_GPU_LIBRARY_NAME "@DNNL_GPU_LIBRARY_NAME@") + + set(_ov_in_install_tree "@PACKAGE_OPENVINO_LIB_DIR@") + if(_ov_in_install_tree) + set(onednn_gpu_lib "${CMAKE_STATIC_LIBRARY_PREFIX}${_OV_DNNL_GPU_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") + set_and_check(onednn_gpu_lib_root "@PACKAGE_OPENVINO_LIB_DIR@") + if(WIN32) + if(OV_GENERATOR_MULTI_CONFIG) + set(extra_args PATH_SUFFIXES ${CMAKE_CONFIGURATION_TYPES}) + else() + set(extra_args PATH_SUFFIXES ${CMAKE_BUILD_TYPE}) + endif() + endif() + + find_library(onednn_gpu_lib_path + NAMES ${_OV_DNNL_GPU_LIBRARY_NAME} + PATHS ${onednn_gpu_lib_root} + ${extra_args}) + + if(NOT onednn_gpu_lib_path) + message(FATAL_ERROR "Internal error: failed to find '${_OV_DNNL_GPU_LIBRARY_NAME}' in '${onednn_gpu_lib_root}'") + endif() + + unset(extra_args) + unset(onednn_gpu_lib) + else() + set_and_check(onednn_gpu_lib_path "@PACKAGE_ONEDNN_GPU_LIB_PATH@") + endif() + + set_target_properties(openvino::onednn_gpu_tgt PROPERTIES + INTERFACE_LINK_LIBRARIES "${onednn_gpu_lib_path}") + + unset(onednn_gpu_lib_path) + unset(_ov_in_install_tree) + unset(_OV_DNNL_GPU_LIBRARY_NAME) + endif() + unset(_OV_ENABLE_ONEDNN_FOR_GPU) endmacro() macro(_ov_find_intel_gna_dependencies) @@ -455,6 +497,7 @@ set(_OV_ENABLE_OPENVINO_BUILD_SHARED "@BUILD_SHARED_LIBS@") if(NOT TARGET openvino) set(_ov_as_external_package ON) + include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") endif() if(NOT _OV_ENABLE_OPENVINO_BUILD_SHARED) @@ -487,8 +530,6 @@ set(_ov_imported_libs openvino::runtime openvino::runtime::c openvino::frontend::pytorch openvino::frontend::tensorflow_lite) if(_ov_as_external_package) - include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") - foreach(target IN LISTS _ov_imported_libs) if(TARGET ${target}) get_target_property(imported_configs ${target} IMPORTED_CONFIGURATIONS) diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 14eb6515d27e06..302c263b024e7e 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -157,9 +157,12 @@ if(ENABLE_INTEL_GNA) list(APPEND PATH_VARS "GNA_PATH") endif() if(DNNL_USE_ACL) - list(APPEND BUILD_PATH_VARS "FIND_ACL_PATH") + list(APPEND BUILD_PATH_VARS "FIND_ACL_PATH;CMAKE_ARCHIVE_OUTPUT_DIRECTORY") set(FIND_ACL_PATH "${intel_cpu_thirdparty_SOURCE_DIR}") endif() +if(ENABLE_ONEDNN_FOR_GPU) + list(APPEND BUILD_PATH_VARS "ONEDNN_GPU_LIB_PATH") +endif() set(PUBLIC_HEADERS_DIR "${OpenVINO_SOURCE_DIR}/src/inference/include") set(IE_INCLUDE_DIR "${PUBLIC_HEADERS_DIR}/ie") @@ -177,12 +180,10 @@ configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOCo # install tree -if(DNNL_USE_ACL) - list(APPEND INSTALL_PATH_VARS "ARM_COMPUTE_LIB_DIR") - # remove generator expression at the end, because searching in Release / Debug will be - # done by ACLConfig.cmake itself - string(REPLACE "$" "" ARM_COMPUTE_LIB_DIR "${OV_CPACK_LIBRARYDIR}") -endif() +list(APPEND INSTALL_PATH_VARS "OPENVINO_LIB_DIR") +# remove generator expression at the end, because searching in Release / Debug +# will be done by inside OpenVINOConfig.cmak / ACLConfig.cmake +string(REPLACE "$" "" OPENVINO_LIB_DIR "${OV_CPACK_LIBRARYDIR}") set(IE_INCLUDE_DIR "${OV_CPACK_INCLUDEDIR}/ie") set(IE_TBB_DIR "${IE_TBB_DIR_INSTALL}") diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index 29c298acb109fd..4c17e2e32373ec 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -117,7 +117,7 @@ function(ov_add_onednn) add_subdirectory(onednn EXCLUDE_FROM_ALL) # install static libraries - ov_install_static_lib(dnnl cpu) + ov_install_static_lib(dnnl ${OV_CPACK_COMP_CORE}) if(DNNL_USE_ACL AND NOT BUILD_SHARED_LIBS) # use ACLConfig.cmake in OpenVINOConfig.cmake in case of static build @@ -125,16 +125,16 @@ function(ov_add_onednn) # but for this we need to install library files install(FILES $ DESTINATION ${OV_CPACK_ARCHIVEDIR} - COMPONENT cpu) + COMPONENT ${OV_CPACK_COMP_CORE}) install(FILES "${intel_cpu_thirdparty_SOURCE_DIR}/ACLConfig.cmake" DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - COMPONENT core_dev) + COMPONENT ${OV_CPACK_COMP_CORE_DEV}) endif() endfunction() if(ENABLE_MLAS_FOR_CPU) add_subdirectory(mlas) - ov_install_static_lib(mlas cpu) + ov_install_static_lib(mlas ${OV_CPACK_COMP_CORE}) endif() ov_add_onednn() diff --git a/src/plugins/intel_gpu/src/graph/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/CMakeLists.txt index 3831742ace55f6..dd3ddb87d1016e 100644 --- a/src/plugins/intel_gpu/src/graph/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/graph/CMakeLists.txt @@ -58,7 +58,7 @@ elseif((NOT ANDROID) AND (UNIX)) target_link_libraries(${TARGET_NAME} PRIVATE pthread) endif() -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) if(ENABLE_SSE42) ie_sse42_optimization_flags(sse4_2_flags) diff --git a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt index 4e4aa260520a06..99ebf5331ab305 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt @@ -91,8 +91,16 @@ add_custom_command( TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/cache/cache.json ${TUNING_CACHE_PATH}/cache.json) +if(BUILD_SHARED_LIBS) + set(CACHE_JSON_INSTALL_DIR ${OV_CPACK_PLUGINSDIR}) + set(CACHE_JSON_COMPONENT gpu) +else() + set(CACHE_JSON_INSTALL_DIR ${OV_CPACK_ARCHIVEDIR}) + set(CACHE_JSON_COMPONENT ${OV_CPACK_COMP_CORE}) +endif() + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cache/cache.json - DESTINATION ${OV_CPACK_PLUGINSDIR} - COMPONENT gpu) + DESTINATION ${CACHE_JSON_INSTALL_DIR} + COMPONENT ${CACHE_JSON_COMPONENT}) -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt index 47c9139a4f9f8b..f1de561105c0ca 100644 --- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt @@ -64,4 +64,4 @@ elseif((NOT ANDROID) AND (UNIX)) target_link_libraries(${TARGET_NAME} PRIVATE pthread) endif() -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt index 1d71dc6e2a2a17..4fdbbc39f3d08f 100644 --- a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt @@ -9,11 +9,12 @@ if(ENABLE_ONEDNN_FOR_GPU) function(build_onednn_gpu) include(ExternalProject) - set(ONEDNN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_build/") - set(ONEDNN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_install/") + set(ONEDNN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_build") + set(ONEDNN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_install" CACHE PATH "Installation path for oneDNN GPU library") set(ONEDNN_PREFIX_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_root") set(ONEDNN_ENABLED_PRIMITIVES "CONCAT;CONVOLUTION;DECONVOLUTION;INNER_PRODUCT;MATMUL;REORDER;POOLING;REDUCTION") set(ONEDNN_ENABLED_ISA "XEHP;XEHPG;XEHPC") + set(DNNL_GPU_LIBRARY_NAME "openvino_onednn_gpu" CACHE STRING "Name of oneDNN library for Intel GPU Plugin") if(X86_64) set(ONEDNN_TARGET_ARCH "X64" CACHE STRING "" FORCE) @@ -79,6 +80,9 @@ if(ENABLE_ONEDNN_FOR_GPU) list(APPEND cmake_extra_args "-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIR}") endif() + set(onednn_gpu_lib "${CMAKE_STATIC_LIBRARY_PREFIX}${DNNL_GPU_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(ONEDNN_GPU_LIB_PATH ${ONEDNN_INSTALL_DIR}/lib/${onednn_gpu_lib} CACHE FILEPATH "Path to oneDNN GPU library") + ExternalProject_Add(onednn_gpu_build # Directory Options: PREFIX "${ONEDNN_PREFIX_DIR}" @@ -99,7 +103,7 @@ if(ENABLE_ONEDNN_FOR_GPU) "-DDNNL_TARGET_ARCH=${ONEDNN_TARGET_ARCH}" "-DDNNL_CPU_RUNTIME=NONE" "-DDNNL_GPU_RUNTIME=OCL" - "-DDNNL_LIBRARY_NAME=openvino_onednn_gpu" + "-DDNNL_LIBRARY_NAME=${DNNL_GPU_LIBRARY_NAME}" "-DCMAKE_INSTALL_PREFIX=${ONEDNN_INSTALL_DIR}" "-DDNNL_ENABLE_CONCURRENT_EXEC=ON" "-DDNNL_ENABLE_PRIMITIVE_CACHE=OFF" @@ -124,18 +128,29 @@ if(ENABLE_ONEDNN_FOR_GPU) # Thus we pass it via CMAKE_CACHE_ARGS "-DDNNL_ENABLE_PRIMITIVE:STRING=${ONEDNN_ENABLED_PRIMITIVES}" "-DDNNL_ENABLE_PRIMITIVE_GPU_ISA:STRING=${ONEDNN_ENABLED_ISA}" + # Build Step Options: + BUILD_BYPRODUCTS ${ONEDNN_GPU_LIB_PATH} # Target Options: EXCLUDE_FROM_ALL ON ) + add_library(onednn_gpu_tgt INTERFACE) set_target_properties(onednn_gpu_tgt PROPERTIES - INTERFACE_LINK_DIRECTORIES "${ONEDNN_INSTALL_DIR}/lib" - INTERFACE_LINK_LIBRARIES "openvino_onednn_gpu" - INTERFACE_INCLUDE_DIRECTORIES "${ONEDNN_INSTALL_DIR}/include" + INTERFACE_LINK_LIBRARIES $ + INTERFACE_INCLUDE_DIRECTORIES $ INTERFACE_COMPILE_DEFINITIONS ENABLE_ONEDNN_FOR_GPU ) add_dependencies(onednn_gpu_tgt onednn_gpu_build) - # TODO: install onednn_gpu in static builds + + if(NOT BUILD_SHARED_LIBS) + ov_install_static_lib(onednn_gpu_tgt ${OV_CPACK_COMP_CORE}) + + # we need to install library explicitly and set_target_properties in OpenVINOConfig.cmake for 'onednn_gpu_tgt' + # to point to installation location of this file + install(FILES "${ONEDNN_GPU_LIB_PATH}" + DESTINATION ${OV_CPACK_ARCHIVEDIR} + COMPONENT ${OV_CPACK_COMP_CORE}) + endif() endfunction() build_onednn_gpu() endif() diff --git a/src/plugins/template/backend/CMakeLists.txt b/src/plugins/template/backend/CMakeLists.txt index 7b945216c95898..74e10c01863dfe 100644 --- a/src/plugins/template/backend/CMakeLists.txt +++ b/src/plugins/template/backend/CMakeLists.txt @@ -51,4 +51,4 @@ openvino_developer_export_targets(COMPONENT core TARGETS interpreter_backend) # install -ov_install_static_lib(interpreter_backend template) +ov_install_static_lib(interpreter_backend ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/template/src/CMakeLists.txt b/src/plugins/template/src/CMakeLists.txt index 2409bb10e0c152..f382f90d11b450 100644 --- a/src/plugins/template/src/CMakeLists.txt +++ b/src/plugins/template/src/CMakeLists.txt @@ -28,7 +28,7 @@ target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${TEMPLATE_PLUGIN_SOURCE_DIR}/include") -# link common Inference Engine libraries +# link common OpenVINO Runtime libraries target_link_libraries(${TARGET_NAME} PRIVATE openvino::interpreter_backend openvino::reference) @@ -42,4 +42,4 @@ endif() # [cmake:plugin] install(TARGETS ${TARGET_NAME} - LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) + LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) diff --git a/thirdparty/ocl/CMakeLists.txt b/thirdparty/ocl/CMakeLists.txt index f31519467f3f64..0ebe3fd6d1df39 100644 --- a/thirdparty/ocl/CMakeLists.txt +++ b/thirdparty/ocl/CMakeLists.txt @@ -58,4 +58,4 @@ set(opencl_root_hints "${OpenCL_INCLUDE_DIR}" PARENT_SCOPE) # installation -ov_install_static_lib(OpenCL gpu) +ov_install_static_lib(OpenCL ${OV_CPACK_COMP_CORE})