0024426: CMake ignores 3rd party options; env.sh does not set "CASROOT" environment...
[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   SET(3RDPARTY_TCL_DLL_DIR "")
304   SET(3RDPARTY_TCL_LIB_DIR "")
305   
306   GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR_INSIDE "${3RDPARTY_TCL_LIBRARY}" PATH)
307   GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR_INSIDE "${3RDPARTY_TCL_DLL}" PATH)
308
309   IF (IS_TCL_VERSION_FOUND)
310     SET (TCL_VERSION ${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION})
311     SET (TCL_FOLDER_VERSION ${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION})
312   ELSE()
313     SET (TCL_VERSION "")
314
315     #TODO SEARCH tclX.X & tkX.X subdirs
316     SET (TCL_FOLDER_VERSION "")
317   ENDIF()
318   
319   INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tcl${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
320   INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tk${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
321   
322   IF (IS_TCL_VERSION_FOUND)
323     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl8" DESTINATION "${INSTALL_DIR}/lib")
324     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
325     INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tk${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
326   ELSE()
327     MESSAGE(STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
328     MESSAGE(STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
329   ENDIF()
330 ELSE()
331   GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
332   GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
333 ENDIF()
334
335 # GLX
336 IF(USE_GLX)
337   ADD_DEFINITIONS(-DMACOSX_USE_GLX)
338
339   IF(NOT DEFINED 3RDPARTY_GLX_DIR)
340     SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
341   ENDIF()
342
343   IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
344     FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
345     IF("${GLX_DIR_NAME}" STREQUAL "")
346       MESSAGE(STATUS "GLX DON'T FIND")
347     ELSE()
348       SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
349     ENDIF()
350   ENDIF()
351
352   IF(3RDPARTY_GLX_DIR)
353     SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
354     SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib"     CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
355
356     SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
357     SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
358
359     MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
360   ELSE()
361     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
362     LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
363   ENDIF()
364 ENDIF()
365
366 # FREETYPE
367 THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${BUILD_SUFFIX}")
368
369 IF("${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
370
371 ELSEIF(EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2/")
372   SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2")
373 ENDIF()
374
375 # FREEIMAGE
376 IF(USE_FREEIMAGE)
377   ADD_DEFINITIONS(-DHAVE_FREEIMAGE)
378
379   THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${BUILD_SUFFIX}")
380   IF(WIN32)
381     IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
382     ELSE()
383       SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
384     ENDIF()
385
386     THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${BUILD_SUFFIX}")
387
388   ENDIF()
389 ENDIF()
390
391 # GL2PS
392 IF(USE_GL2PS)
393   ADD_DEFINITIONS(-DHAVE_GL2PS)
394   THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
395 ENDIF()
396
397 # OPENCL
398 IF(USE_OPENCL)
399   ADD_DEFINITIONS(-DHAVE_OPENCL)
400
401   SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
402                                                   $ENV{INTELOCLSDKROOT}/include
403                                                   $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
404                                                   $ENV{ATISTREAMSDKROOT}/include)
405
406
407   IF(${COMPILER_BITNESS} STREQUAL 32)
408     SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
409                                                  $ENV{INTELOCLSDKROOT}/lib/x86
410                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
411                                                  $ENV{ATISTREAMSDKROOT}/lib/x86)
412   ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
413     SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
414                                                  $ENV{INTELOCLSDKROOT}/lib/x64
415                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
416                                                  $ENV{ATISTREAMSDKROOT}/lib/x86_64)
417   ENDIF()
418
419
420   THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${BUILD_SUFFIX}")
421
422   # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
423   # then try to find OpenCL/cl.h (all other variable won't be changed)
424   THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${BUILD_SUFFIX}")
425 ENDIF()
426
427 # TBB
428 IF (USE_TBB)
429   ADD_DEFINITIONS(-DHAVE_TBB)
430
431   INCLUDE(adm/templates/tbb.cmake)
432
433   IF(INSTALL_TBB)
434     INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
435
436     SET(3RDPARTY_TBB_DLL_DIR "")
437     SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
438   ELSE()
439     GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
440     GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
441   ENDIF()
442 ENDIF()
443
444 string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
445
446 #CHECK ALL 3RDPARTY PATHS
447 IF(3RDPARTY_NOT_INCLUDED)
448   MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
449 ENDIF()
450
451 list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
452 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
453 MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
454 include_directories( ${3RDPARTY_INCLUDE_DIRS} )
455
456 list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
457 string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
458 MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
459 link_directories( ${3RDPARTY_LIBRARY_DIRS} )
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 include(adm/cmake/CMakeToolKitsDeps.txt)
484
485 IF (BUILD_Samples)
486   SET (CMAKE_MFC_FLAG 2)
487   SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
488
489   SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
490   SET (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
491
492   subdirs(samples/mfc/standard/mfcsample)
493   subdirs(samples/mfc/standard/01_Geometry)
494   subdirs(samples/mfc/standard/02_Modeling)
495   subdirs(samples/mfc/standard/03_Viewer2d)
496   subdirs(samples/mfc/standard/04_Viewer3d)
497   subdirs(samples/mfc/standard/05_ImportExport)
498   subdirs(samples/mfc/standard/06_Ocaf)
499   subdirs(samples/mfc/standard/07_Triangulation)
500   subdirs(samples/mfc/standard/08_HLR)
501   subdirs(samples/mfc/standard/09_Animation)
502   subdirs(samples/mfc/standard/10_Convert)
503 ENDIF()