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