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