From 0f647e6b75a87e334f44e0451f0f7ef9c66141c3 Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Wed, 16 Nov 2022 11:13:37 +0100 Subject: [PATCH] Fix finding onetbb lib on windows (#14018) --- cmake/dependencies.cmake | 12 ++++++++++++ scripts/setupvars/setupvars.bat | 9 ++++++++- src/cmake/install_tbb.cmake | 19 +++++++++---------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index c7342b67c11..c39a12cb02c 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -86,6 +86,18 @@ function(ov_download_tbb) set(IE_PATH_TO_DEPS "${THIRDPARTY_SERVER_PATH}") endif() + if (NOT DEFINED ENV{TBBROOT} AND (DEFINED ENV{TBB_DIR} OR DEFINED TBB_DIR)) + if (DEFINED ENV{TBB_DIR}) + set(TEMP_ROOT $ENV{TBB_DIR}) + elseif (DEFINED TBB_DIR) + set(TEMP_ROOT ${TBB_DIR}) + endif() + while(NOT EXISTS "${TEMP_ROOT}/include") + get_filename_component(TEMP_ROOT ${TEMP_ROOT} PATH) + endwhile() + set(TBBROOT ${TEMP_ROOT}) + endif() + if(WIN32 AND X86_64) # TODO: add target_path to be platform specific as well, to avoid following if RESOLVE_DEPENDENCY(TBB diff --git a/scripts/setupvars/setupvars.bat b/scripts/setupvars/setupvars.bat index 77de7ae809d..08dd7b3dffa 100644 --- a/scripts/setupvars/setupvars.bat +++ b/scripts/setupvars/setupvars.bat @@ -41,7 +41,12 @@ set "OPENVINO_LIB_PATHS=%INTEL_OPENVINO_DIR%\runtime\bin\intel64\Release;%INTEL_ :: TBB if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb ( - set "OPENVINO_LIB_PATHS=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\bin;%OPENVINO_LIB_PATHS%" + + if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\redist ( + set "OPENVINO_LIB_PATHS=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\redist\intel64\vc14;%OPENVINO_LIB_PATHS%" + ) else if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\bin ( + set "OPENVINO_LIB_PATHS=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\bin;%OPENVINO_LIB_PATHS%" + ) if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\cmake ( set "TBB_DIR=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\cmake" @@ -49,6 +54,8 @@ if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb ( set "TBB_DIR=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\lib\cmake\TBB" ) else if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\lib64\cmake\TBB ( set "TBB_DIR=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\lib64\cmake\TBB" + ) else if exist %INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\lib\cmake\tbb ( + set "TBB_DIR=%INTEL_OPENVINO_DIR%\runtime\3rdparty\tbb\lib\cmake\tbb" ) ) diff --git a/src/cmake/install_tbb.cmake b/src/cmake/install_tbb.cmake index dd7feb11a2b..d34add87d88 100644 --- a/src/cmake/install_tbb.cmake +++ b/src/cmake/install_tbb.cmake @@ -17,16 +17,15 @@ function(_ov_detect_dynamic_tbbbind_2_5 var) # try to select proper library directory _ov_get_tbb_location(TBB::tbb _tbb_lib_location) get_filename_component(_tbb_libs_dir "${_tbb_lib_location}" DIRECTORY) - # unset for cases if user specified different TBB_DIR / TBBROOT unset(_ov_tbbbind_2_5 CACHE) - find_library(_ov_tbbbind_2_5 - NAMES tbbbind_2_5 - HINTS "${_tbb_libs_dir}" - "Path to TBBBind 2.5+ library" - NO_DEFAULT_PATH - NO_CMAKE_FIND_ROOT_PATH) + find_file(_ov_tbbbind_2_5 + NAMES "${CMAKE_SHARED_LIBRARY_PREFIX}tbbbind_2_5${CMAKE_SHARED_LIBRARY_SUFFIX}" + HINTS "${_tbb_libs_dir}" + "Path to TBBBind 2.5+ library" + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH) if(_ov_tbbbind_2_5) set(${var} ON PARENT_SCOPE) @@ -131,7 +130,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND set(IE_TBBROOT_INSTALL "runtime/3rdparty/tbb") # TBBROOT is not defined if ENV{TBBROOT} is not found - # so, we have to deduce this value outselves + # so, we have to deduce this value ourselves if(NOT DEFINED TBBROOT AND DEFINED ENV{TBBROOT}) file(TO_CMAKE_PATH $ENV{TBBROOT} TBBROOT) endif() @@ -162,9 +161,9 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND file(RELATIVE_PATH tbb_libs_dir "${TBBROOT}" "${_tbb_libs_dir}") # install only meaningful directories - foreach(dir include ${tbb_libs_dir} cmake lib/cmake lib/pkgconfig) + foreach(dir include ${tbb_libs_dir} cmake lib/cmake lib/pkgconfig lib/intel64/vc14) if(EXISTS "${TBBROOT}/${dir}") - if(dir STREQUAL "include" OR dir MATCHES ".*(cmake|pkgconfig)$") + if(dir STREQUAL "include" OR dir MATCHES ".*(cmake|pkgconfig)$" OR dir STREQUAL "lib/intel64/vc14") set(tbb_component tbb_dev) set(core_dev_components tbb_dev) unset(exclude_pattern)