1# Copyright (c) 2017-2020 Intel Corporation 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# It defines the following variables: 16# TBB_<component>_FOUND 17# TBB_IMPORTED_TARGETS 18# 19# TBBConfigVersion.cmake defines TBB_VERSION 20# 21# Initialize to default values 22if (NOT TBB_IMPORTED_TARGETS) 23 set(TBB_IMPORTED_TARGETS "") 24endif() 25 26if (NOT TBB_FIND_COMPONENTS) 27 set(TBB_FIND_COMPONENTS "tbb;tbbmalloc;tbbmalloc_proxy") 28 foreach (_tbb_component ${TBB_FIND_COMPONENTS}) 29 set(TBB_FIND_REQUIRED_${_tbb_component} 1) 30 endforeach() 31endif() 32 33# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc 34list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix) 35if (NOT _tbbmalloc_proxy_ix EQUAL -1) 36 list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix) 37 if (_tbbmalloc_ix EQUAL -1) 38 list(APPEND TBB_FIND_COMPONENTS tbbmalloc) 39 set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy}) 40 endif() 41endif() 42 43set(TBB_INTERFACE_VERSION 11103) 44 45get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_FILE}" PATH) 46get_filename_component(_tbb_root "${_tbb_root}" PATH) 47 48foreach (_tbb_component ${TBB_FIND_COMPONENTS}) 49 set(TBB_${_tbb_component}_FOUND 0) 50 51 set(_tbb_release_lib "/home/twhuang/Code/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_release/lib${_tbb_component}.so.2") 52 53 if (NOT TBB_FIND_RELEASE_ONLY) 54 set(_tbb_debug_lib "/home/twhuang/Code/taskflow/build/benchmarks/tbb_cmake_build/tbb_cmake_build_subdir_debug/lib${_tbb_component}_debug.so.2") 55 endif() 56 57 if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}") 58 if (NOT TARGET TBB::${_tbb_component}) 59 add_library(TBB::${_tbb_component} SHARED IMPORTED) 60 set_target_properties(TBB::${_tbb_component} PROPERTIES 61 INTERFACE_INCLUDE_DIRECTORIES "${_tbb_root}/include") 62 63 if (EXISTS "${_tbb_release_lib}") 64 set_target_properties(TBB::${_tbb_component} PROPERTIES 65 IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}") 66 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 67 endif() 68 69 if (EXISTS "${_tbb_debug_lib}") 70 set_target_properties(TBB::${_tbb_component} PROPERTIES 71 IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}") 72 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 73 endif() 74 75 # Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc 76 if (_tbb_component STREQUAL tbbmalloc_proxy) 77 set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc) 78 endif() 79 endif() 80 list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component}) 81 set(TBB_${_tbb_component}_FOUND 1) 82 elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component}) 83 message(STATUS "Missed required Intel TBB component: ${_tbb_component}") 84 if (TBB_FIND_RELEASE_ONLY) 85 message(STATUS " ${_tbb_release_lib} must exist.") 86 else() 87 message(STATUS " one or both of:\n ${_tbb_release_lib}\n ${_tbb_debug_lib}\n files must exist.") 88 endif() 89 set(TBB_FOUND FALSE) 90 endif() 91endforeach() 92list(REMOVE_DUPLICATES TBB_IMPORTED_TARGETS) 93 94unset(_tbbmalloc_proxy_ix) 95unset(_tbbmalloc_ix) 96unset(_tbb_lib_path) 97unset(_tbb_release_lib) 98unset(_tbb_debug_lib) 99