diff --git a/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake b/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake index 1dbe8952925..3996f373156 100644 --- a/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake +++ b/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake @@ -192,14 +192,6 @@ ov_set_if_not_defined(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER include(packaging/packaging) if(APPLE) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) - - if(DEFINED OV_CPACK_LIBRARYDIR) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OV_CPACK_LIBRARYDIR}") - else() - message(FATAL_ERROR "Internal error: OV_CPACK_LIBRARYDIR is not defined, while it's required to initialize RPATH") - endif() - # WA for Xcode generator + object libraries issue: # https://gitlab.kitware.com/cmake/cmake/issues/20260 # http://cmake.3232098.n2.nabble.com/XCODE-DEPEND-HELPER-make-Deletes-Targets-Before-and-While-They-re-Built-td7598277.html diff --git a/cmake/developer_package/packaging/archive.cmake b/cmake/developer_package/packaging/archive.cmake index a3cc7db0967..5f259a78d72 100644 --- a/cmake/developer_package/packaging/archive.cmake +++ b/cmake/developer_package/packaging/archive.cmake @@ -4,6 +4,15 @@ include(GNUInstallDirs) +if(APPLE) + # on macOS versions with SIP enabled, we need to use @rpath + # because DYLD_LIBRARY_PATH is ignored + set(CMAKE_SKIP_INSTALL_RPATH OFF) +else() + # we don't need RPATHs, because setupvars.sh is used + set(CMAKE_SKIP_INSTALL_RPATH ON) +endif() + # # ov_archive_cpack_set_dirs() # diff --git a/cmake/developer_package/packaging/common-libraries.cmake b/cmake/developer_package/packaging/common-libraries.cmake index fea1bac83dc..4fbce5b4a58 100644 --- a/cmake/developer_package/packaging/common-libraries.cmake +++ b/cmake/developer_package/packaging/common-libraries.cmake @@ -4,6 +4,14 @@ include(GNUInstallDirs) +if(CPACK_GENERATOR STREQUAL "BREW") + # brew relies on RPATHs + # set(CMAKE_SKIP_INSTALL_RPATH OFF) +else() + # we don't need RPATHs, because libraries are searched by standard paths + set(CMAKE_SKIP_INSTALL_RPATH ON) +endif() + # # ov_common_libraries_cpack_set_dirs() # @@ -107,8 +115,3 @@ macro(ov_define_component_include_rules) endmacro() ov_define_component_include_rules() - -if(CPACK_GENERATOR STREQUAL "BREW") - # brew relies on RPATH - set(CMAKE_SKIP_INSTALL_RPATH OFF) -endif() diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake index 2b6a5447323..505565f55da 100644 --- a/cmake/developer_package/packaging/packaging.cmake +++ b/cmake/developer_package/packaging/packaging.cmake @@ -4,9 +4,6 @@ include(CPackComponent) -# we don't need RPATHs, because setupvars.sh is used -set(CMAKE_SKIP_INSTALL_RPATH ON) - # # ov_install_static_lib( ) # @@ -31,6 +28,29 @@ macro(ov_install_static_lib target comp) endif() endmacro() +# +# ov_set_apple_rpath( ...) +# +# Sets LC_RPATH properties for macOS MACH-O binaries to ensure that libraries can find their dependencies +# when macOS system integrity protection (SIP) is enabled (DYLD_LIBRARY_PATH is ignored in this case). +# Note, that this is important when binaries are dynamically loaded at runtime (e.g. via Python). +# +function(ov_set_apple_rpath TARGET_NAME lib_install_path) + if(APPLE AND CPACK_GENERATOR MATCHES "^(7Z|TBZ2|TGZ|TXZ|TZ|TZST|ZIP)$") + unset(rpath_list) + foreach(dependency_install_path IN LISTS ARGN) + file(RELATIVE_PATH dependency_rpath "/${lib_install_path}" "/${dependency_install_path}") + set(dependency_rpath "@loader_path/${dependency_rpath}") + list(APPEND rpath_list "${dependency_rpath}") + endforeach() + + set_target_properties(${TARGET_NAME} PROPERTIES + MACOSX_RPATH ON + INSTALL_RPATH "${rpath_list}" + INSTALL_NAME_DIR "@rpath") + endif() +endfunction() + # # ov_get_pyversion() # diff --git a/cmake/developer_package/version.cmake b/cmake/developer_package/version.cmake index f1e12c6531b..0353e3a52a8 100644 --- a/cmake/developer_package/version.cmake +++ b/cmake/developer_package/version.cmake @@ -220,7 +220,7 @@ macro (ov_add_version_defines FILE TARGET) $ $) set_target_properties(${TARGET}_version - PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE + PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE $) target_sources(${TARGET} PRIVATE $) diff --git a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in index c4a9c49a481..e197597487b 100644 --- a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in +++ b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in @@ -17,7 +17,7 @@ set_and_check(OpenVINO_MAIN_SOURCE_DIR "@OpenVINO_SOURCE_DIR@") # NPU set(ov_options "@OV_OPTIONS@") list(APPEND ov_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_LINKER_LAUNCHER CMAKE_C_LINKER_LAUNCHER - CMAKE_SKIP_RPATH CMAKE_INSTALL_PREFIX CPACK_GENERATOR) + CMAKE_INSTALL_PREFIX CPACK_GENERATOR) if(APPLE) list(APPEND ov_options CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET) diff --git a/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in b/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in index 04cf8a219ae..f78e31ce635 100644 --- a/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in +++ b/cmake/templates/OpenVINODeveloperPackageConfig.cmake.in @@ -13,7 +13,7 @@ set_and_check(OpenVINO_SOURCE_DIR "@OpenVINO_SOURCE_DIR@") set(ov_options "@OV_OPTIONS@") list(APPEND ov_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_LINKER_LAUNCHER CMAKE_C_LINKER_LAUNCHER - CMAKE_SKIP_RPATH CMAKE_INSTALL_PREFIX CPACK_GENERATOR) + CMAKE_INSTALL_PREFIX CPACK_GENERATOR) if(APPLE) list(APPEND ov_options CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET) @@ -42,6 +42,9 @@ foreach(option IN LISTS ov_options) endforeach() message(" ") +# Restore TBB installation directory (requires for proper LC_RPATH on macOS with SIP) +load_cache("${cache_path}" READ_WITH_PREFIX "" TBB_INSTALL_DIR) + # activate generation of plugins.xml set(ENABLE_PLUGINS_XML ON) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 87bf32eb317..5051bc74292 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -223,7 +223,9 @@ macro(ov_add_sample) endif() set_target_properties(${SAMPLE_NAME} PROPERTIES FOLDER ${folder_name} - COMPILE_PDB_NAME ${SAMPLE_NAME}) + COMPILE_PDB_NAME ${SAMPLE_NAME} + # to ensure out of box LC_RPATH on macOS with SIP + INSTALL_RPATH_USE_LINK_PATH ON) if(SAMPLE_INCLUDE_DIRECTORIES) target_include_directories(${SAMPLE_NAME} PRIVATE ${SAMPLE_INCLUDE_DIRECTORIES}) diff --git a/src/bindings/c/src/CMakeLists.txt b/src/bindings/c/src/CMakeLists.txt index e491424cb27..8f5eaeac581 100644 --- a/src/bindings/c/src/CMakeLists.txt +++ b/src/bindings/c/src/CMakeLists.txt @@ -32,6 +32,10 @@ set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_REL ov_add_vs_version_file(NAME ${TARGET_NAME} FILEDESCRIPTION "OpenVINO C API Core Runtime library") +ov_set_apple_rpath(${TARGET_NAME} + # openvino_c installed in the same directory as openvino + ${OV_CPACK_RUNTIMEDIR} ${OV_CPACK_RUNTIMEDIR}) + # export set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME runtime::c) diff --git a/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt b/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt index 92cd19c7c8f..be45fe1281b 100644 --- a/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt @@ -84,6 +84,10 @@ add_custom_command(TARGET ${TARGET_NAME} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/__init__.py ) +foreach(target IN LISTS INSTALLED_TARGETS) + ov_set_apple_rpath(${target} ${OV_CPACK_PYTHONDIR}/openvino/inference_engine ${OV_CPACK_RUNTIMEDIR}) +endforeach() + # install install(TARGETS ${INSTALLED_TARGETS} diff --git a/src/bindings/python/src/compatibility/pyngraph/CMakeLists.txt b/src/bindings/python/src/compatibility/pyngraph/CMakeLists.txt index 998c950ff4c..ba20fd76055 100644 --- a/src/bindings/python/src/compatibility/pyngraph/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/pyngraph/CMakeLists.txt @@ -68,6 +68,8 @@ if(OpenVINO_SOURCE_DIR) ) endif() +ov_set_apple_rpath(_${PROJECT_NAME} ${OV_CPACK_PYTHONDIR} ${OV_CPACK_RUNTIMEDIR}) + # Install if(OpenVINO_SOURCE_DIR OR OpenVINODeveloperPackage_FOUND) diff --git a/src/bindings/python/src/pyopenvino/CMakeLists.txt b/src/bindings/python/src/pyopenvino/CMakeLists.txt index 5d5aeeb4002..99ae9983ee8 100644 --- a/src/bindings/python/src/pyopenvino/CMakeLists.txt +++ b/src/bindings/python/src/pyopenvino/CMakeLists.txt @@ -72,7 +72,7 @@ endif() target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..") target_link_libraries(${PROJECT_NAME} PRIVATE - openvino::runtime::dev openvino::runtime ${OFFLINE_TRANSFORMATIONS_LIB}) + openvino::core::dev openvino::runtime ${OFFLINE_TRANSFORMATIONS_LIB}) set_target_properties(${PROJECT_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO} OUTPUT_NAME "_pyopenvino") @@ -124,6 +124,13 @@ if(OpenVINO_SOURCE_DIR OR OpenVINODeveloperPackage_FOUND) COMPONENT ${OV_CPACK_COMP_PYTHON_OPENVINO}_${pyversion} ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL}) + ov_set_apple_rpath(${PROJECT_NAME} ${OV_CPACK_PYTHONDIR}/openvino + # path to OpenVINO C++ libraries + ${OV_CPACK_RUNTIMEDIR} + # pyopenvino also depends on TBB because of: + # pyopenvino => openvino::offline_transformations => TBB optimized openvino::reference + ${TBB_LIB_INSTALL_DIR}) + ov_cpack_add_component(${OV_CPACK_COMP_OPENVINO_REQ_FILES} HIDDEN) install(FILES ${OpenVINOPython_SOURCE_DIR}/requirements.txt diff --git a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp index 91da7a810e4..188cbe263ed 100644 --- a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp +++ b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp @@ -3,7 +3,6 @@ #include "pyopenvino/core/async_infer_queue.hpp" -#include #include #include diff --git a/src/bindings/python/src/pyopenvino/core/common.hpp b/src/bindings/python/src/pyopenvino/core/common.hpp index 0430470310a..187f0d87ce5 100644 --- a/src/bindings/python/src/pyopenvino/core/common.hpp +++ b/src/bindings/python/src/pyopenvino/core/common.hpp @@ -9,13 +9,12 @@ #include #include -#include -#include #include #include #include #include "Python.h" +#include "openvino/core/type/element_type.hpp" #include "openvino/runtime/compiled_model.hpp" #include "openvino/runtime/infer_request.hpp" #include "openvino/runtime/tensor.hpp" diff --git a/src/bindings/python/src/pyopenvino/core/core.cpp b/src/bindings/python/src/pyopenvino/core/core.cpp index db04ee5bb76..734d8ea1ef9 100644 --- a/src/bindings/python/src/pyopenvino/core/core.cpp +++ b/src/bindings/python/src/pyopenvino/core/core.cpp @@ -4,7 +4,6 @@ #include "pyopenvino/core/core.hpp" -#include #include #include diff --git a/src/bindings/python/src/pyopenvino/core/infer_request.cpp b/src/bindings/python/src/pyopenvino/core/infer_request.cpp index 6b087ecaa20..71e73e4dff3 100644 --- a/src/bindings/python/src/pyopenvino/core/infer_request.cpp +++ b/src/bindings/python/src/pyopenvino/core/infer_request.cpp @@ -3,7 +3,6 @@ #include "pyopenvino/core/infer_request.hpp" -#include #include #include #include diff --git a/src/bindings/python/src/pyopenvino/frontend/frontend_module.cmake b/src/bindings/python/src/pyopenvino/frontend/frontend_module.cmake index f4220bde3aa..5e7a1f2d426 100644 --- a/src/bindings/python/src/pyopenvino/frontend/frontend_module.cmake +++ b/src/bindings/python/src/pyopenvino/frontend/frontend_module.cmake @@ -25,7 +25,7 @@ function(frontend_module TARGET FRAMEWORK INSTALL_COMPONENT) target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenVINOPython_SOURCE_DIR}/src/pyopenvino/utils/") - target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::runtime::dev openvino::frontend::${FRAMEWORK}) + target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::core::dev openvino::frontend::${FRAMEWORK}) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) @@ -39,8 +39,11 @@ function(frontend_module TARGET FRAMEWORK INSTALL_COMPONENT) COMMAND ${CMAKE_COMMAND} -E copy ${OpenVINOPython_SOURCE_DIR}/src/openvino/frontend/${FRAMEWORK}/__init__.py ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/__init__.py) + set(frontend_install_path ${OV_CPACK_PYTHONDIR}/openvino/frontend/${FRAMEWORK}) install(TARGETS ${TARGET_NAME} - DESTINATION ${OV_CPACK_PYTHONDIR}/openvino/frontend/${FRAMEWORK} + DESTINATION ${frontend_install_path} COMPONENT ${INSTALL_COMPONENT} ${OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL}) + + ov_set_apple_rpath(${TARGET_NAME} ${frontend_install_path} ${OV_CPACK_RUNTIMEDIR}) endfunction() diff --git a/src/bindings/python/src/pyopenvino/graph/node_factory.cpp b/src/bindings/python/src/pyopenvino/graph/node_factory.cpp index 5c274d1bf3f..7dde2d53b7b 100644 --- a/src/bindings/python/src/pyopenvino/graph/node_factory.cpp +++ b/src/bindings/python/src/pyopenvino/graph/node_factory.cpp @@ -17,7 +17,6 @@ #include #include "dict_attribute_visitor.hpp" -#include "ngraph/check.hpp" #include "openvino/core/except.hpp" #include "openvino/core/node.hpp" #include "openvino/core/op_extension.hpp" diff --git a/src/cmake/install_tbb.cmake b/src/cmake/install_tbb.cmake index 19a30ee624c..a5f7bd19c58 100644 --- a/src/cmake/install_tbb.cmake +++ b/src/cmake/install_tbb.cmake @@ -128,7 +128,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND endforeach() endforeach() - set(pkg_config_tbb_lib_dir "runtime/3rdparty/tbb/lib") + set(TBB_LIB_INSTALL_DIR "runtime/3rdparty/tbb/lib" CACHE PATH "TBB library install directory" FORCE) elseif(tbb_custom) # for custom TBB we need to install it to our package # to simplify life for our customers @@ -183,7 +183,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND endif() endforeach() - set(pkg_config_tbb_lib_dir "${IE_TBBROOT_INSTALL}/${tbb_libs_dir}") + set(TBB_LIB_INSTALL_DIR "${IE_TBBROOT_INSTALL}/${tbb_libs_dir}" CACHE PATH "TBB library install directory" FORCE) elseif(tbb_downloaded) set(OV_TBB_DIR_INSTALL "runtime/3rdparty/tbb") @@ -234,13 +234,16 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND PATTERN "cmake" EXCLUDE) endif() - set(pkg_config_tbb_lib_dir "${OV_TBB_DIR_INSTALL}/lib") + set(TBB_LIB_INSTALL_DIR "${OV_TBB_DIR_INSTALL}/lib" CACHE PATH "TBB library install directory" FORCE) else() + unset(TBB_LIB_INSTALL_DIR CACHE) message(WARNING "TBB of unknown origin. TBB files are not installed") endif() unset(tbb_downloaded) unset(tbb_custom) +else() + unset(TBB_LIB_INSTALL_DIR CACHE) endif() # install tbbbind for static OpenVINO case diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 068ae2b0cd9..ba3786cd697 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -72,6 +72,14 @@ endif() ov_set_threading_interface_for(${TARGET_NAME}) ov_mark_target_as_cc(${TARGET_NAME}) +if(TBB_FOUND) + if(NOT TBB_LIB_INSTALL_DIR) + message(FATAL_ERROR "Internal error: variable 'TBB_LIB_INSTALL_DIR' is not defined") + endif() + # set LC_RPATH to TBB library directory + ov_set_apple_rpath(${TARGET_NAME} ${OV_CPACK_RUNTIMEDIR} ${TBB_LIB_INSTALL_DIR}) +endif() + # must be called after all target_link_libraries ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME} EXTRA ${TBB_IMPORTED_TARGETS}) @@ -96,7 +104,7 @@ install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets # OpenVINO runtime library dev # -# Add openvin::dev target +# Add openvino::runtine::dev target # add_library(${TARGET_NAME}_dev INTERFACE) @@ -112,6 +120,7 @@ target_compile_definitions(${TARGET_NAME}_dev INTERFACE target_link_libraries(${TARGET_NAME}_dev INTERFACE ${TARGET_NAME} openvino::core::dev) +# TODO: remove once NPU will use explicltly `ov_set_threading_interface_for` ov_set_threading_interface_for(${TARGET_NAME}_dev) set_target_properties(${TARGET_NAME}_dev PROPERTIES EXPORT_NAME runtime::dev) @@ -253,11 +262,11 @@ if(ENABLE_PKGCONFIG_GEN) if(ENABLE_SYSTEM_TBB) set(PKGCONFIG_OpenVINO_PRIVATE_DEPS "-ltbb") elseif(TBB_FOUND) - if(NOT pkg_config_tbb_lib_dir) - message(FATAL_ERROR "Internal error: variable 'pkg_config_tbb_lib_dir' is not defined") + if(NOT TBB_LIB_INSTALL_DIR) + message(FATAL_ERROR "Internal error: variable 'TBB_LIB_INSTALL_DIR' is not defined") endif() - set(PKGCONFIG_OpenVINO_PRIVATE_DEPS "-L\${prefix}/${pkg_config_tbb_lib_dir} -ltbb") + set(PKGCONFIG_OpenVINO_PRIVATE_DEPS "-L\${prefix}/${TBB_LIB_INSTALL_DIR} -ltbb") endif() if(ENABLE_SYSTEM_PUGIXML) diff --git a/src/cmake/ov_parallel.cmake b/src/cmake/ov_parallel.cmake index a9d4d391e45..510b207689a 100644 --- a/src/cmake/ov_parallel.cmake +++ b/src/cmake/ov_parallel.cmake @@ -261,18 +261,16 @@ function(ov_set_threading_interface_for TARGET_NAME) if(target_type STREQUAL "INTERFACE_LIBRARY") set(LINK_TYPE "INTERFACE") set(COMPILE_DEF_TYPE "INTERFACE") - elseif(target_type STREQUAL "EXECUTABLE" OR target_type STREQUAL "OBJECT_LIBRARY" OR - target_type STREQUAL "MODULE_LIBRARY") + elseif(target_type MATCHES "^(EXECUTABLE|OBJECT_LIBRARY|MODULE_LIBRARY)$") set(LINK_TYPE "PRIVATE") - set(COMPILE_DEF_TYPE "PUBLIC") + set(COMPILE_DEF_TYPE "PRIVATE") elseif(target_type STREQUAL "STATIC_LIBRARY") # Affected libraries: inference_engine_s, openvino_gapi_preproc_s # they don't have TBB in public headers => PRIVATE set(LINK_TYPE "PRIVATE") set(COMPILE_DEF_TYPE "PUBLIC") elseif(target_type STREQUAL "SHARED_LIBRARY") - # Affected libraries: inference_engine only - # TODO: why TBB propogates its headers to inference_engine? + # Affected libraries: 'openvino' only set(LINK_TYPE "PRIVATE") set(COMPILE_DEF_TYPE "PUBLIC") else() diff --git a/src/common/offline_transformations/CMakeLists.txt b/src/common/offline_transformations/CMakeLists.txt index ccd11c7eb3b..6712f2f2858 100644 --- a/src/common/offline_transformations/CMakeLists.txt +++ b/src/common/offline_transformations/CMakeLists.txt @@ -19,11 +19,7 @@ source_group("include" FILES ${PUBLIC_HEADERS}) add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime::dev openvino::itt openvino::pugixml openvino::reference - openvino::runtime) - -set_source_files_properties(INCLUDE_DIRECTORIES - $) +target_link_libraries(${TARGET_NAME} PRIVATE openvino::core::dev openvino::reference openvino::runtime) target_include_directories(${TARGET_NAME} PUBLIC ${PUBLIC_HEADERS_DIR} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") diff --git a/src/inference/tests/functional/CMakeLists.txt b/src/inference/tests/functional/CMakeLists.txt index 16bcc08d4b9..4a42e9eb5bd 100644 --- a/src/inference/tests/functional/CMakeLists.txt +++ b/src/inference/tests/functional/CMakeLists.txt @@ -44,6 +44,8 @@ ov_add_test_target( LINK_LIBRARIES gmock func_test_utils + DEFINES + ${COMPILE_DEFINITIONS} INCLUDES $/src ${CMAKE_CURRENT_SOURCE_DIR} @@ -52,4 +54,4 @@ ov_add_test_target( OV UNIT RUNTIME ) -add_compile_definitions(${TARGET_NAME} ${COMPILE_DEFINITIONS}) +ov_set_threading_interface_for(${TARGET_NAME}) diff --git a/src/inference/tests/unit/CMakeLists.txt b/src/inference/tests/unit/CMakeLists.txt index ef8e346aaf4..8030fe0ddb7 100644 --- a/src/inference/tests/unit/CMakeLists.txt +++ b/src/inference/tests/unit/CMakeLists.txt @@ -19,3 +19,5 @@ ov_add_test_target( LABELS OV UNIT RUNTIME ) + +ov_set_threading_interface_for(${TARGET_NAME}) diff --git a/src/plugins/auto/tests/CMakeLists.txt b/src/plugins/auto/tests/CMakeLists.txt index bce0f68667c..59ce3e84bc8 100644 --- a/src/plugins/auto/tests/CMakeLists.txt +++ b/src/plugins/auto/tests/CMakeLists.txt @@ -1,8 +1,7 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # -# RPATH is always enabled for unit tests -set(CMAKE_SKIP_RPATH OFF) + # because unit tests use plugins object files compiled with LTO if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/src/plugins/auto_batch/CMakeLists.txt b/src/plugins/auto_batch/CMakeLists.txt index ffc873e5c6c..9ff585740ab 100644 --- a/src/plugins/auto_batch/CMakeLists.txt +++ b/src/plugins/auto_batch/CMakeLists.txt @@ -18,17 +18,13 @@ ov_add_plugin(NAME ${TARGET_NAME} SOURCES ${SOURCES} ${HEADERS} VERSION_DEFINES_FOR src/plugin.cpp ADD_CLANG_FORMAT) -target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads) +ov_set_threading_interface_for(${TARGET_NAME}) # must be called after all target_link_libraries ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) -if(ENABLE_FUNCTIONAL_TESTS) - add_subdirectory(tests/functional) -endif() - if(ENABLE_TESTS) - add_subdirectory(tests/unit) + add_subdirectory(tests) endif() diff --git a/src/plugins/auto_batch/tests/CMakeLists.txt b/src/plugins/auto_batch/tests/CMakeLists.txt new file mode 100644 index 00000000000..9d4bb95917d --- /dev/null +++ b/src/plugins/auto_batch/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +add_subdirectory(unit) +add_subdirectory(functional) diff --git a/src/plugins/hetero/CMakeLists.txt b/src/plugins/hetero/CMakeLists.txt index fdb972a7b42..8d20a7d6c5b 100644 --- a/src/plugins/hetero/CMakeLists.txt +++ b/src/plugins/hetero/CMakeLists.txt @@ -29,38 +29,31 @@ ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) -if(BUILD_SHARED_LIBS) - set(OBJ_NAME ${TARGET_NAME}_obj) - - add_library(${OBJ_NAME} OBJECT ${SOURCES} ${HEADERS}) - ov_link_system_libraries(${OBJ_NAME} PUBLIC openvino::pugixml) - - ov_add_version_defines(src/version.cpp ${OBJ_NAME}) - - target_include_directories(${OBJ_NAME} - PRIVATE - $ - $ - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - $) - - ov_set_threading_interface_for(${OBJ_NAME}) - - target_compile_definitions(${OBJ_NAME} - PRIVATE - USE_STATIC_IE IMPLEMENT_INFERENCE_ENGINE_PLUGIN IMPLEMENT_INFERENCE_EXTENSION_API - $ - $) - - set_target_properties(${TARGET_NAME}_obj PROPERTIES EXCLUDE_FROM_ALL ON) - set_target_properties(${TARGET_NAME}_obj PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) -endif() - if(ENABLE_TESTS) - add_subdirectory(tests/unit) -endif() + if(BUILD_SHARED_LIBS) + set(OBJ_NAME ${TARGET_NAME}_obj) -if(ENABLE_FUNCTIONAL_TESTS) - add_subdirectory(tests/functional) + add_library(${OBJ_NAME} OBJECT ${SOURCES} ${HEADERS}) + ov_link_system_libraries(${OBJ_NAME} PUBLIC openvino::pugixml) + + ov_add_version_defines(src/version.cpp ${OBJ_NAME}) + + target_include_directories(${OBJ_NAME} + PRIVATE + $ + $ + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + $) + + ov_set_threading_interface_for(${OBJ_NAME}) + + target_compile_definitions(${OBJ_NAME} + PRIVATE + USE_STATIC_IE IMPLEMENT_INFERENCE_ENGINE_PLUGIN IMPLEMENT_INFERENCE_EXTENSION_API + $ + $) + endif() + + add_subdirectory(tests) endif() diff --git a/src/plugins/hetero/tests/CMakeLists.txt b/src/plugins/hetero/tests/CMakeLists.txt new file mode 100644 index 00000000000..9d4bb95917d --- /dev/null +++ b/src/plugins/hetero/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +add_subdirectory(unit) +add_subdirectory(functional) diff --git a/src/plugins/hetero/tests/functional/CMakeLists.txt b/src/plugins/hetero/tests/functional/CMakeLists.txt index a1726e31c5a..550bfa0f075 100644 --- a/src/plugins/hetero/tests/functional/CMakeLists.txt +++ b/src/plugins/hetero/tests/functional/CMakeLists.txt @@ -8,7 +8,6 @@ ov_add_test_target( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} DEPENDENCIES - openvino::runtime mock_engine openvino_hetero_plugin LINK_LIBRARIES diff --git a/src/plugins/hetero/tests/unit/CMakeLists.txt b/src/plugins/hetero/tests/unit/CMakeLists.txt index 939229e4ee9..ad2d38e156b 100644 --- a/src/plugins/hetero/tests/unit/CMakeLists.txt +++ b/src/plugins/hetero/tests/unit/CMakeLists.txt @@ -24,7 +24,6 @@ ov_add_test_target( ov_models DEPENDENCIES mock_engine - ov_models ADD_CLANG_FORMAT LABELS OV UNIT HETERO diff --git a/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt b/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt index fd85b52a313..035e05de645 100644 --- a/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt +++ b/src/plugins/intel_gna/tests/deprecated/unit/CMakeLists.txt @@ -8,9 +8,6 @@ set(TARGET_NAME InferenceEngineUnitTests) ov_disable_deprecated_warnings() -# rpath enabled for unit tests only -SET (CMAKE_SKIP_RPATH OFF) - # collect sources file(GLOB diff --git a/src/plugins/intel_gna/tests/unit/CMakeLists.txt b/src/plugins/intel_gna/tests/unit/CMakeLists.txt index 87f4223a643..cb77a5e190c 100644 --- a/src/plugins/intel_gna/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_gna/tests/unit/CMakeLists.txt @@ -4,9 +4,6 @@ set(TARGET_NAME ov_gna_unit_tests) -# RPATH is always enabled for unit tests -set(CMAKE_SKIP_RPATH OFF) - # because unit tests use plugins object files compiled with LTO if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/src/plugins/intel_gpu/CMakeLists.txt b/src/plugins/intel_gpu/CMakeLists.txt index 2561407b6fa..b0c66a435d6 100644 --- a/src/plugins/intel_gpu/CMakeLists.txt +++ b/src/plugins/intel_gpu/CMakeLists.txt @@ -65,6 +65,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph openvino:: target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/) +ov_set_threading_interface_for(${TARGET_NAME}) + set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) # Workaround to avoid warnings during LTO build