9f33b387 |
1 | # tbb |
2 | |
3 | OCCT_MAKE_BUILD_POSTFIX() |
4 | |
5 | if (NOT DEFINED INSTALL_TBB) |
6 | set (INSTALL_TBB OFF CACHE BOOL "Is tbb required to be copied into install directory") |
7 | endif() |
8 | |
9 | # tbb directory |
10 | if (NOT DEFINED 3RDPARTY_TBB_DIR) |
11 | set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing tbb") |
12 | endif() |
13 | |
14 | # tbb include directory |
15 | if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR) |
16 | set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of the tbb") |
17 | endif() |
18 | |
19 | # tbb library file (with absolute path) |
20 | if (NOT DEFINED 3RDPARTY_TBB_LIBRARY OR NOT 3RDPARTY_TBB_LIBRARY_DIR) |
21 | set (3RDPARTY_TBB_LIBRARY "" CACHE FILEPATH "tbb library" FORCE) |
22 | endif() |
23 | |
24 | # tbb library directory |
25 | if (NOT DEFINED 3RDPARTY_TBB_LIBRARY_DIR) |
26 | set (3RDPARTY_TBB_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tbb library") |
27 | endif() |
28 | |
29 | # tbb malloc library file (with absolute path) |
30 | if (NOT DEFINED 3RDPARTY_TBBMALLOC_LIBRARY OR NOT 3RDPARTY_TBBMALLOC_LIBRARY_DIR) |
31 | set (3RDPARTY_TBBMALLOC_LIBRARY "" CACHE FILEPATH "tbb malloc library" FORCE) |
32 | endif() |
33 | |
34 | # tbb malloc library directory |
35 | if (NOT DEFINED 3RDPARTY_TBBMALLOC_LIBRARY_DIR) |
36 | set (3RDPARTY_TBBMALLOC_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tbb malloc library") |
37 | endif() |
38 | |
39 | # tbb shared library (with absolute path) |
40 | if (WIN32) |
41 | if (NOT DEFINED 3RDPARTY_TBB_DLL OR NOT 3RDPARTY_TBB_DLL_DIR) |
42 | set (3RDPARTY_TBB_DLL "" CACHE FILEPATH "tbb shared library" FORCE) |
43 | endif() |
44 | endif() |
45 | |
46 | # tbb shared library directory |
47 | if (WIN32 AND NOT DEFINED 3RDPARTY_TBB_DLL_DIR) |
48 | set (3RDPARTY_TBB_DLL_DIR "" CACHE FILEPATH "The directory containing tbb shared library") |
49 | endif() |
50 | |
51 | # tbb malloc shared library (with absolute path) |
52 | if (WIN32) |
53 | if (NOT DEFINED 3RDPARTY_TBBMALLOC_DLL OR NOT 3RDPARTY_TBBMALLOC_DLL_DIR) |
54 | set (3RDPARTY_TBBMALLOC_DLL "" CACHE FILEPATH "tbb malloc shared library" FORCE) |
55 | endif() |
56 | endif() |
57 | |
58 | # tbb malloc shared library directory |
19286d7c |
59 | if (WIN32 AND NOT DEFINED 3RDPARTY_TBBMALLOC_DLL_DIR) |
9f33b387 |
60 | set (3RDPARTY_TBBMALLOC_DLL_DIR "" CACHE FILEPATH "The directory containing tbb malloc shared library") |
61 | endif() |
62 | |
63 | # include occt macros. compiler_bitness, os_wiht_bit, compiler and build_postfix |
19286d7c |
64 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") |
9f33b387 |
65 | |
66 | # search for product directory inside 3RDPARTY_DIR directory |
67 | if (NOT 3RDPARTY_TBB_DIR AND 3RDPARTY_DIR) |
68 | FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" "TBB" TBB_DIR_NAME) |
69 | if (TBB_DIR_NAME) |
70 | message (STATUS "Info: TBB: ${TBB_DIR_NAME} folder is used") |
71 | set (3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${TBB_DIR_NAME}" CACHE PATH "The directory containing tbb" FORCE) |
72 | endif() |
73 | endif() |
74 | |
75 | OCCT_MAKE_COMPILER_BITNESS() |
76 | |
77 | if (${COMPILER_BITNESS} STREQUAL 32) |
78 | set (TBB_ARCH_NAME ia32) |
79 | else() |
80 | set (TBB_ARCH_NAME intel64) |
81 | endif() |
82 | |
83 | # search for include directory in defined 3rdparty directory |
84 | if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}") |
85 | set (3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "The directory containing the headers of tbb" FORCE) |
19286d7c |
86 | find_path (3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include" NO_DEFAULT_PATH) |
9f33b387 |
87 | find_path (3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include") |
88 | endif() |
89 | |
90 | if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}") |
91 | set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE FILEPATH "The directory containing the headers of tbb" FORCE) |
92 | endif() |
93 | |
94 | OCCT_MAKE_COMPILER_SHORT_NAME() |
95 | |
96 | # TBB_COMPILER_FOLER |
97 | #if (WIN32) |
98 | set (TBB_COMPILER_FOLER ${COMPILER}) |
99 | #else() |
100 | # set (TBB_COMPILER_FOLER ${COMPILER}) |
101 | #endif() |
102 | |
103 | OCCT_MAKE_BUILD_POSTFIX() |
104 | |
105 | # search for tbb and tbb malloc library in defined 3rdparty directory |
106 | foreach (LIBRARY_NAME TBB TBBMALLOC) |
19286d7c |
107 | if (NOT WIN32) |
108 | file (GLOB TBB_SUBDIRS RELATIVE ${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/ ${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/*) |
109 | list (SORT TBB_SUBDIRS) |
110 | list (REVERSE TBB_SUBDIRS) |
111 | list (LENGTH TBB_SUBDIRS TBB_SUBDIRS_LENGTH) |
112 | set (TBB_SUBDIR_FIRST "") |
113 | if (${TBB_SUBDIRS_LENGTH}) |
114 | list (GET TBB_SUBDIRS 0 TBB_SUBDIR_FIRST) |
115 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_SUBDIR_FIRST}") |
116 | endif() |
117 | endif() |
9f33b387 |
118 | if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR) |
119 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "${LIBRARY_NAME} library" FORCE) |
120 | elseif (3RDPARTY_${LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}") |
121 | get_filename_component(3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR_TMP "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}" PATH) |
122 | if (NOT "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" STREQUAL "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR_TMP}") |
123 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "${LIBRARY_NAME} library" FORCE) |
124 | endif() |
125 | endif() |
126 | |
127 | if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}") |
128 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "3RDPARTY_${LIBRARY_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of ${LIBRARY_NAME}" FORCE) |
129 | |
130 | # first of all, search for debug version of a library if build type is debug |
131 | if (DEFINED IS_BUILD_DEBUG) |
132 | find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}_debug |
133 | PATHS |
134 | "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" |
135 | "${3RDPARTY_TBB_DIR}/libd/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
136 | "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
137 | NO_DEFAULT_PATH) |
138 | |
139 | # second search if previous one do not find anything |
140 | find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}_debug) |
141 | endif() |
142 | |
143 | # if build type is release or debug version of library isn't found - search for release version of one |
144 | if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}") |
145 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "3RDPARTY_${LIBRARY_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of ${LIBRARY_NAME}" FORCE) |
146 | |
147 | if (DEFINED IS_BUILD_DEBUG) |
148 | message (STATUS "Warning: debug version of ${LIBRARY_NAME} library isn't found (${LIBRARY_NAME}_debug) in ${3RDPARTY_TBB_DIR}/lib(d). Search for release one") |
149 | endif() |
150 | |
19286d7c |
151 | string (TOLOWER "${LIBRARY_NAME}" lower_LIBRARY_NAME) |
152 | find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${lower_LIBRARY_NAME} |
9f33b387 |
153 | PATHS |
154 | "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" |
155 | "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
156 | NO_DEFAULT_PATH) |
157 | |
158 | # second search if previous one do not find anything |
159 | find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}) |
160 | endif() |
161 | endif() |
162 | |
163 | if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}") |
164 | get_filename_component(3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}" PATH) |
9f33b387 |
165 | endif() |
19286d7c |
166 | set (3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${LIBRARY_NAME} library" FORCE) |
9f33b387 |
167 | |
168 | # search for dll in defined 3rdparty directory (just for win case) |
169 | if (WIN32) |
170 | set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") |
19286d7c |
171 | |
9f33b387 |
172 | if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL_DIR) |
173 | set (3RDPARTY_${LIBRARY_NAME}_DLL "" CACHE FILEPATH "${LIBRARY_NAME} shared library" FORCE) |
174 | elseif (3RDPARTY_${LIBRARY_NAME}_DLL AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}") |
175 | get_filename_component(3RDPARTY_${LIBRARY_NAME}_DLL_DIR_TMP "${3RDPARTY_${LIBRARY_NAME}_DLL}" PATH) |
176 | if (NOT "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" STREQUAL "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR_TMP}") |
177 | set (3RDPARTY_${LIBRARY_NAME}_DLL "" CACHE FILEPATH "${LIBRARY_NAME} shared library" FORCE) |
178 | endif() |
179 | endif() |
180 | |
181 | if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}") |
182 | set (3RDPARTY_${LIBRARY_NAME}_DLL "3RDPARTY_${LIBRARY_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of ${LIBRARY_NAME}" FORCE) |
183 | |
184 | if (DEFINED IS_BUILD_DEBUG) |
185 | find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME}_debug |
186 | PATHS |
187 | "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" |
188 | "${3RDPARTY_TBB_DIR}/bind/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
189 | "${3RDPARTY_TBB_DIR}/bin/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
190 | NO_DEFAULT_PATH) |
191 | |
192 | # second search if previous one do not find anything |
193 | find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME}_debug) |
194 | endif() |
195 | |
196 | if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}") |
197 | set (3RDPARTY_${LIBRARY_NAME}_DLL "3RDPARTY_${LIBRARY_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of ${LIBRARY_NAME}" FORCE) |
198 | |
199 | if (DEFINED IS_BUILD_DEBUG) |
200 | message (STATUS "Warning: debug version of ${LIBRARY_NAME} dll isn't found (${LIBRARY_NAME}_debug) in ${3RDPARTY_TBB_DIR}/bin(d). Search for release one") |
201 | endif() |
202 | |
203 | find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME} |
204 | PATHS |
205 | "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" |
206 | "${3RDPARTY_TBB_DIR}/bin/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}" |
207 | NO_DEFAULT_PATH) |
208 | |
209 | # second search if previous one do not find anything |
210 | find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME}) |
211 | endif() |
212 | endif() |
19286d7c |
213 | |
9f33b387 |
214 | if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL_DIR OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}") |
215 | get_filename_component(3RDPARTY_${LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${LIBRARY_NAME}_DLL}" PATH) |
216 | set (3RDPARTY_${LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" CACHE FILEPATH "The directory containing ${LIBRARY_NAME} shared library" FORCE) |
217 | endif() |
218 | endif() # end dll search |
219 | endforeach() # end tbb / tbbmalloc |
220 | |
221 | # include found paths to common variables |
222 | if (3RDPARTY_TBB_INCLUDE_DIR AND EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}") |
223 | list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}") |
224 | else() |
225 | list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR) |
226 | endif() |
227 | |
228 | foreach (LIBRARY_NAME TBB TBBMALLOC) |
229 | if (3RDPARTY_${LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}") |
230 | list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}") |
231 | else() |
232 | list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR) |
233 | endif() |
234 | |
235 | if (WIN32) |
94829f84 |
236 | if (3RDPARTY_${LIBRARY_NAME}_DLL OR EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}") |
237 | list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}") |
238 | else() |
9f33b387 |
239 | list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_DLL_DIR) |
240 | endif() |
241 | endif() |
242 | endforeach() |
243 | |
244 | # install tbb |
245 | if (INSTALL_TBB) |
246 | OCCT_MAKE_OS_WITH_BITNESS() |
247 | OCCT_MAKE_COMPILER_SHORT_NAME() |
248 | |
249 | if (WIN32) |
250 | install (FILES ${3RDPARTY_TBB_DLL} ${3RDPARTY_TBBMALLOC_DLL} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}") |
251 | else() |
19286d7c |
252 | get_filename_component(TBBLIB ${3RDPARTY_TBB_LIBRARY} NAME) |
253 | get_filename_component(TBBMALLOCLIB ${3RDPARTY_TBBMALLOC_LIBRARY} NAME) |
254 | install (FILES ${3RDPARTY_TBB_LIBRARY}.2 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}" RENAME ${TBBLIB}.2) |
255 | install (FILES ${3RDPARTY_TBBMALLOC_LIBRARY}.2 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}" RENAME ${TBBMALLOCLIB}.2) |
9f33b387 |
256 | endif() |
0a66e59d |
257 | |
258 | set (USED_3RDPARTY_TBB_DIR "") |
259 | else() |
260 | # the library directory for using by the executable |
261 | if (WIN32) |
262 | set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR}) |
263 | else() |
264 | set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR}) |
265 | endif() |
9f33b387 |
266 | endif() |
267 | |
268 | mark_as_advanced (3RDPARTY_TBB_LIBRARY 3RDPARTY_TBBMALLOC_LIBRARY 3RDPARTY_TBB_DLL 3RDPARTY_TBBMALLOC_DLL) |