1 # Copyright (c) 2017-2019 Intel Corporation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # It defines the following variables:
18 # TBB_tbbmalloc_proxy_FOUND
19 # TBB_IMPORTED_TARGETS
21 # TBBConfigVersion.cmake defines TBB_VERSION
23 # Initialize to default values
24 if (NOT TBB_tbb_FOUND)
27 if (NOT TBB_tbbmalloc_FOUND)
28 set(TBB_tbbmalloc_FOUND 0)
30 if (NOT TBB_tbbmalloc_proxy_FOUND)
31 set(TBB_tbbmalloc_proxy_FOUND 0)
33 if (NOT TBB_IMPORTED_TARGETS)
34 set(TBB_IMPORTED_TARGETS "")
37 if (NOT TBB_FIND_COMPONENTS)
38 set(TBB_FIND_COMPONENTS "tbb;tbbmalloc;tbbmalloc_proxy")
39 foreach (_tbb_component ${TBB_FIND_COMPONENTS})
40 set(TBB_FIND_REQUIRED_${_tbb_component} 1)
44 # Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc
45 list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix)
46 if (NOT _tbbmalloc_proxy_ix EQUAL -1)
47 list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix)
48 if (_tbbmalloc_ix EQUAL -1)
49 list(APPEND TBB_FIND_COMPONENTS tbbmalloc)
50 set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
54 unset(_tbbmalloc_proxy_ix)
56 foreach (_tbb_component ${TBB_FIND_COMPONENTS})
57 set(_tbb_release_lib "${CMAKE_CURRENT_LIST_DIR}/@TBB_LIB_REL_PATH@/@TBB_LIB_PREFIX@${_tbb_component}.@TBB_LIB_EXT@")
58 set(_tbb_debug_lib "${CMAKE_CURRENT_LIST_DIR}/@TBB_LIB_REL_PATH@/@TBB_LIB_PREFIX@${_tbb_component}_debug.@TBB_LIB_EXT@")
60 if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}")
61 if (NOT TARGET TBB::${_tbb_component})
62 add_library(TBB::${_tbb_component} SHARED IMPORTED)
63 set_target_properties(TBB::${_tbb_component} PROPERTIES
64 INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/@TBB_INC_REL_PATH@")
66 if (EXISTS "${_tbb_release_lib}")
67 set_target_properties(TBB::${_tbb_component} PROPERTIES
68 IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"@TBB_IMPLIB_RELEASE@)
69 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
72 if (EXISTS "${_tbb_debug_lib}")
73 set_target_properties(TBB::${_tbb_component} PROPERTIES
74 IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"@TBB_IMPLIB_DEBUG@)
75 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
78 # Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc
79 if (_tbb_component STREQUAL tbbmalloc_proxy)
80 set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc)
82 list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
84 message(STATUS "Using previously found TBB::${_tbb_component}")
86 set(TBB_${_tbb_component}_FOUND 1)
87 elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component})
88 message(STATUS "Missed required Intel TBB component: ${_tbb_component}")
89 message(STATUS " one or both of:\n ${_tbb_release_lib}\n ${_tbb_debug_lib}\n files must exist.")
91 set(TBB_${_tbb_component}_FOUND 0)
94 unset(_tbb_release_lib)