Tuned TBB cmake finding (#12852)

* Tuned TBB cmake finding

* Fixed for cmake less 3.24

* Fixes for Android ARM

* Fixed Android build
This commit is contained in:
Ilya Lavrenov 2022-09-02 10:25:23 +04:00 committed by GitHub
parent 230ae977dc
commit 1d3e63c40e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 12 deletions

View File

@ -123,7 +123,7 @@ function(ov_download_tbb)
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "f1c9b9e2861efdaa01552bd25312ccbc5feeb45551e5f91ae61e29221c5c1479")
elseif(ANDROID) # Should be before LINUX due LINUX is detected as well
elseif(ANDROID AND X86_64) # Should be before LINUX due LINUX is detected as well
RESOLVE_DEPENDENCY(TBB
ARCHIVE_ANDROID "tbb2020_20200404_android.tgz"
TARGET_PATH "${TEMP}/tbb"

View File

@ -30,6 +30,7 @@ find_package(TBB
CONFIG
PATHS ${TBBROOT}/cmake
${IEDevScripts_DIR}/${IE_OWN_TBB_CONFIG}
NO_DEFAULT_PATH)
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
find_package_handle_standard_args(TBB CONFIG_MODE)

View File

@ -187,8 +187,8 @@ if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND
if(DEFINED ENV{TBBROOT})
file(TO_CMAKE_PATH $ENV{TBBROOT} ENV_TBBROOT)
endif()
if(DEFINED ENV{TBB_DIR})
file(TO_CMAKE_PATH $ENV{TBB_DIR} ENV_TBB_DIR)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
set(_no_cmake_install_prefix NO_CMAKE_INSTALL_PREFIX)
endif()
set(find_package_tbb_extra_args
@ -198,14 +198,19 @@ if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND
"${ENV_TBBROOT}/lib64/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/TBB"
"${ENV_TBBROOT}/lib/cmake/tbb"
"${ENV_TBB_DIR}"
# for custom TBB exposed via cmake -DTBBROOT=<custom TBB root>
"${TBBROOT}/cmake"
# _tbb_dir points to TBB_DIR (custom | temp | system) used to build OpenVINO
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
CMAKE_FIND_ROOT_PATH_BOTH
NO_PACKAGE_ROOT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_SYSTEM_PATH
${_no_cmake_install_prefix}
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
unset(_tbb_dir)
unset(_no_cmake_install_prefix)
endif()
unset(enable_system_tbb)

View File

@ -6,8 +6,22 @@ macro(ov_find_package_tbb)
if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
if(NOT ENABLE_SYSTEM_TBB)
set(_find_package_no_args NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
set(_no_cmake_install_prefix NO_CMAKE_INSTALL_PREFIX)
endif()
# Note, we explicitly:
# don't set NO_CMAKE_PATH to allow -DTBB_DIR=XXX
# don't set NO_CMAKE_ENVIRONMENT_PATH to allow env TBB_DIR=XXX
set(_find_package_no_args NO_PACKAGE_ROOT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_SYSTEM_PATH
${_no_cmake_install_prefix}
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
unset(_no_cmake_install_prefix)
endif()
find_package(TBB QUIET COMPONENTS tbb tbbmalloc
@ -68,7 +82,7 @@ macro(ov_find_package_tbb)
if(NOT TBB_FOUND)
set(THREADING "SEQ")
set(ENABLE_TBBBIND_2_5 OFF)
message(WARNING "TBB was not found by the configured TBB_DIR/TBBROOT path.\
message(WARNING "TBB was not found by the configured TBB_DIR / TBBROOT path.\
SEQ method will be used.")
else()
message(STATUS "TBB (${TBB_VERSION}) is found at ${TBB_DIR}")

View File

@ -99,7 +99,7 @@ endif()
# install only downloaded | custom TBB, system one is not installed
# - downloaded TBB should be a part of all packages
# - custom TBB provided by users, needs to be a part of wheel packages
# - TODO: system TBB also needs to be a part of wheel packages
# - system TBB also needs to be a part of wheel packages
if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
( (DEFINED TBB AND TBB MATCHES ${TEMP}) OR
(DEFINED TBBROOT OR DEFINED TBB_DIR OR DEFINED ENV{TBBROOT} OR
@ -121,7 +121,7 @@ if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND
if(ENABLE_SYSTEM_TBB)
# TODO: what's about tbbbind for cases U22 with >= TBB 20221
# it seems that oneTBB from U22 distro does not contains tbbbind library
# message(FATAL_ERROR "TBB_IMPORTED_TARGETS - ${TBB_IMPORTED_TARGETS}")
# the same situation for conda-forge distribution of TBB / oneTBB
# for system libraries we still need to install TBB libraries
# so, need to take locations of actual libraries and install them