1 #===-- FindTBB.cmake -----------------------------------------------------===##
3 # The LLVM Compiler Infrastructure
5 # This file is dual licensed under the MIT and the University of Illinois Open
6 # Source Licenses. See LICENSE.TXT for details.
8 #===----------------------------------------------------------------------===##
10 include(FindPackageHandleStandardArgs)
12 if (NOT TBB_FIND_COMPONENTS)
13 set(TBB_FIND_COMPONENTS tbb tbbmalloc)
14 foreach (_tbb_component ${TBB_FIND_COMPONENTS})
15 set(TBB_FIND_REQUIRED_${_tbb_component} 1)
19 find_path(_tbb_include_dir tbb/tbb.h)
21 file(READ "${_tbb_include_dir}/tbb/tbb_stddef.h" _tbb_stddef LIMIT 2048)
22 string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_stddef}")
23 string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_stddef}")
24 string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_tbb_stddef}")
26 set(TBB_VERSION "${_tbb_ver_major}.${_tbb_ver_minor}")
32 foreach (_tbb_component ${TBB_FIND_COMPONENTS})
33 find_library(_tbb_release_lib ${_tbb_component})
35 set(TBB_${_tbb_component}_FOUND 1)
37 add_library(TBB::${_tbb_component} SHARED IMPORTED)
38 list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
41 if (UNIX AND NOT APPLE)
42 set(_tbb_lib_suffix ".2")
45 set_target_properties(TBB::${_tbb_component} PROPERTIES
46 IMPORTED_CONFIGURATIONS "RELEASE"
47 IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}${_tbb_lib_suffix}"
48 INTERFACE_INCLUDE_DIRECTORIES "${_tbb_include_dir}")
50 find_library(_tbb_debug_lib ${_tbb_component}_debug)
52 set_target_properties(TBB::${_tbb_component} PROPERTIES
53 IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
54 IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}${_tbb_lib_suffix}")
56 unset(_tbb_debug_lib CACHE)
57 unset(_tbb_lib_suffix)
59 unset(_tbb_release_lib CACHE)
62 unset(_tbb_include_dir CACHE)
64 find_package_handle_standard_args(TBB
65 REQUIRED_VARS TBB_IMPORTED_TARGETS
67 VERSION_VAR TBB_VERSION)