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