0024459: Exception during clearing object in test case v3d/raytrace/connected in...
[occt.git] / CMakeLists.txt
1 cmake_minimum_required ( VERSION 2.6)
2
3 if (NOT BUILD_CONFIGURATION)
4   set(BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
5   SET_PROPERTY(CACHE BUILD_CONFIGURATION PROPERTY STRINGS Release Debug RelWithDebInfo)
6 endif()
7
8 set(CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
9
10 project(OCCT)
11
12 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
13
14 set(BUILD_SHARED_LIBS ON)
15
16 IF("${BUILD_CONFIGURATION}" 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_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
25
26 SET( INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
27 SET( CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
28
29 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
30 separate_arguments(BUILD_TOOLKITS)
31
32 IF(MSVC)
33   SET(BUILD_Samples OFF CACHE BOOL "OCCT samples building")
34 ENDIF()
35
36 include(adm/cmake/CMakeModules.txt)
37
38 if (WIN32)
39   set(SCRIPT_EXT bat)
40 else()
41   set(SCRIPT_EXT sh)
42 endif()
43
44 if (MSVC)
45   add_definitions(/fp:precise)
46 endif()
47
48 # set compiler short name and choose SSE2 option for appropriate MSVC compilers
49 if (DEFINED MSVC70)
50   SET(COMPILER vc7)
51 elseif (DEFINED MSVC80)
52   SET(COMPILER vc8)
53   if (${COMPILER_BITNESS} STREQUAL 32)
54     add_definitions(/arch:SSE2)
55   endif()
56 elseif (DEFINED MSVC90)
57   SET(COMPILER vc9)
58   if (${COMPILER_BITNESS} STREQUAL 32)
59     add_definitions(/arch:SSE2)
60   endif()
61 elseif (DEFINED MSVC10)
62   SET(COMPILER vc10)
63   if (${COMPILER_BITNESS} STREQUAL 32)
64     add_definitions(/arch:SSE2)
65   endif()
66 elseif (DEFINED MSVC11)
67   SET(COMPILER vc11)
68 else()
69   SET(COMPILER ${CMAKE_GENERATOR})
70 endif()
71
72 if (${COMPILER_BITNESS} STREQUAL 64)
73   add_definitions(-D_OCC64)
74 endif()
75
76 add_definitions(-DCSFDB)
77 if(WIN32)
78   add_definitions(/DWNT -wd4996)
79 elseif(APPLE)
80   add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
81 else()
82   add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
83 endif()
84
85 # enable structured exceptions for MSVC
86 string(REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
87 IF(ISFLAG)
88   STRING(REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
89 ELSEIF(WIN32)
90   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
91 ENDIF()
92
93 # enable parallel compilation on MSVC 9 and above
94 IF(WIN32)
95   IF(NOT DEFINED MSVC70 AND NOT DEFINED MSVC80)
96     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
97   ENDIF()
98 ENDIF()
99
100 # increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
101 IF(MSVC)
102   if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
103     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
104   else()
105     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
106   endif()
107 elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
108   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
109 endif()
110
111 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
112 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
113
114 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
115 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
116
117 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
118 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
119 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)
120
121 # RESOURCES
122 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/DrawResources" DESTINATION  "${INSTALL_DIR}/src" )
123 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/StdResource" DESTINATION  "${INSTALL_DIR}/src" )
124 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/SHMessage" DESTINATION  "${INSTALL_DIR}/src" )
125 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Textures" DESTINATION  "${INSTALL_DIR}/src" )
126 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Shaders" DESTINATION  "${INSTALL_DIR}/src" )
127 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSMessage" DESTINATION  "${INSTALL_DIR}/src" )
128 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSTEPResource" DESTINATION  "${INSTALL_DIR}/src" )
129 install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XmlOcafResource" DESTINATION  "${INSTALL_DIR}/src" )
130
131 install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Lexi_Expr.dat" DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
132 install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Units.dat"     DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
133 install(FILES "${CMAKE_SOURCE_DIR}/src/TObj/TObj.msg" DESTINATION  "${INSTALL_DIR}/src/TObj" )
134
135 IF("${BUILD_CONFIGURATION}" STREQUAL "Release") 
136   SET(BUILD_SUFFIX "")
137 ELSE()
138   SET(BUILD_SUFFIX "") # debug == release
139 ENDIF()
140
141 FUNCTION(SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
142   file(GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
143
144   foreach(ITEM ${SUB_ITEMS})
145     if(IS_DIRECTORY "${ITEM}")
146       GET_FILENAME_COMPONENT(ITEM_NAME "${ITEM}" NAME)
147       LIST(APPEND LOCAL_RESULT "${ITEM_NAME}")
148     endif()
149   endforeach()
150   set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
151 ENDFUNCTION()
152
153 FUNCTION(FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
154   string( TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME )
155
156   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${COMPILER_BITNESS}")
157   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}")
158   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER_BITNESS}")
159   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
160   LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
161
162   SUBDIRECTORY_NAMES( "${ROOT_DIR}" SUBDIR_NAME_LIST)
163
164   FOREACH( SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
165     IF(LOCAL_RESULT)
166       BREAK()
167     ENDIF()
168
169     FOREACH(SUBDIR_NAME ${SUBDIR_NAME_LIST})
170       string( TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME )
171
172       STRING(REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
173       IF(DUMMY_VAR)
174         LIST(APPEND LOCAL_RESULT ${SUBDIR_NAME})
175       ENDIF()
176     ENDFOREACH()
177   ENDFOREACH()
178
179   IF(LOCAL_RESULT)
180     LIST(LENGTH "${LOCAL_RESULT}" LOC_LEN)
181     MATH(EXPR LAST_ELEMENT_INDEX "${LOC_LEN}-1")
182     LIST(GET LOCAL_RESULT ${LAST_ELEMENT_INDEX} DUMMY)
183     SET(${RESULT} ${DUMMY} PARENT_SCOPE)
184   ENDIF()
185 ENDFUNCTION()
186
187 IF(WIN32)
188   SET(DLL_SO "dll")
189   SET(DLL_SO_FOLDER "bin")
190   SET(DLL_SO_PREFIX "")
191 ELSEIF(APPLE)
192   SET(DLL_SO "dylib")
193   SET(DLL_SO_FOLDER "lib")
194   SET(DLL_SO_PREFIX "lib")
195 ELSE()
196   SET(DLL_SO "so")
197   SET(DLL_SO_FOLDER "lib")
198   SET(DLL_SO_PREFIX "lib")
199 ENDIF()
200
201 SET(3RDPARTY_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory contains required 3rdparty products")
202 SET(3RDPARTY_INCLUDE_DIRS "")
203 SET(3RDPARTY_NOT_INCLUDED)
204
205 IF(APPLE)
206   SET(USE_GLX OFF CACHE BOOL "whether use X11 OpenGL on OSX or not")
207 ENDIF()
208
209 SET(USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
210 SET(USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
211 SET(USE_TBB OFF CACHE BOOL "whether use tbb product or not")
212 SET(USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
213
214 SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
215
216 MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
217   IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
218     SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
219   ENDIF()
220
221   IF(3RDPARTY_DIR AND ("${3RDPARTY_${PRODUCT_NAME}_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
222     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
223     IF("${${PRODUCT_NAME}_DIR_NAME}" STREQUAL "")
224       MESSAGE(STATUS "${PRODUCT_NAME} DON'T FIND")
225     ELSE()
226       SET(3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "Directory contains ${PRODUCT_NAME} product" FORCE)
227     ENDIF()
228   ENDIF()
229
230   SET(INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} lib copy to install directory")
231
232   IF(3RDPARTY_${PRODUCT_NAME}_DIR)
233     IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
234       SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
235       FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
236     ENDIF()
237
238     IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
239       SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of the ${PRODUCT_NAME} product" FORCE)
240       FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME}  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
241     ENDIF()
242
243     IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
244       SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of the ${PRODUCT_NAME} product" FORCE)
245       FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}"  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
246     ENDIF()
247
248     MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
249   ELSE()
250
251   ENDIF()
252
253   # check default path (with additions) for header search
254   IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
255     SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
256     FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER})
257   ENDIF()
258
259   # check default path (with additions) for library search
260   IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
261     SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
262     FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB})
263   ENDIF()
264
265   # check default path (with additions) for DLL search
266   IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
267     SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
268     FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL})
269   ENDIF()
270
271   IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
272     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
273   ELSE()
274     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
275   ENDIF()
276
277   IF(3RDPARTY_${PRODUCT_NAME}_LIBRARY)
278     GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
279     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
280   ELSE()
281     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY)
282   ENDIF()
283
284   IF(3RDPARTY_${PRODUCT_NAME}_DLL)
285     #
286   ELSE()
287     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL)
288   ENDIF()
289
290   IF(INSTALL_${PRODUCT_NAME})
291     INSTALL(FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
292     SET(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "")
293   ELSE()
294     GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
295   ENDIF()
296 ENDMACRO()
297
298 # TCL
299 INCLUDE(adm/templates/tcl.cmake)
300
301 #install tcltk
302 IF(INSTALL_TCL)
303   GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
304   GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
305
306   IF (IS_TCL_VERSION_FOUND)
307     SET (TCL_VERSION ${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION})
308     SET (TCL_FOLDER_VERSION ${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION})
309   ELSE()
310     SET (TCL_VERSION "")
311
312     #TODO SEARCH tclX.X & tkX.X subdirs
313     SET (TCL_FOLDER_VERSION "")
314   ENDIF()
315   
316   INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR}/${DLL_SO_PREFIX}tcl${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
317   INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR}/${DLL_SO_PREFIX}tk${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
318   
319   IF (IS_TCL_VERSION_FOUND)
320     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR}/tcl8" DESTINATION "${INSTALL_DIR}/lib")
321     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR}/tcl${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
322     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR}/tk${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
323   ELSE()
324     MESSAGE(STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
325     MESSAGE(STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
326   ENDIF()
327 ENDIF()
328
329 # GLX
330 IF(USE_GLX)
331   ADD_DEFINITIONS(-DMACOSX_USE_GLX)
332
333   IF(NOT DEFINED 3RDPARTY_GLX_DIR)
334     SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
335   ENDIF()
336
337   IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
338     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
339     IF("${GLX_DIR_NAME}" STREQUAL "")
340       MESSAGE(STATUS "GLX DON'T FIND")
341     ELSE()
342       SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
343     ENDIF()
344   ENDIF()
345
346   IF(3RDPARTY_GLX_DIR)
347     SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
348     SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib"     CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
349
350     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
351     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
352
353     MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
354   ELSE()
355     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
356     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
357   ENDIF()
358 ENDIF()
359
360 # FREETYPE
361 THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${BUILD_SUFFIX}")
362
363 IF("${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
364
365 ELSEIF(EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2/")
366   SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2")
367 ENDIF()
368
369 # FREEIMAGE
370 IF(USE_FREEIMAGE)
371   ADD_DEFINITIONS(-DHAVE_FREEIMAGE)
372
373   THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${BUILD_SUFFIX}")
374   IF(WIN32)
375     IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
376     ELSE()
377       SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
378     ENDIF()
379
380     THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${BUILD_SUFFIX}")
381
382   ENDIF()
383 ENDIF()
384
385 # GL2PS
386 IF(USE_GL2PS)
387   ADD_DEFINITIONS(-DHAVE_GL2PS)
388   THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
389 ENDIF()
390
391 # OPENCL
392 IF(USE_OPENCL)
393   ADD_DEFINITIONS(-DHAVE_OPENCL)
394
395   SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
396                                                   $ENV{INTELOCLSDKROOT}/include
397                                                   $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
398                                                   $ENV{ATISTREAMSDKROOT}/include)
399
400
401   IF(${COMPILER_BITNESS} STREQUAL 32)
402     SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
403                                                  $ENV{INTELOCLSDKROOT}/lib/x86
404                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
405                                                  $ENV{ATISTREAMSDKROOT}/lib/x86)
406   ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
407     SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
408                                                  $ENV{INTELOCLSDKROOT}/lib/x64
409                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
410                                                  $ENV{ATISTREAMSDKROOT}/lib/x86_64)
411   ENDIF()
412
413
414   THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${BUILD_SUFFIX}")
415
416   # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
417   # then try to find OpenCL/cl.h (all other variable won't be changed)
418   THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${BUILD_SUFFIX}")
419 ENDIF()
420
421 # TBB
422 IF (USE_TBB)
423   ADD_DEFINITIONS(-DHAVE_TBB)
424
425   INCLUDE(adm/templates/tbb.cmake)
426
427   IF(INSTALL_TBB)
428     INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
429
430     SET(3RDPARTY_TBB_DLL_DIR "")
431     SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
432   ELSE()
433     GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
434     GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
435   ENDIF()
436 ENDIF()
437
438 string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
439
440 #CHECK ALL 3RDPARTY PATHS
441 IF(3RDPARTY_NOT_INCLUDED)
442   MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
443 ENDIF()
444
445 list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
446 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
447 MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
448 include_directories( ${3RDPARTY_INCLUDE_DIRS} )
449
450 list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
451 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
452 MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
453 link_directories( ${3RDPARTY_LIBRARY_DIRS} )
454
455 #
456 SET(RUN_PROJECT "")
457 SET(CASROOT_DEFINITION "set \"CASROOT=${CMAKE_SOURCE_DIR}\"")
458 SET(BIN_DIR_POSTFIX "bin")
459 SET(RESOURCE_DIR_PREFIX "%SCRIPTROOT%\\src")
460
461 IF("${INSTALL_DIR}" STREQUAL "")
462   MESSAGE(FATAL_ERROR "INSTALL_DIR is empty")
463 ELSE()
464   # inc,data,tests DIRECTORY
465   install(DIRECTORY "${CMAKE_SOURCE_DIR}/inc"   DESTINATION  "${INSTALL_DIR}" )
466   install(DIRECTORY "${CMAKE_SOURCE_DIR}/data"  DESTINATION  "${INSTALL_DIR}" )
467   IF(INSTALL_TESTS)
468     install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
469   ENDIF()
470
471   # DRAW.BAT or DRAW.SH
472   install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS  OWNER_READ OWNER_WRITE OWNER_EXECUTE 
473                                                                               GROUP_READ GROUP_WRITE GROUP_EXECUTE 
474                                                                               WORLD_READ WORLD_WRITE WORLD_EXECUTE)
475   IF (BUILD_Samples)
476     install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/sample.bat" DESTINATION  "${INSTALL_DIR}")
477   ENDIF()
478
479   configure_file("${CMAKE_SOURCE_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
480   install(FILES "${OCCT_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" )
481 ENDIF()
482
483 IF(MSVC AND "${BUILD_CONFIGURATION}" STREQUAL "Debug")
484   SET(RUN_PROJECT "start OCCT.sln")
485   SET(BIN_DIR_POSTFIX "out\\bin\\Debug")
486   SET(RESOURCE_DIR_PREFIX "%CASROOT%\\src")
487   configure_file("${CMAKE_SOURCE_DIR}/adm/cmake/env.bat.in" OCCT.bat @ONLY)
488 ENDIF()
489
490 include(adm/cmake/CMakeToolKitsDeps.txt)
491
492 IF (BUILD_Samples)
493   SET (CMAKE_MFC_FLAG 2)
494   SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
495
496   SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
497   SET (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
498
499   subdirs(samples/mfc/standard/mfcsample)
500   subdirs(samples/mfc/standard/01_Geometry)
501   subdirs(samples/mfc/standard/02_Modeling)
502   subdirs(samples/mfc/standard/03_Viewer2d)
503   subdirs(samples/mfc/standard/04_Viewer3d)
504   subdirs(samples/mfc/standard/05_ImportExport)
505   subdirs(samples/mfc/standard/06_Ocaf)
506   subdirs(samples/mfc/standard/07_Triangulation)
507   subdirs(samples/mfc/standard/08_HLR)
508   subdirs(samples/mfc/standard/09_Animation)
509   subdirs(samples/mfc/standard/10_Convert)
510 ENDIF()