forked from HSA-Libraries/Bolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindTBB.cmake
125 lines (110 loc) · 5.06 KB
/
FindTBB.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
############################################################################
# Copyright 2012 - 2013 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
############################################################################
# Locate a TBB implementation.
#
# Defines the following variables:
#
# TBB_FOUND - Found the OPENCL framework
# TBB_INCLUDE_DIRS - Include directories
#
# Also defines the library variables below as normal
# variables. These contain debug/optimized keywords when
# a debugging library is found.
#
# TBB_LIBRARY
# TBB_MALLOC_LIBRARY
# TBB_LIBRARY_DEBUG
# TBB_MALLOC_LIBRARY_DEBUG
# TBB_INCLUDE_DIRS
# Accepts the following variables as input:
#
# TBB_ROOT - (as a CMake or environment variable)
# The root directory of the TBB implementation found
#
# FIND_LIBRARY_USE_LIB64_PATHS - Global property that controls whether findTBB should search for
# 64bit or 32bit libs
#-----------------------
# Example Usage:
#
# find_package(TBB REQUIRED)
# include_directories(${TBB_INCLUDE_DIRS})
#
# add_executable(foo foo.cc)
# target_link_libraries(foo ${TBB_LIBRARIES})
#
#-----------------------
set(_TBB_LIB_NAME "tbb")
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
if( MSVC )
if( MSVC_VERSION VERSION_LESS 1700 )
set(TBB_COMPILER "vc10")
else( )
set(TBB_COMPILER "vc11")
endif()
elseif(UNIX)
set(TBB_COMPILER "gcc4.4")
endif()
if ( NOT TBB_ROOT )
set(TBB_ROOT $ENV{TBB_ROOT})
endif( )
message ( STATUS "TBB_ROOT:" ${TBB_ROOT} )
if ( NOT TBB_ROOT )
message( "TBB install not found in the system.")
else ( )
# Search for 64bit libs if FIND_LIBRARY_USE_LIB64_PATHS is set to true in the global environment, 32bit libs else
get_property( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
if( LIB64 )
set(TBB_ARCH_PLATFORM intel64)
else( )
set(TBB_ARCH_PLATFORM ia32)
endif( )
message ( STATUS "TBB_LIB: " ${LIB64} )
#Find TBB header files
find_path( TBB_INCLUDE_DIRS
NAMES tbb/tbb.h
HINTS ${TBB_ROOT}/include
DOC "TBB header file path"
)
mark_as_advanced( TBB_INCLUDE_DIRS )
message ( STATUS "TBB_INCLUDE_DIRS: " ${TBB_INCLUDE_DIRS} )
#Find TBB Libraries
set (_TBB_LIBRARY_DIR ${TBB_ROOT}/lib/${TBB_ARCH_PLATFORM} )
find_library(TBB_LIBRARY ${_TBB_LIB_NAME} HINTS ${_TBB_LIBRARY_DIR}/${TBB_COMPILER}
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME} HINTS ${_TBB_LIBRARY_DIR}/${TBB_COMPILER}
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
find_library(TBB_LIBRARY_DEBUG ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}/${TBB_COMPILER}
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
find_library(TBB_MALLOC_LIBRARY_DEBUG ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}/${TBB_COMPILER}
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
message ( STATUS "TBB_LIBRARY:" ${TBB_LIBRARY})
message ( STATUS "TBB_MALLOC_LIBRARY:" ${TBB_MALLOC_LIBRARY})
message ( STATUS "TBB_LIBRARY_DEBUG:" ${TBB_LIBRARY_DEBUG})
message ( STATUS "TBB_MALLOC_LIBRARY_DEBUG:" ${TBB_MALLOC_LIBRARY_DEBUG})
mark_as_advanced( TBB_LIBRARY )
mark_as_advanced( TBB_MALLOC_LIBRARY )
mark_as_advanced( TBB_LIBRARY_DEBUG )
mark_as_advanced( TBB_MALLOC_LIBRARY_DEBUG )
mark_as_advanced( TBB_ROOT )
message ( STATUS "TBB_ROOT: "${TBB_ROOT} )
include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( TBB DEFAULT_MSG TBB_LIBRARY TBB_MALLOC_LIBRARY TBB_LIBRARY_DEBUG TBB_MALLOC_LIBRARY_DEBUG TBB_INCLUDE_DIRS TBB_ROOT)
if( NOT TBB_FOUND )
message( STATUS "FindTBB looked for libraries named tbb but could not find" )
endif()
endif ( )