0024953: Draw crashed after execution of test case bugs/modalg_5/bug24764
[occt.git] / CMakeLists.txt
CommitLineData
03c69aec 1cmake_minimum_required ( VERSION 2.6)
166d6cd7 2
ad211ad3 3if (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)
03c69aec 6endif()
166d6cd7 7
ad211ad3 8set(CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
03c69aec 9
10project(OCCT)
11
ad211ad3 12set_property(GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 13
14set(BUILD_SHARED_LIBS ON)
15
ad211ad3 16IF("${BUILD_CONFIGURATION}" STREQUAL "${CMAKE_BUILD_TYPE}")
03c69aec 17 SET(CHANGES_ARE_NEEDED OFF)
18ELSE()
19 SET(CHANGES_ARE_NEEDED ON)
20ENDIF()
21
11fca7c1 22MATH(EXPR COMPILER_BITNESS "32 + 32*(${CMAKE_SIZEOF_VOID_P}/8)")
03c69aec 23
33839ae6 24SET(CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
03c69aec 25
33839ae6 26SET(INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
27SET(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
28
29set(BUILD_PATCH_DIR "" CACHE PATH "directory with occt patch")
03c69aec 30
ad211ad3 31set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
03c69aec 32separate_arguments(BUILD_TOOLKITS)
33
234e52be 34IF(MSVC)
35 SET(BUILD_Samples OFF CACHE BOOL "OCCT samples building")
36ENDIF()
37
33839ae6 38# consider for patch existence
39SET (IS_PATCH_CURRENT "NO")
40SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
41IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
42 SET (IS_PATCH_CURRENT "YES")
43 SET (TK_ROOT_DIR ${BUILD_PATCH_DIR})
44ENDIF()
45
46# include the list of patch modules if the one exists
47# or include the list of original modules
48IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt")
49 MESSAGE(STATUS "Info: the list of patched modules is included")
50 include(${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt)
51ELSE()
52 include(adm/cmake/CMakeModules.txt)
53ENDIF()
03c69aec 54
55if (WIN32)
56 set(SCRIPT_EXT bat)
57else()
58 set(SCRIPT_EXT sh)
59endif()
60
ad211ad3 61if (MSVC)
62 add_definitions(/fp:precise)
63endif()
64
85bcc072 65# choose SSE2 option for appropriate MSVC compilers
66if (MSVC80 OR MSVC90 OR MSVC10)
4d42a1a5 67 if (${COMPILER_BITNESS} STREQUAL 32)
68 add_definitions(/arch:SSE2)
69 endif()
85bcc072 70endif()
71
72# set compiler short name
73if (MSVC)
74 if (MSVC70)
75 set (COMPILER vc7)
76 elseif (MSVC80)
77 set (COMPILER vc8)
78 elseif (MSVC90)
79 set (COMPILER vc9)
80 elseif (MSVC10)
81 set (COMPILER vc10)
82 elseif (MSVC11)
83 set (COMPILER vc11)
4d42a1a5 84 endif()
85bcc072 85elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
86 set (COMPILER gcc)
87elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
88 set (COMPILER gxx)
89elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
90 set (COMPILER clang)
91elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
92 set (COMPILER icc)
03c69aec 93else()
85bcc072 94 set (COMPILER ${CMAKE_GENERATOR})
95 string (REGEX REPLACE " " "" COMPILER ${COMPILER})
03c69aec 96endif()
85bcc072 97
32856b63 98if (WIN32)
99 SET(OS_WITH_BIT "win${COMPILER_BITNESS}")
100elseif(APPLE)
101 SET(OS_WITH_BIT "mac${COMPILER_BITNESS}")
102else()
103 SET(OS_WITH_BIT "lin${COMPILER_BITNESS}")
104endif()
03c69aec 105
03c69aec 106add_definitions(-DCSFDB)
107if(WIN32)
108 add_definitions(/DWNT -wd4996)
109elseif(APPLE)
110 add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
111else()
112 add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
113endif()
114
4d42a1a5 115# enable structured exceptions for MSVC
03c69aec 116string(REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
117IF(ISFLAG)
118 STRING(REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
119ELSEIF(WIN32)
120 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
121ENDIF()
122
4d42a1a5 123# enable parallel compilation on MSVC 9 and above
03c69aec 124IF(WIN32)
125 IF(NOT DEFINED MSVC70 AND NOT DEFINED MSVC80)
126 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
127 ENDIF()
128ENDIF()
129
4d42a1a5 130# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
d5aedb2c 131IF(MSVC)
132 if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
133 string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
134 else()
135 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
136 endif()
137elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
138 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
139endif()
140
03c69aec 141SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
142SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
143
144SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
145SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
146
147set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
148set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
149set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)
150
151# RESOURCES
152install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/DrawResources" DESTINATION "${INSTALL_DIR}/src" )
153install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/StdResource" DESTINATION "${INSTALL_DIR}/src" )
154install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/SHMessage" DESTINATION "${INSTALL_DIR}/src" )
155install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Textures" DESTINATION "${INSTALL_DIR}/src" )
4058ef10 156install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Shaders" DESTINATION "${INSTALL_DIR}/src" )
03c69aec 157install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSMessage" DESTINATION "${INSTALL_DIR}/src" )
03c69aec 158install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSTEPResource" DESTINATION "${INSTALL_DIR}/src" )
159install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XmlOcafResource" DESTINATION "${INSTALL_DIR}/src" )
160
161install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Lexi_Expr.dat" DESTINATION "${INSTALL_DIR}/src/UnitsAPI" )
162install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Units.dat" DESTINATION "${INSTALL_DIR}/src/UnitsAPI" )
ad211ad3 163install(FILES "${CMAKE_SOURCE_DIR}/src/TObj/TObj.msg" DESTINATION "${INSTALL_DIR}/src/TObj" )
03c69aec 164
32856b63 165IF("${BUILD_CONFIGURATION}" STREQUAL "Debug")
166 SET(3RDPARTY_BUILD_SUFFIX "") # debug == release
167 SET(BUILD_SUFFIX "d")
03c69aec 168ELSE()
32856b63 169 SET(3RDPARTY_BUILD_SUFFIX "")
170 SET(BUILD_SUFFIX "")
03c69aec 171ENDIF()
172
173FUNCTION(SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
174 file(GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
234e52be 175
03c69aec 176 foreach(ITEM ${SUB_ITEMS})
177 if(IS_DIRECTORY "${ITEM}")
178 GET_FILENAME_COMPONENT(ITEM_NAME "${ITEM}" NAME)
179 LIST(APPEND LOCAL_RESULT "${ITEM_NAME}")
180 endif()
181 endforeach()
182 set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
183ENDFUNCTION()
184
185FUNCTION(FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
186 string( TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME )
234e52be 187
11fca7c1 188 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${COMPILER_BITNESS}")
189 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}")
190 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER_BITNESS}")
03c69aec 191 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
192 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
234e52be 193
03c69aec 194 SUBDIRECTORY_NAMES( "${ROOT_DIR}" SUBDIR_NAME_LIST)
234e52be 195
03c69aec 196 FOREACH( SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
197 IF(LOCAL_RESULT)
198 BREAK()
199 ENDIF()
234e52be 200
03c69aec 201 FOREACH(SUBDIR_NAME ${SUBDIR_NAME_LIST})
202 string( TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME )
234e52be 203
03c69aec 204 STRING(REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
205 IF(DUMMY_VAR)
206 LIST(APPEND LOCAL_RESULT ${SUBDIR_NAME})
207 ENDIF()
208 ENDFOREACH()
209 ENDFOREACH()
234e52be 210
03c69aec 211 IF(LOCAL_RESULT)
212 LIST(LENGTH "${LOCAL_RESULT}" LOC_LEN)
213 MATH(EXPR LAST_ELEMENT_INDEX "${LOC_LEN}-1")
214 LIST(GET LOCAL_RESULT ${LAST_ELEMENT_INDEX} DUMMY)
215 SET(${RESULT} ${DUMMY} PARENT_SCOPE)
234e52be 216 ENDIF()
03c69aec 217ENDFUNCTION()
218
219IF(WIN32)
220 SET(DLL_SO "dll")
221 SET(DLL_SO_FOLDER "bin")
222 SET(DLL_SO_PREFIX "")
223ELSEIF(APPLE)
224 SET(DLL_SO "dylib")
225 SET(DLL_SO_FOLDER "lib")
226 SET(DLL_SO_PREFIX "lib")
227ELSE()
228 SET(DLL_SO "so")
229 SET(DLL_SO_FOLDER "lib")
230 SET(DLL_SO_PREFIX "lib")
231ENDIF()
232
7c633a3e 233SET(3RDPARTY_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory contains required 3rdparty products")
03c69aec 234SET(3RDPARTY_INCLUDE_DIRS "")
235SET(3RDPARTY_NOT_INCLUDED)
236
237IF(APPLE)
ad211ad3 238 SET(USE_GLX OFF CACHE BOOL "whether use X11 OpenGL on OSX or not")
03c69aec 239ENDIF()
240
ad211ad3 241SET(USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
242SET(USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
243SET(USE_TBB OFF CACHE BOOL "whether use tbb product or not")
244SET(USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
03c69aec 245
246SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
247
a5deedd0 248MACRO (CHECK_AND_UNSET VARNAME)
249 IF(DEFINED ${VARNAME})
250 UNSET(${VARNAME} CACHE)
251 ENDIF()
252ENDMACRO()
253
254MACRO (CHECK_AND_UNSET_GROUP VARNAME)
255 CHECK_AND_UNSET ("${VARNAME}_DIR")
256 CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
257 CHECK_AND_UNSET ("${VARNAME}_DLL")
258 CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
259ENDMACRO()
260
03c69aec 261MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
262 IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
263 SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
264 ENDIF()
234e52be 265
03c69aec 266 IF(3RDPARTY_DIR AND ("${3RDPARTY_${PRODUCT_NAME}_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
267 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
268 IF("${${PRODUCT_NAME}_DIR_NAME}" STREQUAL "")
269 MESSAGE(STATUS "${PRODUCT_NAME} DON'T FIND")
270 ELSE()
271 SET(3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "Directory contains ${PRODUCT_NAME} product" FORCE)
272 ENDIF()
273 ENDIF()
234e52be 274
03c69aec 275 SET(INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} lib copy to install directory")
276
277 IF(3RDPARTY_${PRODUCT_NAME}_DIR)
278 IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
279 SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
85bcc072 280 if ("${PRODUCT_NAME}" STREQUAL "FREETYPE")
281 FIND_PATH(3RDPARTY_FREETYPE_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_FREETYPE_DIR}/include" "${3RDPARTY_FREETYPE_DIR}/include/freetype2" NO_DEFAULT_PATH)
282 else()
283 FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
284 endif()
03c69aec 285 ENDIF()
234e52be 286
03c69aec 287 IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
ad211ad3 288 SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of the ${PRODUCT_NAME} product" FORCE)
03c69aec 289 FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
03c69aec 290 ENDIF()
234e52be 291
03c69aec 292 IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
ad211ad3 293 SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of the ${PRODUCT_NAME} product" FORCE)
03c69aec 294 FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
03c69aec 295 ENDIF()
234e52be 296
03c69aec 297 MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
7c633a3e 298 ELSE()
234e52be 299
7c633a3e 300 ENDIF()
234e52be 301
7c633a3e 302 # check default path (with additions) for header search
303 IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
304 SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
305 FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER})
306 ENDIF()
307
308 # check default path (with additions) for library search
309 IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
310 SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
311 FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB})
312 ENDIF()
313
314 # check default path (with additions) for DLL search
315 IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
316 SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
317 FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL})
03c69aec 318 ENDIF()
319
320 IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
321 SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
322 ELSE()
323 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
324 ENDIF()
325
326 IF(3RDPARTY_${PRODUCT_NAME}_LIBRARY)
327 GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
328 SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
329 ELSE()
330 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY)
331 ENDIF()
234e52be 332
03c69aec 333 IF(3RDPARTY_${PRODUCT_NAME}_DLL)
334 #
335 ELSE()
336 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL)
337 ENDIF()
338
339 IF(INSTALL_${PRODUCT_NAME})
32856b63 340 INSTALL(FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
03c69aec 341 SET(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "")
342 ELSE()
343 GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
344 ENDIF()
345ENDMACRO()
346
347# TCL
ad211ad3 348INCLUDE(adm/templates/tcl.cmake)
03c69aec 349
ad211ad3 350#install tcltk
351IF(INSTALL_TCL)
a0726e55 352 SET(3RDPARTY_TCL_DLL_DIR "")
353 SET(3RDPARTY_TCL_LIB_DIR "")
354
355 GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR_INSIDE "${3RDPARTY_TCL_LIBRARY}" PATH)
356 GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR_INSIDE "${3RDPARTY_TCL_DLL}" PATH)
234e52be 357
ad211ad3 358 IF (IS_TCL_VERSION_FOUND)
359 SET (TCL_VERSION ${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION})
360 SET (TCL_FOLDER_VERSION ${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION})
361 ELSE()
362 SET (TCL_VERSION "")
03c69aec 363
ad211ad3 364 #TODO SEARCH tclX.X & tkX.X subdirs
365 SET (TCL_FOLDER_VERSION "")
366 ENDIF()
367
32856b63 368 INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tcl${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
369 INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tk${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
03c69aec 370
ad211ad3 371 IF (IS_TCL_VERSION_FOUND)
32856b63 372 # tcl is required to install in lib folder (without ${BUILD_SUFFIX})
373 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl8" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
374 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
375 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tk${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
ad211ad3 376 ELSE()
377 MESSAGE(STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
378 MESSAGE(STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
379 ENDIF()
a0726e55 380ELSE()
381 GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
382 GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
03c69aec 383ENDIF()
384
385# GLX
ad211ad3 386IF(USE_GLX)
03c69aec 387 ADD_DEFINITIONS(-DMACOSX_USE_GLX)
234e52be 388
03c69aec 389 IF(NOT DEFINED 3RDPARTY_GLX_DIR)
390 SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
391 ENDIF()
234e52be 392
03c69aec 393 IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
394 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
395 IF("${GLX_DIR_NAME}" STREQUAL "")
396 MESSAGE(STATUS "GLX DON'T FIND")
397 ELSE()
398 SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
399 ENDIF()
400 ENDIF()
234e52be 401
03c69aec 402 IF(3RDPARTY_GLX_DIR)
403 SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
404 SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib" CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
234e52be 405
03c69aec 406 SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
407 SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
234e52be 408
03c69aec 409 MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
410 ELSE()
411 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
412 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
413 ENDIF()
414ENDIF()
415
416# FREETYPE
32856b63 417THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${3RDPARTY_BUILD_SUFFIX}")
03c69aec 418
03c69aec 419# FREEIMAGE
ad211ad3 420IF(USE_FREEIMAGE)
234e52be 421 ADD_DEFINITIONS(-DHAVE_FREEIMAGE)
03c69aec 422
32856b63 423 THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${3RDPARTY_BUILD_SUFFIX}")
03c69aec 424 IF(WIN32)
425 IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
426 ELSE()
427 SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
428 ENDIF()
234e52be 429
32856b63 430 THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${3RDPARTY_BUILD_SUFFIX}")
234e52be 431
03c69aec 432 ENDIF()
a5deedd0 433ELSE()
434 CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
435 CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
436 CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
437 CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
03c69aec 438ENDIF()
439
440# GL2PS
ad211ad3 441IF(USE_GL2PS)
03c69aec 442 ADD_DEFINITIONS(-DHAVE_GL2PS)
32856b63 443 THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${3RDPARTY_BUILD_SUFFIX}")
a5deedd0 444ELSE()
445 CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
446 CHECK_AND_UNSET ("INSTALL_GL2PS")
03c69aec 447ENDIF()
448
7c633a3e 449# OPENCL
ad211ad3 450IF(USE_OPENCL)
234e52be 451 ADD_DEFINITIONS(-DHAVE_OPENCL)
452
7c633a3e 453 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
454 $ENV{INTELOCLSDKROOT}/include
455 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
456 $ENV{ATISTREAMSDKROOT}/include)
234e52be 457
458
7c633a3e 459 IF(${COMPILER_BITNESS} STREQUAL 32)
460 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
461 $ENV{INTELOCLSDKROOT}/lib/x86
462 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
463 $ENV{ATISTREAMSDKROOT}/lib/x86)
464 ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
465 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
466 $ENV{INTELOCLSDKROOT}/lib/x64
467 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
468 $ENV{ATISTREAMSDKROOT}/lib/x86_64)
469 ENDIF()
234e52be 470
471
32856b63 472 THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${3RDPARTY_BUILD_SUFFIX}")
234e52be 473
474 # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
7c633a3e 475 # then try to find OpenCL/cl.h (all other variable won't be changed)
32856b63 476 IF("${3RDPARTY_OPENCL_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_OPENCL_INCLUDE_DIR}" STREQUAL "3RDPARTY_OPENCL_INCLUDE_DIR-NOTFOUND")
477 THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${3RDPARTY_BUILD_SUFFIX}")
478 ENDIF()
479
a5deedd0 480ELSE()
481 CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
32856b63 482 CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
a5deedd0 483 CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
484 CHECK_AND_UNSET ("INSTALL_OPENCL")
7c633a3e 485ENDIF()
486
03c69aec 487# TBB
ad211ad3 488IF (USE_TBB)
03c69aec 489 ADD_DEFINITIONS(-DHAVE_TBB)
490
ad211ad3 491 INCLUDE(adm/templates/tbb.cmake)
234e52be 492
03c69aec 493 IF(INSTALL_TBB)
32856b63 494 INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
03c69aec 495
496 SET(3RDPARTY_TBB_DLL_DIR "")
497 SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
498 ELSE()
499 GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
500 GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
501 ENDIF()
a5deedd0 502ELSE()
503 CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
504 CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB_MALLOC")
505 CHECK_AND_UNSET ("3RDPARTY_TBB_DIR_NAME")
506 CHECK_AND_UNSET ("INSTALL_TBB")
03c69aec 507ENDIF()
508
509string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
510
511#CHECK ALL 3RDPARTY PATHS
512IF(3RDPARTY_NOT_INCLUDED)
513 MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
514ENDIF()
515
516list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
517string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
518MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
519include_directories( ${3RDPARTY_INCLUDE_DIRS} )
520
521list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
522string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
523MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
524link_directories( ${3RDPARTY_LIBRARY_DIRS} )
525
03c69aec 526IF("${INSTALL_DIR}" STREQUAL "")
527 MESSAGE(FATAL_ERROR "INSTALL_DIR is empty")
528ELSE()
529 # inc,data,tests DIRECTORY
32856b63 530 install(DIRECTORY "${CMAKE_SOURCE_DIR}/inc" DESTINATION "${INSTALL_DIR}")
531 install(DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${INSTALL_DIR}")
532 install(DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl" DESTINATION "${INSTALL_DIR}/samples")
03c69aec 533 IF(INSTALL_TESTS)
534 install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
535 ENDIF()
536
33839ae6 537 # install patch inc, data, tests folder
538 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
539 IF(EXISTS "${BUILD_PATCH_DIR}/inc")
540 install(DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION "${INSTALL_DIR}" )
541 ENDIF()
542
543 IF(EXISTS "${BUILD_PATCH_DIR}/data")
544 install(DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${INSTALL_DIR}" )
545 ENDIF()
546
547 IF(INSTALL_TESTS)
548 IF(EXISTS "${BUILD_PATCH_DIR}/tests")
549 install(DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
550 ENDIF()
551 ENDIF()
552 ENDIF()
553
03c69aec 554 # DRAW.BAT or DRAW.SH
33839ae6 555 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
556 install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
557 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
558 ELSE()
559 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
560 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
561 ENDIF()
562
32856b63 563
564 SET(CUSTOM_CUR "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_SUFFIX}.${SCRIPT_EXT}")
565
566 if (WIN32)
567 SET (CUSTOM_ADD_CONTENT "\nif exist \"%~dp0${CUSTOM_CUR}\" (\n call \"%~dp0${CUSTOM_CUR}\" %1 %2 %3 \n)")
568 else()
569 SET (CUSTOM_ADD_CONTENT "\nif [ -e \"\${aScriptPath}/${CUSTOM_CUR}\" ]; then\n source \"\${aScriptPath}/${CUSTOM_CUR}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
570 endif()
571
572 # change custom.bat/sh
573 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
574 FILE(READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
575
576 SET (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${CUSTOM_ADD_CONTENT}")
577
578 FILE(WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
579 else()
580 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.main")
581 configure_file("${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" @ONLY)
582 ELSE()
583 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" @ONLY)
584 ENDIF()
585
586 install(FILES "${OCCT_BINARY_DIR}/custom.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}")
587 endif()
588
589 # write current custom.bat/sh
590 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.in")
591 configure_file("${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.in" ${CUSTOM_CUR} @ONLY)
592 ELSE()
593 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/custom.${SCRIPT_EXT}.in" ${CUSTOM_CUR} @ONLY)
594 ENDIF()
595
596 install(FILES "${OCCT_BINARY_DIR}/${CUSTOM_CUR}" DESTINATION "${INSTALL_DIR}" )
597
234e52be 598 IF (BUILD_Samples)
33839ae6 599 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/sample.bat")
600 install(FILES "${BUILD_PATCH_DIR}/adm/templates/sample.bat" DESTINATION "${INSTALL_DIR}")
601 ELSE()
602 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/sample.bat" DESTINATION "${INSTALL_DIR}")
603 ENDIF()
234e52be 604 ENDIF()
03c69aec 605
33839ae6 606 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in")
607 configure_file("${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
608 ELSE()
609 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
610 ENDIF()
03c69aec 611 install(FILES "${OCCT_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" )
612ENDIF()
613
33839ae6 614# include patched toolkit projects or original ones
615SET (UNSUBDIRS "")
616IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt")
617 include(${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt)
618ELSE()
619 SET (IS_PATCH_CURRENT "NO")
620 SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
621 include(adm/cmake/CMakeToolKitsDeps.txt)
622ENDIF()
623
624# include some required original toolkit
625IF(NOT "${UNSUBDIRS}" STREQUAL "")
626 SET (IS_PATCH_CURRENT "NO")
627 SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
628 # add required subdirs
629 FOREACH(UNSUBDIR ${UNSUBDIRS})
630 MESSAGE(STATUS "${UNSUBDIR}")
631 subdirs(${TK_ROOT_DIR}/${UNSUBDIR})
632 ENDFOREACH()
633ENDIF()
234e52be 634
33839ae6 635# samples do not support patch usage
234e52be 636IF (BUILD_Samples)
637 SET (CMAKE_MFC_FLAG 2)
638 SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
639
640 SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
641 SET (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
642
643 subdirs(samples/mfc/standard/mfcsample)
644 subdirs(samples/mfc/standard/01_Geometry)
645 subdirs(samples/mfc/standard/02_Modeling)
646 subdirs(samples/mfc/standard/03_Viewer2d)
647 subdirs(samples/mfc/standard/04_Viewer3d)
648 subdirs(samples/mfc/standard/05_ImportExport)
649 subdirs(samples/mfc/standard/06_Ocaf)
650 subdirs(samples/mfc/standard/07_Triangulation)
651 subdirs(samples/mfc/standard/08_HLR)
652 subdirs(samples/mfc/standard/09_Animation)
653 subdirs(samples/mfc/standard/10_Convert)
654ENDIF()