Warning, /sdk/codevis/cmake/FindTBB.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # FindTBB
0003 # -------
0004 #
0005 # Find Intel's Threading Building Blocks (TBB) include path and libraries.
0006 #
0007 # This module reads hints about search locations from variables:
0008 #
0009 # ::
0010 #
0011 #    TBB_ROOT                         - Root directory of pre-built TBB package.
0012 #                                       Can be an environment variable instead. It is
0013 #                                       derived from the found TBB_INCLUDE_DIR if unset.
0014 #    TBB_ARCH_PLATFORM                - Environment variable which can be used to specify
0015 #                                       architecture and platform specific library path
0016 #                                       suffix (excluding "/lib/" suffix or prefix).
0017 #                                       For MSVC, the appropriate link library path of the
0018 #                                       official pre-built download package from the TBB
0019 #                                       web site is chosen by this module. The path suffix
0020 #                                       derived from this variable takes precedence.
0021 #
0022 # This module considers the following CMake variables set by find_package:
0023 #
0024 # ::
0025 #
0026 #    TBB_FIND_COMPONENTS              - Case-insensitive names of requested libraries:
0027 #                                       tbb, [tbb]malloc, [tbb]malloc_proxy
0028 #    TBB_FIND_REQUIRED_<C>            - Whether TBB library component <C> is required.
0029 #                                       TBB is considered to be not found when at least
0030 #                                       one required library or its include path is missing.
0031 #                                       When no TBB_FIND_COMPONENTS are specified, only the
0032 #                                       threading library "tbb" is required.
0033 #    TBB_FIND_REQUIRED                - Raise FATAL_ERROR when required components not found.
0034 #    TBB_FIND_QUIETLY                 - Suppress all other (status) messages.
0035 #
0036 # The TBB_DEBUG variable can be set to TRUE before find_package(TBB) to
0037 # enable verbose output which helps to debug the processing of this module:
0038 #
0039 # ::
0040 #
0041 #    set(TBB_DEBUG TRUE)
0042 #    find_package(TBB)
0043 #
0044 # This module defines the following variables:
0045 #
0046 # ::
0047 #
0048 #    TBB_FOUND                        - Whether TBB libraries were found.
0049 #    TBB_INCLUDE_DIR                  - TBB library include path where tbb/tbb_stddef.h is located.
0050 #                                       Used as HINTS for find_path of TBB_<C>_INCLUDE_DIR.
0051 #    TBB_INCLUDE_DIRS                 - Include paths of found TBB libraries.
0052 #    TBB_LIBRARIES                    - File paths of found TBB libraries.
0053 #    TBB_VERSION                      - Version for use in VERSION_LESS et al. comparisons.
0054 #    TBB_VERSION_MAJOR                - Major library version number.
0055 #    TBB_VERSION_MINOR                - Minor library version number.
0056 #    TBB_VERSION_STRING               - Version string for output messages.
0057 #    TBB_INTERFACE_VERSION            - API version number.
0058 #    TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major version still supported.
0059 #
0060 # Additionally, for each requested component, this module defines the following variables:
0061 #
0062 # ::
0063 #
0064 #    TBB_TBB_FOUND                    - Whether TBB threading library was found.
0065 #    TBB_TBB_INCLUDE_DIR              - Include path of TBB threading library.
0066 #    TBB_TBB_INCLUDE_DIRS             - Include paths for use of TBB library.
0067 #    TBB_TBB_LIBRARIES                - TBB threading library and transitive link dependencies.
0068 #    TBB_TBB_LIBRARY_RELEASE          - File path of optimized TBB link library.
0069 #    TBB_TBB_LIBRARY_DEBUG            - File path of TBB link library with debug symbols.
0070 #    TBB_TBB_LIBRARY                  - File paths of both "optimized" and "debug" TBB threading link libraries.
0071 #                                       When only one of these is found, this variable is set to either
0072 #                                       TBB_TBB_LIBRARY_RELEASE or TBB_TBB_LIBRARY_DEBUG.
0073 #
0074 #    TBB_MALLOC_FOUND                 - Whether TBB malloc library was found.
0075 #    TBB_MALLOC_INCLUDE_DIR           - Include path of TBB malloc library.
0076 #    TBB_MALLOC_INCLUDE_DIRS          - Include paths for use of TBB malloc library.
0077 #    TBB_MALLOC_LIBRARIES             - TBB malloc library and transitive link dependencies.
0078 #    TBB_MALLOC_LIBRARY_RELEASE       - File path of optimized TBB malloc link library.
0079 #    TBB_MALLOC_LIBRARY_DEBUG         - File path of TBB malloc link library with debug symbols.
0080 #    TBB_MALLOC_LIBRARY               - File paths of both "optimized" and "debug" TBB malloc link libraries.
0081 #                                       When only one of these is found, this variable is set to either
0082 #                                       TBB_MALLOC_LIBRARY_RELEASE or TBB_MALLOC_LIBRARY_DEBUG.
0083 #
0084 #    TBB_MALLOC_PROXY_FOUND           - Whether TBB malloc proxy library was found.
0085 #    TBB_MALLOC_PROXY_INCLUDE_DIR     - Include path of TBB malloc proxy library.
0086 #    TBB_MALLOC_PROXY_INCLUDE_DIRS    - Include paths for use of TBB malloc proxy library.
0087 #    TBB_MALLOC_PROXY_LIBRARIES       - TBB malloc proxy library and transitive link dependencies.
0088 #    TBB_MALLOC_PROXY_LIBRARY_RELEASE - File path of optimized TBB malloc proxy link library.
0089 #    TBB_MALLOC_PROXY_LIBRARY_DEBUG   - File path of TBB malloc proxy link library with debug symbols.
0090 #    TBB_MALLOC_PROXY_LIBRARY         - File paths of both "optimized" and "debug" TBB malloc proxy link libraries.
0091 #                                       When only one of these is found, this variable is set to either
0092 #                                       TBB_MALLOC_PROXY_LIBRARY_RELEASE or TBB_MALLOC_PROXY_LIBRARY_DEBUG.
0093 #
0094 # of these, the following variables are added as advanced cache entries:
0095 #
0096 # ::
0097 #
0098 #    TBB_INCLUDE_DIR
0099 #    TBB_<C>_INCLUDE_DIR
0100 #    TBB_<C>_LIBRARY_RELEASE
0101 #    TBB_<C>_LIBRARY_DEBUG
0102 #
0103 # This module further defines the following import targets with the IMPORTED and INTERFACE
0104 # properties set appropriately such that only a target_link_libraries command is required
0105 # to declare the dependency of another target on the respective TBB library component.
0106 # The use of these import targets instead of above defined variables is recommended.
0107 #
0108 # ::
0109 #
0110 #    TBB::tbb          - TBB threading library.
0111 #    TBB::malloc       - TBB malloc library.
0112 #    TBB::malloc_proxy - TBB malloc proxy library.
0113 #
0114 # Example usage:
0115 #
0116 # ::
0117 #
0118 #    find_package(TBB REQUIRED COMPONENTS tbb OPTIONAL_COMPONENTS malloc)
0119 #
0120 #    add_executable(foo foo.cc)
0121 #    target_link_libraries(foo TBB::tbb)
0122 #    if (TARGET TBB::malloc)
0123 #    # or if (TBB_MALLOC_FOUND)
0124 #      target_link_libraries(foo TBB::malloc)
0125 #    endif ()
0126 #
0127 # This module was written by Andreas Schuh for CMake BASIS with inspiration
0128 # from the FindTBB module which was originally part of the Object-oriented
0129 # Graphics Rendering Engine (OGRE) project with modifications by Robert Maynard.
0130 
0131 #=============================================================================
0132 # Copyright 2016 Andreas Schuh <andreas.schuh.84@gmail.com>
0133 #
0134 # Distributed under the OSI-approved BSD License (the "License");
0135 # see accompanying file Copyright.txt for details.
0136 #
0137 # This software is distributed WITHOUT ANY WARRANTY; without even the
0138 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0139 # See the License for more information.
0140 #=============================================================================
0141 # (To distribute this file outside of CMake, substitute the full
0142 #  License text for the above reference.)
0143 
0144 if (NOT TBB_FIND_QUIETLY)
0145   set(_TBB_FIND_STATUS "Looking for TBB")
0146   if (TBB_FIND_COMPONENTS)
0147     set(_TBB_FIND_STATUS "${_TBB_FIND_STATUS} [${TBB_FIND_COMPONENTS}]")
0148   endif ()
0149   if (NOT TBB_FIND_REQUIRED)
0150     set(_TBB_FIND_STATUS "${_TBB_FIND_STATUS} (optional)")
0151   endif ()
0152   message(STATUS "${_TBB_FIND_STATUS}...")
0153 endif ()
0154 
0155 # ------------------------------------------------------------------------------
0156 # Default required/optional components
0157 if (NOT TBB_FIND_COMPONENTS)
0158   set(TBB_FIND_COMPONENTS tbb malloc malloc_proxy)
0159   set(TBB_FIND_REQUIRED_tbb          TRUE)
0160   set(TBB_FIND_REQUIRED_malloc       FALSE)
0161   set(TBB_FIND_REQUIRED_malloc_proxy FALSE)
0162 endif ()
0163 
0164 # ------------------------------------------------------------------------------
0165 # Normalize component names
0166 set(_TBB_FIND_COMPONENTS)
0167 foreach (__TBB_COMPONENT IN LISTS TBB_FIND_COMPONENTS)
0168   string(TOUPPER "${__TBB_COMPONENT}" _TBB_COMPONENT)
0169   string(REGEX REPLACE "^TBB_?([A-Z_]+)$" "\\1" _TBB_COMPONENT "${_TBB_COMPONENT}")
0170   if (_TBB_COMPONENT MATCHES "^(TBB|MALLOC|MALLOC_PROXY)$")
0171     set(_TBB_${_TBB_COMPONENT}_NAME ${__TBB_COMPONENT})
0172     list(APPEND _TBB_FIND_COMPONENTS ${_TBB_COMPONENT})
0173     if (TBB_FIND_REQUIRED_${__TBB_COMPONENT})
0174       set(_TBB_FIND_REQUIRED_${_TBB_COMPONENT} TRUE)
0175     else ()
0176       set(_TBB_FIND_REQUIRED_${_TBB_COMPONENT} FALSE)
0177     endif ()
0178   else ()
0179     message(FATAL_ERROR "Unknown TBB library component: ${__TBB_COMPONENT}\n"
0180                         "Valid component names are: tbb, [tbb]malloc, [tbb]malloc_proxy")
0181   endif ()
0182 endforeach ()
0183 unset(__TBB_COMPONENT)
0184 
0185 if (TBB_DEBUG)
0186   message("** FindTBB: Components = [${_TBB_FIND_COMPONENTS}]")
0187 endif ()
0188 
0189 # ------------------------------------------------------------------------------
0190 # Names of headers and libraries for each component
0191 set(_TBB_TBB_LIB_NAMES_RELEASE          tbb)
0192 set(_TBB_TBB_LIB_NAMES_DEBUG            tbb_debug)
0193 set(_TBB_TBB_INC_NAMES                  tbb/tbb.h)
0194 
0195 set(_TBB_MALLOC_LIB_NAMES_RELEASE       tbbmalloc)
0196 set(_TBB_MALLOC_LIB_NAMES_DEBUG         tbbmalloc_debug)
0197 set(_TBB_MALLOC_INC_NAMES               tbb/tbb.h)
0198 
0199 set(_TBB_MALLOC_PROXY_LIB_NAMES_RELEASE tbbmalloc_proxy)
0200 set(_TBB_MALLOC_PROXY_LIB_NAMES_DEBUG   tbbmalloc_proxy_debug)
0201 set(_TBB_MALLOC_PROXY_INC_NAMES         tbb/tbbmalloc_proxy.h)
0202 
0203 # ------------------------------------------------------------------------------
0204 # Transitive link dependencies
0205 set(_TBB_TBB_LIB_LINK_DEPENDS)
0206 set(_TBB_MALLOC_LIB_LINK_DEPENDS)
0207 set(_TBB_MALLOC_PROXY_LIB_LINK_DEPENDS)
0208 
0209 if (UNIX AND NOT APPLE)
0210   # On Linux, the TBB threading library requires librt.so
0211   list(APPEND _TBB_TBB_LIB_LINK_DEPENDS rt)
0212 endif ()
0213 
0214 # ------------------------------------------------------------------------------
0215 # Construct a set of search paths
0216 set(_TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM})
0217 
0218 if (NOT TBB_ROOT)
0219   file(TO_CMAKE_PATH "$ENV{TBB_ROOT}" TBB_ROOT)
0220 endif ()
0221 
0222 set(_TBB_INC_PATH_SUFFIXES include)
0223 
0224 set(_TBB_LIB_PATH_SUFFIXES)
0225 if (_TBB_ARCH_PLATFORM)
0226   list(APPEND _TBB_LIB_PATH_SUFFIXES lib/${_TBB_ARCH_PLATFORM})
0227   list(APPEND _TBB_LIB_PATH_SUFFIXES ${_TBB_ARCH_PLATFORM}/lib)
0228 endif ()
0229 list(APPEND _TBB_LIB_PATH_SUFFIXES lib)
0230 
0231 if (WIN32 AND MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio ([0-9]+)")
0232   set(_TBB_MSVS_VERSION ${CMAKE_MATCH_1})
0233   if (CMAKE_CL_64)
0234     list(APPEND _TBB_LIB_PATH_SUFFIXES lib/intel64/vc${_TBB_MSVS_VERSION})
0235     list(APPEND _TBB_LIB_PATH_SUFFIXES intel64/vc${_TBB_MSVS_VERSION}/lib)
0236     list(APPEND _TBB_LIB_PATH_SUFFIXES lib/ia64/vc${_TBB_MSVS_VERSION})
0237     list(APPEND _TBB_LIB_PATH_SUFFIXES ia64/vc${_TBB_MSVS_VERSION}/lib)
0238   else ()
0239     list(APPEND _TBB_LIB_PATH_SUFFIXES lib/ia32/vc${_TBB_MSVS_VERSION})
0240     list(APPEND _TBB_LIB_PATH_SUFFIXES ia32/vc${_TBB_MSVS_VERSION}/lib)
0241   endif ()
0242   unset(_TBB_MSVS_VERSION)
0243 endif ()
0244 
0245 if (TBB_DEBUG)
0246   message("** FindTBB: Initial search paths:")
0247   message("** FindTBB: - Root directory hints  = [${TBB_ROOT}]")
0248   message("** FindTBB: - Include path suffixes = [${_TBB_INC_PATH_SUFFIXES}]")
0249   message("** FindTBB: - Library path suffixes = [${_TBB_LIB_PATH_SUFFIXES}]")
0250 endif ()
0251 
0252 # ------------------------------------------------------------------------------
0253 # Find common include directory
0254 #
0255 # Looking for tbb/tbb_stddef.h because we use this path later to read this file
0256 # in order to extract the version information. The tbb.h header should be in the
0257 # same directory and is searched for separately as part of the "tbb" and "malloc"
0258 # component search. The TBB_INCLUDE_DIR is then used as HINTS.
0259 find_path(TBB_INCLUDE_DIR
0260   NAMES tbb/tbb_stddef.h
0261   HINTS ${TBB_ROOT}
0262   PATH_SUFFIXES ${_TBB_INC_PATH_SUFFIXES}
0263 )
0264 
0265 mark_as_advanced(TBB_INCLUDE_DIR)
0266 
0267 # ------------------------------------------------------------------------------
0268 # Derive TBB_ROOT from TBB_INCLUDE_DIR if unset
0269 if (TBB_INCLUDE_DIR AND NOT TBB_ROOT)
0270   if (_TBB_INC_PATH_SUFFIXES MATCHES "[^/;]/[^/;]")
0271     string(LENGTH "${TBB_INCLUDE_DIR}" _TBB_INCLUDE_DIR_LENGTH)
0272     foreach (_TBB_INC_PATH_SUFFIX IN LISTS _TBB_INC_PATH_SUFFIXES)
0273       string(LENGTH "${_TBB_INC_PATH_SUFFIX}" _TBB_INC_PATH_SUFFIX_LENGTH)
0274       if (_TBB_INC_PATH_SUFFIX_LENGTH GREATER 0)
0275         math(EXPR _TBB_SUBSTRING_START "${_TBB_INCLUDE_DIR_LENGTH} - ${_TBB_INC_PATH_SUFFIX_LENGTH}")
0276         string(SUBSTRING "${TBB_INCLUDE_DIR}" _TBB_SUBSTRING_START -1 _TBB_SUBSTRING)
0277         if (_TBB_SUBSTRING STREQUAL _TBB_INC_PATH_SUFFIX)
0278           if (_TBB_SUBSTRING_START GREATER 0)
0279             string(SUBSTRING "${TBB_INCLUDE_DIR}" 0 _TBB_SUBSTRING_START TBB_ROOT)
0280             string(REGEX REPLACE "/+$" "" TBB_ROOT "${TBB_ROOT}")
0281           else ()
0282             set(TBB_ROOT "/")
0283           endif ()
0284           break()
0285         endif ()
0286       endif ()
0287     endforeach ()
0288     unset(_TBB_SUBSTRING)
0289     unset(_TBB_SUBSTRING_START)
0290     unset(_TBB_INCLUDE_DIR_LENGTH)
0291     unset(_TBB_INC_PATH_SUFFIX_LENGTH)
0292   else ()
0293     get_filename_component(TBB_ROOT "${TBB_INCLUDE_DIR}" DIRECTORY)
0294   endif ()
0295 endif ()
0296 
0297 if (TBB_DEBUG)
0298   message("** FindTBB: After initial search of TBB include path")
0299   message("** FindTBB: - TBB_INCLUDE_DIR = ${TBB_INCLUDE_DIR}")
0300   message("** FindTBB: - TBB_ROOT        = [${TBB_ROOT}]")
0301 endif ()
0302 
0303 # ------------------------------------------------------------------------------
0304 # Find library components
0305 set(TBB_INCLUDE_DIRS)
0306 set(TBB_LIBRARIES)
0307 
0308 foreach (_TBB_COMPONENT IN LISTS _TBB_FIND_COMPONENTS)
0309   if (TBB_DEBUG)
0310     message("** FindTBB: Looking for component ${_TBB_COMPONENT}...")
0311   endif ()
0312 
0313   # Find include path and library files of this component
0314   find_path(TBB_${_TBB_COMPONENT}_INCLUDE_DIR
0315     NAMES ${_TBB_${_TBB_COMPONENT}_INC_NAMES}
0316     HINTS ${TBB_INCLUDE_DIR} ${TBB_ROOT}
0317     PATH_SUFFIXES ${_TBB_INC_PATH_SUFFIXES}
0318   )
0319 
0320   find_library(TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE
0321     NAMES ${_TBB_${_TBB_COMPONENT}_LIB_NAMES_RELEASE}
0322     HINTS ${TBB_ROOT}
0323     PATH_SUFFIXES ${_TBB_LIB_PATH_SUFFIXES}
0324   )
0325 
0326   find_library(TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG
0327     NAMES ${_TBB_${_TBB_COMPONENT}_LIB_NAMES_DEBUG}
0328     HINTS ${TBB_ROOT}
0329     PATH_SUFFIXES ${_TBB_LIB_PATH_SUFFIXES}
0330   )
0331 
0332   if (TBB_DEBUG)
0333     message("** FindTBB: - TBB_${_TBB_COMPONENT}_INCLUDE_DIR     = ${TBB_${_TBB_COMPONENT}_INCLUDE_DIR}")
0334     message("** FindTBB: - TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE = ${TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE}")
0335     message("** FindTBB: - TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG   = ${TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG}")
0336   endif ()
0337 
0338   # Mark cache entries as advanced
0339   mark_as_advanced(TBB_${_TBB_COMPONENT}_INCLUDE_DIR)
0340   mark_as_advanced(TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE)
0341   mark_as_advanced(TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG)
0342 
0343   # Set TBB_<C>_LIBRARY
0344   if (TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE AND TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG)
0345     set(TBB_${_TBB_COMPONENT}_LIBRARY
0346       optimized ${TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE}
0347       debug     ${TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG}
0348     )
0349   elseif (TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE)
0350     set(TBB_${_TBB_COMPONENT}_LIBRARY ${TBB_${_TBB_COMPONENT}_LIBRARY_RELEASE})
0351   elseif (TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG)
0352     set(TBB_${_TBB_COMPONENT}_LIBRARY ${TBB_${_TBB_COMPONENT}_LIBRARY_DEBUG})
0353   else ()
0354     set(TBB_${_TBB_COMPONENT}_LIBRARY TBB_${_TBB_COMPONENT}_LIBRARY-NOTFOUND)
0355   endif ()
0356 
0357   # Set TBB_<C>_FOUND
0358   if (TBB_${_TBB_COMPONENT}_INCLUDE_DIR AND TBB_${_TBB_COMPONENT}_LIBRARY)
0359     set(TBB_${_TBB_COMPONENT}_FOUND TRUE)
0360   else ()
0361     set(TBB_${_TBB_COMPONENT}_FOUND FALSE)
0362   endif ()
0363   set(TBB_${_TBB_${_TBB_COMPONENT}_NAME}_FOUND ${TBB_${_TBB_COMPONENT}_FOUND})
0364 
0365   if (TBB_${_TBB_COMPONENT}_FOUND)
0366 
0367     # Add transitive dependencies
0368     set(TBB_${_TBB_COMPONENT}_INCLUDE_DIRS ${TBB_${_TBB_COMPONENT}_INCLUDE_DIR})
0369     set(TBB_${_TBB_COMPONENT}_LIBRARIES    ${TBB_${_TBB_COMPONENT}_LIBRARY})
0370     if (_TBB_${_TBB_COMPONENT}_LIB_LINK_DEPENDS)
0371       list(APPEND TBB_${_TBB_COMPONENT}_LIBRARIES "${_TBB_${_TBB_COMPONENT}_LIB_LINK_DEPENDS}")
0372     endif ()
0373 
0374     if (TBB_DEBUG)
0375       message("** FindTBB: - TBB_${_TBB_COMPONENT}_INCLUDE_DIRS    = [${TBB_${_TBB_COMPONENT}_INCLUDE_DIRS}]")
0376       message("** FindTBB: - TBB_${_TBB_COMPONENT}_LIBRARIES       = [${TBB_${_TBB_COMPONENT}_LIBRARIES}]")
0377     endif ()
0378 
0379     # Add to TBB_INCLUDE_DIRS and TBB_LIBRARIES
0380     list(APPEND TBB_INCLUDE_DIRS ${TBB_${_TBB_COMPONENT}_INCLUDE_DIRS})
0381     list(APPEND TBB_LIBRARIES    ${TBB_${_TBB_COMPONENT}_LIBRARIES})
0382 
0383     # Add TBB::<C> import target
0384     string(TOLOWER ${_TBB_COMPONENT} _TBB_TARGET_NAME)
0385     set(_TBB_TARGET_NAME "TBB::${_TBB_TARGET_NAME}")
0386     add_library(${_TBB_TARGET_NAME} SHARED IMPORTED)
0387 
0388     set_target_properties(${_TBB_TARGET_NAME} PROPERTIES
0389       INTERFACE_INCLUDE_DIRECTORIES     "${TBB_${_TBB_COMPONENT}_INCLUDE_DIRS}"
0390       IMPORTED_LINK_INTERFACE_LANGUAGES CXX
0391       IMPORTED_NO_SONAME                TRUE
0392     )
0393     if (_TBB_${_TBB_COMPONENT}_LIB_LINK_DEPENDS)
0394       set_target_properties(${_TBB_TARGET_NAME} PROPERTIES
0395         INTERFACE_LINK_LIBRARIES "${_TBB_${_TBB_COMPONENT}_LIB_LINK_DEPENDS}"
0396       )
0397     endif ()
0398 
0399     foreach (_TBB_CONFIGURATION IN ITEMS DEBUG RELEASE)
0400       if (TBB_${_TBB_COMPONENT}_LIBRARY_${_TBB_CONFIGURATION})
0401         set_property(TARGET ${_TBB_TARGET_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${_TBB_CONFIGURATION})
0402         if (WIN32)
0403           set_target_properties(${_TBB_TARGET_NAME} PROPERTIES
0404             IMPORTED_IMPLIB_${_TBB_CONFIGURATION} "${TBB_${_TBB_COMPONENT}_LIBRARY_${_TBB_CONFIGURATION}}"
0405           )
0406           string(REPLACE       "/lib/"   "/bin/" _TBB_LIB_PATH_DLL "${TBB_${_TBB_COMPONENT}_LIBRARY_${_TBB_CONFIGURATION}}")
0407           string(REGEX REPLACE "\\.lib$" ".dll"  _TBB_LIB_PATH_DLL "${_TBB_LIB_PATH_DLL}")
0408           if (EXISTS "${_TBB_LIB_PATH_DLL}")
0409             set_target_properties(${_TBB_TARGET_NAME} PROPERTIES
0410               IMPORTED_LOCATION_${_TBB_CONFIGURATION} "${_TBB_LIB_PATH_DLL}"
0411             )
0412             if (TBB_DEBUG)
0413               message("** FindTBB: - IMPORTED_LOCATION_${_TBB_CONFIGURATION} = ${_TBB_LIB_PATH_DLL}")
0414             endif ()
0415           elseif (TBB_DEBUG)
0416             message("** FindTBB: Could not determine ${_TBB_CONFIGURATION} DLL path from import library, tried: "
0417                     "\n\t${_TBB_LIB_PATH_DLL}")
0418           endif ()
0419         else ()
0420           set_target_properties(${_TBB_TARGET_NAME} PROPERTIES
0421             IMPORTED_LOCATION_${_TBB_CONFIGURATION} "${TBB_${_TBB_COMPONENT}_LIBRARY_${_TBB_CONFIGURATION}}"
0422           )
0423         endif ()
0424       endif ()
0425     endforeach ()
0426 
0427     if (TBB_DEBUG)
0428       message("** FindTBB: Looking for component ${_TBB_COMPONENT}... - found")
0429     endif ()
0430 
0431   else ()
0432 
0433     if (TBB_DEBUG)
0434       message("** FindTBB: Looking for component ${_TBB_COMPONENT}... - not found")
0435     endif ()
0436     unset(TBB_${_TBB_COMPONENT}_INCLUDE_DIRS)
0437     unset(TBB_${_TBB_COMPONENT}_LIBRARIES)
0438 
0439   endif ()
0440 endforeach ()
0441 
0442 if (TBB_INCLUDE_DIRS)
0443   list(REMOVE_DUPLICATES TBB_INCLUDE_DIRS)
0444 endif ()
0445 
0446 if (TBB_DEBUG)
0447   message("** FindTBB: Include paths and libraries of all found components:")
0448   message("** FindTBB: - TBB_INCLUDE_DIRS = [${TBB_INCLUDE_DIRS}]")
0449   message("** FindTBB: - TBB_LIBRARIES    = [${TBB_LIBRARIES}]")
0450 endif ()
0451 
0452 # ------------------------------------------------------------------------------
0453 # Extract library version from start of tbb_stddef.h
0454 if (TBB_INCLUDE_DIR)
0455   if (NOT DEFINED TBB_VERSION_MAJOR OR
0456       NOT DEFINED TBB_VERSION_MINOR OR
0457       NOT DEFINED TBB_INTERFACE_VERSION OR
0458       NOT DEFINED TBB_COMPATIBLE_INTERFACE_VERSION)
0459     file(READ "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS LIMIT 2048)
0460     string(REGEX REPLACE
0461       ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
0462       TBB_VERSION_MAJOR "${_TBB_VERSION_CONTENTS}"
0463     )
0464     string(REGEX REPLACE
0465       ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
0466       TBB_VERSION_MINOR "${_TBB_VERSION_CONTENTS}"
0467     )
0468     string(REGEX REPLACE
0469       ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
0470       TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}"
0471     )
0472     string(REGEX REPLACE
0473       ".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
0474       TBB_COMPATIBLE_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}"
0475     )
0476     unset(_TBB_VERSION_CONTENTS)
0477   endif ()
0478   set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}")
0479   set(TBB_VERSION_STRING "${TBB_VERSION}")
0480 else ()
0481   unset(TBB_VERSION)
0482   unset(TBB_VERSION_MAJOR)
0483   unset(TBB_VERSION_MINOR)
0484   unset(TBB_VERSION_STRING)
0485   unset(TBB_INTERFACE_VERSION)
0486   unset(TBB_COMPATIBLE_INTERFACE_VERSION)
0487 endif ()
0488 
0489 if (TBB_DEBUG)
0490   message("** FindTBB: Version information from ${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h")
0491   message("** FindTBB: - TBB_VERSION_STRING               = ${TBB_VERSION_STRING}")
0492   message("** FindTBB: - TBB_VERSION_MAJOR                = ${TBB_VERSION_MAJOR}")
0493   message("** FindTBB: - TBB_VERSION_MINOR                = ${TBB_VERSION_MINOR}")
0494   message("** FindTBB: - TBB_INTERFACE_VERSION            = ${TBB_INTERFACE_VERSION}")
0495   message("** FindTBB: - TBB_COMPATIBLE_INTERFACE_VERSION = ${TBB_COMPATIBLE_INTERFACE_VERSION}")
0496 endif ()
0497 
0498 # ------------------------------------------------------------------------------
0499 # Handle QUIET, REQUIRED, and [EXACT] VERSION arguments and set TBB_FOUND
0500 include(FindPackageHandleStandardArgs)
0501 find_package_handle_standard_args(TBB
0502   REQUIRED_VARS TBB_INCLUDE_DIR
0503   VERSION_VAR   TBB_VERSION
0504   HANDLE_COMPONENTS
0505 )
0506 
0507 if (NOT TBB_FIND_QUIETLY)
0508   if (TBB_FOUND)
0509     message(STATUS "${_TBB_FIND_STATUS}... - found v${TBB_VERSION_STRING}")
0510   else ()
0511     message(STATUS "${_TBB_FIND_STATUS}... - not found")
0512   endif ()
0513 endif ()
0514 
0515 # ------------------------------------------------------------------------------
0516 # Unset local auxiliary variables
0517 foreach (_TBB_COMPONENT IN ITEMS TBB MALLOC MALLOC_PROXY)
0518   unset(_TBB_FIND_REQUIRED_${_TBB_COMPONENT})
0519   unset(_TBB_${_TBB_COMPONENT}_LIB_NAMES_RELEASE)
0520   unset(_TBB_${_TBB_COMPONENT}_LIB_NAMES_DEBUG)
0521   unset(_TBB_${_TBB_COMPONENT}_LIB_LINK_DEPENDS)
0522   unset(_TBB_${_TBB_COMPONENT}_INC_NAMES)
0523   unset(_TBB_${_TBB_COMPONENT}_NAME)
0524 endforeach ()
0525 
0526 unset(_TBB_COMPONENT)
0527 unset(_TBB_TARGET_NAME)
0528 unset(_TBB_FIND_COMPONENTS)
0529 unset(_TBB_FIND_STATUS)
0530 unset(_TBB_INC_PATH_SUFFIXES)
0531 unset(_TBB_LIB_PATH_SUFFIXES)
0532 unset(_TBB_LIB_PATH_DLL)
0533 unset(_TBB_LIB_NAME)
0534 unset(_TBB_ARCH_PLATFORM)