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