From 7dc40dc69f0b3f61795c3558d56103b4bb4be5ab Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 5 Nov 2020 11:32:46 +0300 Subject: [PATCH] Moved find_package(TBB) inside set_ie_threading_interface_for (#2966) --- inference-engine/cmake/ie_parallel.cmake | 40 +++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/inference-engine/cmake/ie_parallel.cmake b/inference-engine/cmake/ie_parallel.cmake index 7fd77ccc06c..de39ac7cfb4 100644 --- a/inference-engine/cmake/ie_parallel.cmake +++ b/inference-engine/cmake/ie_parallel.cmake @@ -2,24 +2,28 @@ # SPDX-License-Identifier: Apache-2.0 # -if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") - find_package(TBB COMPONENTS tbb tbbmalloc) - if (TBB_FOUND) - if (${TBB_VERSION} VERSION_LESS 2020) - ext_message(WARNING "TBB version is less than OpenVINO recommends to use.\ - Some TBB related features like NUMA-aware tbb::task_arena\ - execution will be disabled.") - endif() - else () - ext_message(WARNING "TBB was not found by the configured TBB_DIR/TBBROOT path. \ - SEQ method will be used.") - endif () -endif() - 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) + set("TBB_FOUND" ${TBB_FOUND} PARENT_SCOPE) + set("TBB_IMPORTED_TARGETS" ${TBB_IMPORTED_TARGETS} PARENT_SCOPE) + if (TBB_FOUND) + if (TBB_VERSION VERSION_LESS 2020) + ext_message(WARNING "TBB version is less than OpenVINO recommends to use.\ + Some TBB related features like NUMA-aware tbb::task_arena\ + execution will be disabled.") + endif() + else () + ext_message(WARNING "TBB was not found by the configured TBB_DIR/TBBROOT path.\ + SEQ method will be used.") + endif () + endif() + get_target_property(target_type ${TARGET_NAME} TYPE) if(target_type STREQUAL "INTERFACE_LIBRARY") set(LINK_TYPE "INTERFACE") + elseif(target_type STREQUAL "EXECUTABLE" OR target_type STREQUAL "OBJECT_LIBRARY") + set(LINK_TYPE "PRIVATE") else() set(LINK_TYPE "PUBLIC") endif() @@ -30,7 +34,7 @@ function(set_ie_threading_interface_for TARGET_NAME) target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN}) else() # 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) if(TARGET ${ITEM}) 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}) endif() get_target_property(compile_definitions ${ITEM} INTERFACE_COMPILE_DEFINITIONS) - if (compile_options) + if (compile_definitions) target_compile_definitions(${TARGET_NAME} ${LINK_TYPE} ${compile_definitions}) endif() endif() @@ -66,7 +70,7 @@ function(set_ie_threading_interface_for TARGET_NAME) set(IE_THREAD_DEFINE "IE_THREAD_TBB") ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${TBB_IMPORTED_TARGETS}) else () - ext_message(WARNING "TBB was not found by the configured TBB_DIR path. \ + ext_message(WARNING "TBB was not found by the configured TBB_DIR path.\ SEQ method will be used for ${TARGET_NAME}") endif () elseif (THREADING STREQUAL "OMP") @@ -120,7 +124,7 @@ function(set_ie_threading_interface_for TARGET_NAME) if (WIN32) ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} "$<$:${OMP_LIBRARIES_DEBUG}>;$<$>:${OMP_LIBRARIES_RELEASE}>") else() - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + if (CMAKE_BUILD_TYPE STREQUAL "Debug") ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_DEBUG}) else() ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_RELEASE})