Debian Codegraph @

third-party/tbb/cmake/templates/TBBConfig.cmake.in

raw
1 # Copyright (c) 2017-2023 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
22 if (NOT TBB_IMPORTED_TARGETS)
23 set(TBB_IMPORTED_TARGETS "")
24 endif()
25
26 if (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()
31 endif()
32
33 get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
34 get_filename_component(_tbb_root "${_tbb_root}/@TBB_ROOT_REL_PATH@" ABSOLUTE)
35
36 set(TBB_INTERFACE_VERSION @TBB_INTERFACE_VERSION@)
37 @TBB_COMPONENTS_BIN_VERSION@
38 # Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc
39 list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix)
40 if (NOT _tbbmalloc_proxy_ix EQUAL -1)
41 list(APPEND TBB_FIND_COMPONENTS tbbmalloc)
42 list(REMOVE_DUPLICATES TBB_FIND_COMPONENTS)
43 set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
44 endif()
45 unset(_tbbmalloc_proxy_ix)
46
47 if (CMAKE_SIZEOF_VOID_P STREQUAL "8")
48 set(_tbb_intel_arch intel64)
49 else ()
50 set(_tbb_intel_arch ia32)
51 set(_tbb_arch_suffix 32)
52 endif()
53
54 @TBB_HANDLE_SUBDIRS@
55 foreach (_tbb_component ${TBB_FIND_COMPONENTS})
56 unset(_tbb_release_dll CACHE)
57 unset(_tbb_debug_dll CACHE)
58 unset(_tbb_release_lib CACHE)
59 unset(_tbb_debug_lib CACHE)
60
61 set(TBB_${_tbb_component}_FOUND 0)
62 @TBB_HANDLE_BIN_VERSION@
63
64 find_library(_tbb_release_lib
65 NAMES @TBB_LIB_PREFIX@${_tbb_component}${_bin_version}.@TBB_LIB_EXT@
66 PATHS ${_tbb_root}
67 PATH_SUFFIXES "@TBB_LIB_REL_PATH@/${_tbb_intel_arch}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}" "@TBB_LIB_REL_PATH@"
68 NO_DEFAULT_PATH
69 )
70
71 if (NOT TBB_FIND_RELEASE_ONLY)
72 find_library(_tbb_debug_lib
73 NAMES @TBB_LIB_PREFIX@${_tbb_component}${_bin_version}_debug.@TBB_LIB_EXT@
74 PATHS ${_tbb_root}
75 PATH_SUFFIXES "@TBB_LIB_REL_PATH@/${_tbb_intel_arch}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}" "@TBB_LIB_REL_PATH@"
76 NO_DEFAULT_PATH
77 )
78 endif()
79
80 if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}")
81 if (NOT TARGET TBB::${_tbb_component})
82 add_library(TBB::${_tbb_component} SHARED IMPORTED)
83
84 get_filename_component(_tbb_include_dir "${_tbb_root}/@TBB_INC_REL_PATH@" ABSOLUTE)
85 set_target_properties(TBB::${_tbb_component} PROPERTIES
86 INTERFACE_INCLUDE_DIRECTORIES "${_tbb_include_dir}"@TBB_COMPILE_DEFINITIONS@)
87 unset(_tbb_current_realpath)
88 unset(_tbb_include_dir)
89
90 @TBB_HANDLE_IMPLIB@
91
92 if (EXISTS "${_tbb_release_dll}")
93 set_target_properties(TBB::${_tbb_component} PROPERTIES
94 IMPORTED_LOCATION_RELEASE "${_tbb_release_dll}"@TBB_IMPLIB_RELEASE@)
95 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
96 endif()
97
98 if (EXISTS "${_tbb_debug_dll}")
99 set_target_properties(TBB::${_tbb_component} PROPERTIES
100 IMPORTED_LOCATION_DEBUG "${_tbb_debug_dll}"@TBB_IMPLIB_DEBUG@)
101 set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
102 endif()
103
104 # Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc
105 if (_tbb_component STREQUAL tbbmalloc_proxy)
106 set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc)
107 endif()
108 endif()
109 list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
110 set(TBB_${_tbb_component}_FOUND 1)
111 elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component})
112 message(STATUS "Missed required oneTBB component: ${_tbb_component}")
113 if (TBB_FIND_RELEASE_ONLY)
114 message(STATUS " ${_tbb_release_lib} must exist.")
115 else()
116 message(STATUS " one or both of:\n ${_tbb_release_lib}\n ${_tbb_debug_lib}\n files must exist.")
117 endif()
118 set(TBB_FOUND FALSE)
119 endif()
120 endforeach()
121 list(REMOVE_DUPLICATES TBB_IMPORTED_TARGETS)
122 unset(_tbb_release_dll)
123 unset(_tbb_debug_dll)
124 unset(_tbb_release_lib)
125 unset(_tbb_debug_lib)
126 unset(_tbb_root)
127 unset(_tbb_intel_arch)
128 unset(_tbb_arch_suffix)