Moved find_package(TBB) inside set_ie_threading_interface_for (#2966)

This commit is contained in:
Ilya Lavrenov 2020-11-05 11:32:46 +03:00 committed by GitHub
parent 5be7f32f95
commit 7dc40dc69f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,13 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") function(set_ie_threading_interface_for TARGET_NAME)
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
find_package(TBB COMPONENTS tbb tbbmalloc) find_package(TBB COMPONENTS tbb tbbmalloc)
set("TBB_FOUND" ${TBB_FOUND} PARENT_SCOPE)
set("TBB_IMPORTED_TARGETS" ${TBB_IMPORTED_TARGETS} PARENT_SCOPE)
if (TBB_FOUND) if (TBB_FOUND)
if (${TBB_VERSION} VERSION_LESS 2020) if (TBB_VERSION VERSION_LESS 2020)
ext_message(WARNING "TBB version is less than OpenVINO recommends to use.\ ext_message(WARNING "TBB version is less than OpenVINO recommends to use.\
Some TBB related features like NUMA-aware tbb::task_arena\ Some TBB related features like NUMA-aware tbb::task_arena\
execution will be disabled.") execution will be disabled.")
@ -16,10 +19,11 @@ if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
endif () endif ()
endif() endif()
function(set_ie_threading_interface_for TARGET_NAME)
get_target_property(target_type ${TARGET_NAME} TYPE) get_target_property(target_type ${TARGET_NAME} TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY") if(target_type STREQUAL "INTERFACE_LIBRARY")
set(LINK_TYPE "INTERFACE") set(LINK_TYPE "INTERFACE")
elseif(target_type STREQUAL "EXECUTABLE" OR target_type STREQUAL "OBJECT_LIBRARY")
set(LINK_TYPE "PRIVATE")
else() else()
set(LINK_TYPE "PUBLIC") set(LINK_TYPE "PUBLIC")
endif() endif()
@ -30,7 +34,7 @@ function(set_ie_threading_interface_for TARGET_NAME)
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN}) target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})
else() else()
# Object library may not link to anything. # Object library may not link to anything.
# To add interface include directories and compile options explicitly. # To add interface include definitions and compile options explicitly.
foreach(ITEM IN LISTS ARGN) foreach(ITEM IN LISTS ARGN)
if(TARGET ${ITEM}) if(TARGET ${ITEM})
get_target_property(compile_options ${ITEM} INTERFACE_COMPILE_OPTIONS) get_target_property(compile_options ${ITEM} INTERFACE_COMPILE_OPTIONS)
@ -38,7 +42,7 @@ function(set_ie_threading_interface_for TARGET_NAME)
target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${compile_options}) target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${compile_options})
endif() endif()
get_target_property(compile_definitions ${ITEM} INTERFACE_COMPILE_DEFINITIONS) get_target_property(compile_definitions ${ITEM} INTERFACE_COMPILE_DEFINITIONS)
if (compile_options) if (compile_definitions)
target_compile_definitions(${TARGET_NAME} ${LINK_TYPE} ${compile_definitions}) target_compile_definitions(${TARGET_NAME} ${LINK_TYPE} ${compile_definitions})
endif() endif()
endif() endif()
@ -120,7 +124,7 @@ function(set_ie_threading_interface_for TARGET_NAME)
if (WIN32) if (WIN32)
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} "$<$<CONFIG:DEBUG>:${OMP_LIBRARIES_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${OMP_LIBRARIES_RELEASE}>") ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} "$<$<CONFIG:DEBUG>:${OMP_LIBRARIES_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${OMP_LIBRARIES_RELEASE}>")
else() else()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_DEBUG}) ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_DEBUG})
else() else()
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_RELEASE}) ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_RELEASE})