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