Setting Warning Level for Windows (MSVC) to /W4 and Linux -Wall
[occt.git] / CMakeLists.txt
1 cmake_minimum_required ( VERSION 2.6)
2
3 if (NOT BUILD_TYPE)
4   set(BUILD_TYPE "Release" CACHE STRING "Build type of the OCCT" FORCE)
5   SET_PROPERTY(CACHE BUILD_TYPE PROPERTY STRINGS Release Debug)
6 endif()
7
8 set(CMAKE_CONFIGURATION_TYPES ${BUILD_TYPE} CACHE INTERNAL "" FORCE)
9
10 project(OCCT)
11
12 set_property(GLOBAL PROPERTY 3RDPARTY_USE_FOLDERS ON)
13
14 set(BUILD_SHARED_LIBS ON)
15
16 IF("${BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE}" AND "${BUILD_BITNESS}" STREQUAL "${BUILD_BITNESS1}")
17   SET(CHANGES_ARE_NEEDED OFF)
18 ELSE()
19   SET(CHANGES_ARE_NEEDED ON)
20 ENDIF()
21
22 set(BUILD_BITNESS 32 CACHE STRING "Bitness of the OCCT project")
23 SET_PROPERTY(CACHE BUILD_BITNESS PROPERTY STRINGS 32 64)
24
25 SET(BUILD_BITNESS1 ${BUILD_BITNESS} CACHE INTERNAL "Temporary bitness is created to check whether change 3rdparty paths or not" FORCE)
26
27 SET( CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE INTERNAL "Build type of the OCCT" FORCE )
28
29 SET( INSTALL_DIR "" CACHE PATH "Directory contains install files of the OCCT" )
30 SET( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
31
32 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are included in OCCT")
33 separate_arguments(BUILD_TOOLKITS)
34
35 include(adm/cmake/CMakeModules.txt)
36
37 if (WIN32)
38   set(SCRIPT_EXT bat)
39 else()
40   set(SCRIPT_EXT sh)
41 endif()
42
43 if (DEFINED MSVC70)
44   SET(COMPILER vc7)
45 elseif (DEFINED MSVC80)
46   SET(COMPILER vc8)
47 elseif (DEFINED MSVC90)
48   SET(COMPILER vc9)
49 elseif (DEFINED MSVC10)
50   SET(COMPILER vc10)
51 elseif (DEFINED MSVC11)
52   SET(COMPILER vc11)
53 else()
54   SET(COMPILER ${CMAKE_GENERATOR})
55 endif()
56
57 if (${BUILD_BITNESS} STREQUAL 64)
58   add_definitions(-D_OCC64)
59 endif()
60
61 add_definitions(-DCSFDB)
62 if(WIN32)
63   add_definitions(/DWNT -wd4996)
64 elseif(APPLE)
65   add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
66 else()
67   add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
68 endif()
69
70 string(REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
71 IF(ISFLAG)
72   STRING(REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
73 ELSEIF(WIN32)
74   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
75 ENDIF()
76
77 IF(WIN32)
78   IF(NOT DEFINED MSVC70 AND NOT DEFINED MSVC80)
79     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
80   ENDIF()
81 ENDIF()
82
83 # set warning level 4
84 IF(MSVC)
85   if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
86     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
87   else()
88     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
89   endif()
90 elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
91   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
92 endif()
93
94 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
95 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
96
97 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
98 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
99
100 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
101 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
102 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)
103
104 # RESOURCES
105 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/DrawResources" DESTINATION  "${INSTALL_DIR}/src" )
106 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/StdResource" DESTINATION  "${INSTALL_DIR}/src" )
107 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/SHMessage" DESTINATION  "${INSTALL_DIR}/src" )
108 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Textures" DESTINATION  "${INSTALL_DIR}/src" )
109 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSMessage" DESTINATION  "${INSTALL_DIR}/src" )
110 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/TObj" DESTINATION  "${INSTALL_DIR}/src" )
111 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSTEPResource" DESTINATION  "${INSTALL_DIR}/src" )
112 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XmlOcafResource" DESTINATION  "${INSTALL_DIR}/src" )
113
114 install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Lexi_Expr.dat" DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
115 install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Units.dat"     DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
116
117 IF("${BUILD_TYPE}" STREQUAL "Release") 
118   SET(BUILD_SUFFIX "")
119 ELSE()
120   SET(BUILD_SUFFIX "") # debug == release
121 ENDIF()
122
123 FUNCTION(SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
124   file(GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
125   
126   foreach(ITEM ${SUB_ITEMS})
127     if(IS_DIRECTORY "${ITEM}")
128       GET_FILENAME_COMPONENT(ITEM_NAME "${ITEM}" NAME)
129       LIST(APPEND LOCAL_RESULT "${ITEM_NAME}")
130     endif()
131   endforeach()
132   set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
133 ENDFUNCTION()
134
135 FUNCTION(FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
136   string( TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME )
137   
138   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${BUILD_BITNESS}")
139   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${BUILD_BITNESS}")
140   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${BUILD_BITNESS}")
141   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
142   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
143   
144   SUBDIRECTORY_NAMES( "${ROOT_DIR}" SUBDIR_NAME_LIST)
145   
146   FOREACH( SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
147     IF(LOCAL_RESULT)
148       BREAK()
149     ENDIF()
150     
151     FOREACH(SUBDIR_NAME ${SUBDIR_NAME_LIST})
152       string( TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME )
153       
154       STRING(REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
155       IF(DUMMY_VAR)
156         LIST(APPEND LOCAL_RESULT ${SUBDIR_NAME})
157       ENDIF()
158     ENDFOREACH()
159   ENDFOREACH()
160   
161   IF(LOCAL_RESULT)
162     LIST(LENGTH "${LOCAL_RESULT}" LOC_LEN)
163     MATH(EXPR LAST_ELEMENT_INDEX "${LOC_LEN}-1")
164     LIST(GET LOCAL_RESULT ${LAST_ELEMENT_INDEX} DUMMY)
165     SET(${RESULT} ${DUMMY} PARENT_SCOPE)
166   ENDIF()  
167 ENDFUNCTION()
168
169 IF(WIN32)
170   SET(DLL_SO "dll")
171   SET(DLL_SO_FOLDER "bin")
172   SET(DLL_SO_PREFIX "")
173 ELSEIF(APPLE)
174   SET(DLL_SO "dylib")
175   SET(DLL_SO_FOLDER "lib")
176   SET(DLL_SO_PREFIX "lib")
177 ELSE()
178   SET(DLL_SO "so")
179   SET(DLL_SO_FOLDER "lib")
180   SET(DLL_SO_PREFIX "lib")
181 ENDIF()
182
183 SET(3RDPARTY_DIR "" CACHE PATH "Directory contains required 3rdparty products")
184 SET(3RDPARTY_INCLUDE_DIRS "")
185 SET(3RDPARTY_NOT_INCLUDED)
186
187 IF(APPLE)
188   SET(3RDPARTY_USE_GLX OFF CACHE BOOL "whether use X11 OpenGL on OSX or not")
189 ENDIF()
190
191 SET(3RDPARTY_USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
192 SET(3RDPARTY_USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
193 SET(3RDPARTY_USE_TBB OFF CACHE BOOL "whether use tbb product or not")
194
195 SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
196
197 MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
198   IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
199     SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
200   ENDIF()
201   
202   IF(3RDPARTY_DIR AND ("${3RDPARTY_${PRODUCT_NAME}_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
203     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
204     IF("${${PRODUCT_NAME}_DIR_NAME}" STREQUAL "")
205       MESSAGE(STATUS "${PRODUCT_NAME} DON'T FIND")
206     ELSE()
207       SET(3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "Directory contains ${PRODUCT_NAME} product" FORCE)
208     ENDIF()
209   ENDIF()
210   
211   SET(INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} lib copy to install directory")
212
213   IF(3RDPARTY_${PRODUCT_NAME}_DIR)
214     IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
215       SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
216       FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
217       
218       IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
219         FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME})
220       ENDIF()
221       
222     ENDIF()
223     
224     IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
225       SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
226       FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME}  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
227       
228       # check default path for library search
229       IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
230         FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME})
231       ENDIF()
232     ENDIF()
233     
234     IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
235       SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
236       FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}"  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
237       
238       IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
239         FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}")
240       ENDIF()
241     ENDIF()
242     MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
243   ENDIF()
244
245   IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
246     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
247   ELSE()
248     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
249   ENDIF()
250
251   IF(3RDPARTY_${PRODUCT_NAME}_LIBRARY)
252     GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
253     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
254   ELSE()
255     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY)
256   ENDIF()
257   
258   IF(3RDPARTY_${PRODUCT_NAME}_DLL)
259     #
260   ELSE()
261     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL)
262   ENDIF()
263
264   IF(INSTALL_${PRODUCT_NAME})
265     INSTALL(FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
266     SET(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "")
267   ELSE()
268     GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
269   ENDIF()
270 ENDMACRO()
271
272 # TCL
273
274 #tcl85 - win; tcl8.5 - lin
275 IF(WIN32)
276   SET(TCL_SEP "")
277 ELSE()
278   SET(TCL_SEP ".")
279 ENDIF()
280   
281 THIRDPARTY_PRODUCT("TCL" "tcl.h" "tcl8${TCL_SEP}5")
282
283 #install tk and libs
284 IF(INSTALL_TCL)
285   GET_FILENAME_COMPONENT(3RDPARTY_TK_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
286   GET_FILENAME_COMPONENT(3RDPARTY_TK_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
287   
288   INSTALL(FILES "${3RDPARTY_TK_DLL_DIR}/${DLL_SO_PREFIX}tk8${TCL_SEP}5.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
289   INSTALL(DIRECTORY "${3RDPARTY_TK_LIB_DIR}/tcl8.5" DESTINATION "${INSTALL_DIR}/lib")
290   INSTALL(DIRECTORY "${3RDPARTY_TK_LIB_DIR}/tk8.5" DESTINATION "${INSTALL_DIR}/lib")
291 ENDIF()
292
293 # GLX
294 IF(3RDPARTY_USE_GLX)
295   ADD_DEFINITIONS(-DMACOSX_USE_GLX)
296   
297   IF(NOT DEFINED 3RDPARTY_GLX_DIR)
298     SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
299   ENDIF()
300   
301   IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
302     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
303     IF("${GLX_DIR_NAME}" STREQUAL "")
304       MESSAGE(STATUS "GLX DON'T FIND")
305     ELSE()
306       SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
307     ENDIF()
308   ENDIF()
309   
310   IF(3RDPARTY_GLX_DIR)
311     SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
312     SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib"     CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
313     
314     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
315     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
316     
317     MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
318   ELSE()
319     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
320     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
321   ENDIF()
322 ENDIF()
323
324 # FREETYPE
325 THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${BUILD_SUFFIX}")
326
327 IF("${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
328   
329 ELSEIF(EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2/")
330   SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2")
331 ENDIF()
332
333 # FREEIMAGE
334 IF(3RDPARTY_USE_FREEIMAGE)
335   ADD_DEFINITIONS(-DHAVE_FREEIMAGE) 
336
337   THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${BUILD_SUFFIX}")
338   IF(WIN32)
339     IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
340     ELSE()
341       SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
342     ENDIF()
343     
344     THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${BUILD_SUFFIX}")
345     
346   ENDIF()
347 ENDIF()
348
349 # GL2PS
350 IF(3RDPARTY_USE_GL2PS)
351   ADD_DEFINITIONS(-DHAVE_GL2PS)
352   THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
353 ENDIF()
354
355 # TBB
356 IF (3RDPARTY_USE_TBB)
357   ADD_DEFINITIONS(-DHAVE_TBB)
358
359   IF(${BUILD_BITNESS} STREQUAL 32)
360     SET (TBB_ARCH_NAME ia32)
361   ELSE()
362     SET (TBB_ARCH_NAME intel64)
363   ENDIF()
364   
365   IF(NOT DEFINED 3RDPARTY_TBB_DIR)
366     SET(3RDPARTY_TBB_DIR "" CACHE PATH "Directory contains tbb product")
367   ENDIF()
368   
369   SET(3RDPARTY_TBB_DIR_NAME "")
370   IF(3RDPARTY_DIR AND ("${3RDPARTY_TBB_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
371     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" "TBB" 3RDPARTY_TBB_DIR_NAME)
372     IF("${3RDPARTY_TBB_DIR_NAME}" STREQUAL "")
373       MESSAGE(STATUS "TBB DON'T FIND")
374     ELSE()
375       SET(3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${3RDPARTY_TBB_DIR_NAME}" CACHE PATH "Directory contains tbb product" FORCE)
376     ENDIF()
377   ENDIF()
378   
379   SET(INSTALL_TBB OFF CACHE BOOL "Is tbb lib copy to install directory")
380
381   IF(3RDPARTY_TBB_DIR)
382     IF("${3RDPARTY_TBB_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED)
383       SET(3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE PATH "Directory contains headers of the tbb product" FORCE)
384       FIND_PATH(3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include")
385     ENDIF()
386
387     SET(TBB_DEBUG_POSTFIX "")
388     if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
389       SET(TBB_DEBUG_POSTFIX "") # _debug postfix removed
390     ENDIF()
391     
392     IF("${3RDPARTY_TBB_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TBB_LIBRARY}" STREQUAL "3RDPARTY_TBB_LIBRARY-NOTFOUND")
393       SET(3RDPARTY_TBB_LIBRARY "3RDPARTY_TBB_LIBRARY-NOTFOUND" CACHE PATH "Directory contains library of the tbb product" FORCE)
394       FIND_LIBRARY(3RDPARTY_TBB_LIBRARY tbb${TBB_DEBUG_POSTFIX} PATHS "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
395       
396       IF("${3RDPARTY_TBB_LIBRARY}" STREQUAL "3RDPARTY_TBB_LIBRARY-NOTFOUND")
397         FIND_LIBRARY(3RDPARTY_TBB_LIBRARY tbb${TBB_DEBUG_POSTFIX})
398       ENDIF()
399     ENDIF()
400
401     IF("${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND")
402       SET(3RDPARTY_TBB_MALLOC_LIBRARY "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND" CACHE PATH "Directory contains library of the tbb malloc product" FORCE)
403       FIND_LIBRARY(3RDPARTY_TBB_MALLOC_LIBRARY tbbmalloc${TBB_DEBUG_POSTFIX} PATHS "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
404       
405       IF("${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND")
406         FIND_LIBRARY(3RDPARTY_TBB_MALLOC_LIBRARY tbbmalloc${TBB_DEBUG_POSTFIX})
407       ENDIF()
408     ENDIF()
409     
410     
411     
412     IF("${3RDPARTY_TBB_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED)
413       SET(3RDPARTY_TBB_DLL "3RDPARTY_TBB_DLL-NOTFOUND" CACHE PATH "Directory contains shared library of the tbb product" FORCE)
414       FIND_FILE(3RDPARTY_TBB_DLL "${DLL_SO_PREFIX}tbb${TBB_DEBUG_POSTFIX}.${DLL_SO}" PATHS "${3RDPARTY_TBB_DIR}/${DLL_SO_FOLDER}/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
415       
416       IF("${3RDPARTY_TBB_DLL}" STREQUAL "3RDPARTY_TBB_DLL-NOTFOUND")
417         FIND_FILE(3RDPARTY_TBB_DLL "${DLL_SO_PREFIX}tbb${TBB_DEBUG_POSTFIX}.${DLL_SO}")
418       ENDIF()
419     ENDIF()
420     
421     IF("${3RDPARTY_TBB_MALLOC_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED)
422       SET(3RDPARTY_TBB_MALLOC_DLL "3RDPARTY_TBB_MALLOC_DLL-NOTFOUND" CACHE PATH "Directory contains shared library of the tbb malloc product" FORCE)
423       FIND_FILE(3RDPARTY_TBB_MALLOC_DLL "${DLL_SO_PREFIX}tbbmalloc${TBB_DEBUG_POSTFIX}.${DLL_SO}" PATHS "${3RDPARTY_TBB_DIR}/${DLL_SO_FOLDER}/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
424       
425       IF("${3RDPARTY_TBB_MALLOC_DLL}" STREQUAL "3RDPARTY_TBB_MALLOC_DLL-NOTFOUND")
426         FIND_FILE(3RDPARTY_TBB_MALLOC_DLL "${DLL_SO_PREFIX}tbbmalloc${TBB_DEBUG_POSTFIX}.${DLL_SO}")
427       ENDIF()
428     ENDIF()
429
430     MARK_AS_ADVANCED(3RDPARTY_TBB_DIR_NAME)
431   ELSE()
432     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_DIR)
433   ENDIF()
434
435   IF(3RDPARTY_TBB_INCLUDE_DIR)
436     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_TBB_INCLUDE_DIR}")
437   ELSE()
438     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR)
439   ENDIF()
440
441   IF(3RDPARTY_TBB_LIBRARY)
442     GET_FILENAME_COMPONENT(3RDPARTY_TBB_LIBRARY_DIR "${3RDPARTY_TBB_LIBRARY}" PATH)
443     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_TBB_LIBRARY_DIR}")
444   ELSE()
445     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_LIBRARY)
446   ENDIF()
447   
448   IF(3RDPARTY_TBB_MALLOC_LIBRARY)
449     GET_FILENAME_COMPONENT(3RDPARTY_TBB_LIBRARY_DIR "${3RDPARTY_TBB_MALLOC_LIBRARY}" PATH)
450     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_TBB_LIBRARY_DIR}")
451   ELSE()
452     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_MALLOC_LIBRARY)
453   ENDIF()
454   
455   IF(3RDPARTY_TBB_DLL)
456     #
457   ELSE()
458     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_DLL)
459   ENDIF()
460   
461   IF(3RDPARTY_TBB_MALLOC_DLL)
462     #
463   ELSE()
464     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_MALLOC_DLL)
465   ENDIF()
466
467   IF(INSTALL_TBB)
468     INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
469
470     SET(3RDPARTY_TBB_DLL_DIR "")
471     SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
472   ELSE()
473     GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
474     GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
475   ENDIF()
476 ENDIF()
477
478 string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
479
480 #CHECK ALL 3RDPARTY PATHS
481 IF(3RDPARTY_NOT_INCLUDED)
482   MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
483 ENDIF()
484
485 list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
486 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
487 MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
488 include_directories( ${3RDPARTY_INCLUDE_DIRS} )
489
490 list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
491 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
492 MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
493 link_directories( ${3RDPARTY_LIBRARY_DIRS} )
494
495 #
496 SET(RUN_PROJECT "")
497 SET(CASROOT_DEFINITION "set \"CASROOT=${CMAKE_SOURCE_DIR}\"")
498 SET(BIN_DIR_POSTFIX "bin")
499 SET(RESOURCE_DIR_PREFIX "%SCRIPTROOT%\\src")
500
501 IF("${INSTALL_DIR}" STREQUAL "")
502   MESSAGE(FATAL_ERROR "INSTALL_DIR is empty")
503 ELSE()
504   # inc,data,tests DIRECTORY
505   install(DIRECTORY "${CMAKE_SOURCE_DIR}/inc"   DESTINATION  "${INSTALL_DIR}" )
506   install(DIRECTORY "${CMAKE_SOURCE_DIR}/data"  DESTINATION  "${INSTALL_DIR}" )
507   IF(INSTALL_TESTS)
508     install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
509   ENDIF()
510
511   # DRAW.BAT or DRAW.SH
512   install(FILES "${CMAKE_SOURCE_DIR}/adm/cmake/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS  OWNER_READ OWNER_WRITE OWNER_EXECUTE 
513                                                                               GROUP_READ GROUP_WRITE GROUP_EXECUTE 
514                                                                               WORLD_READ WORLD_WRITE WORLD_EXECUTE)
515
516   configure_file("${CMAKE_SOURCE_DIR}/adm/cmake/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
517   install(FILES "${OCCT_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" )
518 ENDIF()
519
520 IF(MSVC AND "${BUILD_TYPE}" STREQUAL "Debug")
521   SET(RUN_PROJECT "start OCCT.sln")
522   SET(BIN_DIR_POSTFIX "out\\bin\\Debug")
523   SET(RESOURCE_DIR_PREFIX "%CASROOT%\\src")
524   configure_file("${CMAKE_SOURCE_DIR}/adm/cmake/env.bat.in" OCCT.bat @ONLY)
525 ENDIF()
526
527 include(adm/cmake/CMakeToolKitsDeps.txt)