0026942: Training material are not built on OCCT installed after building by cmake...
[occt.git] / CMakeLists.txt
CommitLineData
19286d7c 1cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
166d6cd7 2
576f8b11 3set (CMAKE_SUPPRESS_REGENERATION TRUE)
4
fa0cbe55 5set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
03c69aec 6
316d77d9 7# macro: include patched file if it exists
8macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
109aa56e 9 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake")
10 include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 11 else()
f2e9c853 12 include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 13 endif()
14endmacro()
15
16# include variable description
17OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr")
18
c259930b 19# set type of OCCT libraries
20if (NOT BUILD_LIBRARY_TYPE)
316d77d9 21 set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE)
c259930b 22 SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
23endif()
24
25if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
26 set (BUILD_SHARED_LIBS ON)
27else()
28 unset (BUILD_SHARED_LIBS)
29endif()
30
9f33b387 31# the name of the project
32project (OCCT)
03c69aec 33
096ef695 34# include occt macros
35OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
36
9f33b387 37# Solution folder property
38set_property (GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 39
096ef695 40# get current OCCT version
41OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
42
43set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
44set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
45set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
46
0e617b05 47set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
096ef695 48
49# single-configuration generator
50set (SINGLE_GENERATOR OFF)
51if (CMAKE_BUILD_TYPE)
52 set (SINGLE_GENERATOR ON)
53endif()
54
316d77d9 55# a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable
56# check this variable and set if it's required
57if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator.
58 set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
19286d7c 59endif()
60
898f6a92 61# enable extended messages of many OCCT algorithms
109aa56e 62set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
63if (BUILD_WITH_DEBUG)
898f6a92 64 add_definitions (-DOCCT_DEBUG)
65endif()
316d77d9 66
19286d7c 67# copy samples to install directory
0e617b05 68set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}")
19286d7c 69
096ef695 70# install dir of the project
71if (NOT DEFINED INSTALL_DIR)
72 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
73endif()
74
d573adcf 75if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
76 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
77elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
78 # CMAKE_INSTALL_PREFIX has been changed at previous step
79 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
80
81 # INSTALL_DIR is required to be updated
82 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
83endif()
84
85if (NOT DEFINED INSTALL_DIR_PREV)
86 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
87elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
88 # INSTALL_DIR has been changed at previous step
89 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
90
91 # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
92 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
93
94 # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
95 set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
96
97 # The structure of install folder should be reset
98 OCCT_CHECK_AND_UNSET (INSTALL_BIN_DIR)
99 OCCT_CHECK_AND_UNSET (INSTALL_SCRIPT_DIR)
100 OCCT_CHECK_AND_UNSET (INSTALL_LIB_DIR)
101 OCCT_CHECK_AND_UNSET (INSTALL_INCLUDE_DIR)
102 OCCT_CHECK_AND_UNSET (INSTALL_OCCT_RESOURCE_DIR)
103 OCCT_CHECK_AND_UNSET (INSTALL_SHARE_DIR)
096ef695 104endif()
105
106# hide CMAKE_INSTALL_PREFIX from a user
107set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
108
109set (BIN_LETTER "")
110if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
111 set (BIN_LETTER "d")
112elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
113 set (BIN_LETTER "i")
114endif()
03c69aec 115
096ef695 116# Get all used variables: OS_WITH_BIT, COMPILER
117OCCT_MAKE_OS_WITH_BITNESS()
118OCCT_MAKE_COMPILER_SHORT_NAME()
119
120# do not define INSTALL_BIN_DIR for win.
121# Leave library structure for win: <prefix>/win64/vc10/bin(d)
122if (NOT DEFINED INSTALL_BIN_DIR)
123 if (UNIX)
124 set (INSTALL_BIN_DIR "${INSTALL_DIR}/bin" CACHE PATH "${INSTALL_BIN_DIR_DESCR}")
125 else()
126 if (SINGLE_GENERATOR)
127 set (INSTALL_BIN_DIR "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}" CACHE PATH "${INSTALL_BIN_DIR_DESCR}")
128 endif()
129 endif()
130endif()
131
132# define folder contaning all shell/batch scripts
133if (NOT DEFINED INSTALL_SCRIPT_DIR)
134 if (UNIX)
135 set (INSTALL_SCRIPT_DIR "${INSTALL_BIN_DIR}/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_SCRIPT_DIR_DESCR}")
136 else()
137 set (INSTALL_SCRIPT_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_SCRIPT_DIR_DESCR}")
138 endif()
139endif()
140
141# place the libraries to <prefix>/lib folder for unix and leave old structure for windows
142if (NOT DEFINED INSTALL_LIB_DIR)
143 if (UNIX)
144 set (INSTALL_LIB_DIR "${INSTALL_DIR}/lib" CACHE PATH "${INSTALL_LIB_DIR_DESCR}")
145 else()
146 if (SINGLE_GENERATOR)
147 set (INSTALL_LIB_DIR "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}" CACHE PATH "${INSTALL_LIB_DIR_DESCR}")
148 endif()
149 endif()
150endif()
151
152# OCCT headers: <prefix>/inc for windows,
153# <prefix>/include/opencascade-7.0.0 for unix
154if (NOT DEFINED INSTALL_INCLUDE_DIR)
155 if (UNIX)
156 set (INSTALL_INCLUDE_DIR "${INSTALL_DIR}/include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_INCLUDE_DIR_DESCR}")
157 else()
158 set (INSTALL_INCLUDE_DIR "${INSTALL_DIR}/inc" CACHE PATH "${INSTALL_INCLUDE_DIR_DESCR}")
159 endif()
160endif()
161
162# OCCT resources: <prefix>/src for windows,
163# <prefix>/share/opencascade-7.0.0/resources for unix
164if (NOT DEFINED INSTALL_OCCT_RESOURCE_DIR)
165 if (UNIX)
fd5a9eac 166 set (INSTALL_OCCT_RESOURCE_DIR "${INSTALL_DIR}/share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_OCCT_RESOURCE_DIR_DESCR}")
096ef695 167 else()
168 set (INSTALL_OCCT_RESOURCE_DIR "${INSTALL_DIR}/src" CACHE PATH "${INSTALL_OCCT_RESOURCE_DIR_DESCR}")
169 endif()
170endif()
171
172# OCCT data
173if (NOT DEFINED INSTALL_SHARE_DIR)
174 if (UNIX)
175 set (INSTALL_SHARE_DIR "${INSTALL_DIR}/share/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_SHARE_DIR_DESCR}")
176 else()
177 set (INSTALL_SHARE_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_SHARE_DIR_DESCR}")
178 endif()
179endif()
180
181# a directory recognized as a 'patch' for OCCT
109aa56e 182set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
03c69aec 183
9f33b387 184# the list of being built toolkits
316d77d9 185set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
186separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 187
ad211ad3 188if (MSVC)
316d77d9 189 set (BUILD_MODULE_OcctMfcSamples OFF CACHE BOOL "${BUILD_MODULE_OcctMfcSamples_DESCR}")
85bcc072 190endif()
191
9f33b387 192# whether use optional 3rdparty or not
193if (APPLE)
316d77d9 194 set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
03c69aec 195endif()
096ef695 196
f60111dc 197if (WIN32)
198 set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
199endif()
85bcc072 200
9f33b387 201# include the patched or original list of modules
19286d7c 202# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
203# list <OCCT_MODULES> will contain all modules
204OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
03c69aec 205
316d77d9 206foreach (OCCT_MODULE ${OCCT_MODULES})
207 BUILD_MODULE (${OCCT_MODULE})
19286d7c 208endforeach()
209
e713baee 210if (ANDROID AND BUILD_MODULE_Draw)
211 message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
212 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
213endif()
214
adc33035 215# Overview
316d77d9 216set (BUILD_DOC_OcctOverview OFF CACHE BOOL "${BUILD_DOC_OcctOverview_DESCR}")
adc33035 217
f60111dc 218if (NOT USE_D3D)
219 list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost)
220endif()
221
316d77d9 222# accumulate used toolkits (first level) in BUILD_TOOLKITS variable
223list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
19286d7c 224
316d77d9 225foreach (OCCT_MODULE ${OCCT_MODULES})
226 if (BUILD_MODULE_${OCCT_MODULE})
227 list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
19286d7c 228 endif()
229endforeach()
230
231# DRAWEXE excluded when library build is static
232if (NOT BUILD_SHARED_LIBS)
316d77d9 233 list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE)
19286d7c 234 message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
235endif()
236
237# accumulate all used toolkits
316d77d9 238list (REMOVE_DUPLICATES BUILD_TOOLKITS)
239set (RAW_BUILD_TOOLKITS)
096ef695 240foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
316d77d9 241 OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
242 list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
19286d7c 243endforeach()
244
316d77d9 245list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
246set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
03c69aec 247
9f33b387 248# include the patched or original list of definitions and flags
19286d7c 249OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
03c69aec 250
19286d7c 251OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
03c69aec 252
a6874708 253# search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
254list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
255if (CAN_USE_VTK EQUAL -1)
256 list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
257endif()
258
259if (NOT CAN_USE_VTK EQUAL -1)
260 if (NOT DEFINED USE_VTK)
261 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
262 endif()
263else()
264 OCCT_CHECK_AND_UNSET (USE_VTK)
265endif()
266
5682a6fa 267# Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
268list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH)
269list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
270
fb3267c7 271if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
109aa56e 272 set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
5682a6fa 273else()
109aa56e 274 OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
5682a6fa 275endif()
276
9f33b387 277if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 278 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
e713baee 279 get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
9f33b387 280endif()
234e52be 281
9f33b387 282# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
f2e9c853 283OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
03c69aec 284
fb3267c7 285if (USE_TCL)
5682a6fa 286 message (STATUS "Info: TCL is used by OCCT")
19286d7c 287 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
82f443b6 288
289 message (STATUS "Info: TK is used by OCCT")
290 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
9f33b387 291else()
9ccea0c6 292 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
293 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
5682a6fa 294
295 OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
82f443b6 296 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
9f33b387 297endif()
03c69aec 298
9f33b387 299# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
f2e9c853 300OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE)
03c69aec 301
fb3267c7 302if (USE_FREETYPE)
5682a6fa 303 message (STATUS "Info: Freetype is used by OCCT")
19286d7c 304 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
9f33b387 305else()
9ccea0c6 306 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 307 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
308 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
5682a6fa 309 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
9f33b387 310endif()
03c69aec 311
09c597c9 312# VTK
313if (USE_VTK)
314 add_definitions (-DHAVE_VTK)
19286d7c 315 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
f2e9c853 316else()
317 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
a6874708 318
319 if (NOT CAN_USE_VTK EQUAL -1)
320 message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
321
322 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
323 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
324 endif()
09c597c9 325endif()
326
f60111dc 327# D3D
328if (USE_D3D)
329 add_definitions (-DHAVE_D3D)
330 #if(MSVC_VERSION LESS 1700)
331 #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
332 #endif()
333endif()
334
09c597c9 335# GLX
336if (USE_GLX)
337 add_definitions (-DMACOSX_USE_GLX)
19286d7c 338 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
09c597c9 339endif()
340
03c69aec 341# FREEIMAGE
5682a6fa 342# search for CSF_FREEIMAGE variable in EXTERNLIB of each being used toolkit
343OCCT_IS_PRODUCT_REQUIRED (CSF_FREEIMAGE CAN_USE_FREEIMAGE)
344OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGEPLUS)
345
346if (CAN_USE_FREEIMAGE OR CAN_USE_FREEIMAGEPLUS)
347 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
348
349 if (USE_FREEIMAGE)
350 add_definitions (-DHAVE_FREEIMAGE)
351 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
352 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
353 else()
354 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
355 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
356 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
357 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
358 endif()
9f33b387 359else()
5682a6fa 360 OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
361
9f33b387 362 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
363 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
364 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
365 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
366endif()
03c69aec 367
368# GL2PS
5682a6fa 369# search for CSF_GL2PS variable in EXTERNLIB of each being used toolkit
370OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS)
371
372if (NOT DEFINED ANDROID AND CAN_USE_GL2PS)
373 set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
374
375 if (USE_GL2PS)
376 add_definitions (-DHAVE_GL2PS)
377 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
378 else()
379 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
380 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
381 endif()
9f33b387 382else()
5682a6fa 383 OCCT_CHECK_AND_UNSET ("USE_GL2PS")
384
9f33b387 385 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
386 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
387endif()
03c69aec 388
9f33b387 389# TBB
5682a6fa 390# search for CSF_TBB variable in EXTERNLIB of each being used toolkit
391OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
392
393if (NOT DEFINED ANDROID AND CAN_USE_TBB)
394 set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
395
396 if (USE_TBB)
397 add_definitions (-DHAVE_TBB)
398 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
399 else()
400 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
401 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
402 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
403 endif()
9f33b387 404else()
5682a6fa 405 OCCT_CHECK_AND_UNSET ("USE_TBB")
406
9f33b387 407 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
408 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
409 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
410endif()
234e52be 411
adc33035 412# Doxygen
316d77d9 413if (BUILD_DOC_OcctOverview)
414 if (NOT DEFINED INSTALL_DOC_OcctOverview)
415 set (INSTALL_DOC_OcctOverview OFF CACHE BOOL "${INSTALL_DOC_OcctOverview_DESCR}")
adc33035 416 endif()
417
316d77d9 418 if (INSTALL_DOC_OcctOverview)
096ef695 419 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_SHARE_DIR}/doc")
f2e9c853 420
096ef695 421 # create overview.html only for windows
422 if (WIN32)
423 OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_SCRIPT_DIR}")
424 endif()
adc33035 425 endif()
426
427 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
428else()
316d77d9 429 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_OcctOverview")
adc33035 430
431 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
109aa56e 432 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
adc33035 433endif()
434
316d77d9 435# bison
109aa56e 436if (BUILD_YACCLEX)
316d77d9 437 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
438else()
439 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
440endif()
441
442# flex
109aa56e 443if (BUILD_YACCLEX)
316d77d9 444 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
445else()
446 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
447endif()
448
9f33b387 449string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 450
9f33b387 451# check all 3rdparty paths
452if (3RDPARTY_NOT_INCLUDED)
453 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
454endif()
7c633a3e 455
9bb81d6c 456if (3RDPARTY_INCLUDE_DIRS)
457 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
458 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
a6874708 459 message (STATUS "Info: The directories of 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
9bb81d6c 460 include_directories (${3RDPARTY_INCLUDE_DIRS})
461endif()
462
94829f84 463# include <cmake binary folder>/inc
464include_directories (${CMAKE_BINARY_DIR}/inc)
465
9bb81d6c 466if (3RDPARTY_LIBRARY_DIRS)
467 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
468 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
a6874708 469 message (STATUS "Info: The directories of 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
9bb81d6c 470 link_directories (${3RDPARTY_LIBRARY_DIRS})
471endif()
234e52be 472
9f33b387 473# build directories
fa0cbe55 474set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
475set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
476set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 477
316d77d9 478set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
479set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
480set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 481
fa0cbe55 482set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
483set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
484set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 485
fa0cbe55 486if (WIN32)
f2e9c853 487 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
488 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
489 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 490endif()
03c69aec 491
d94d80e5 492string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
493message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
94829f84 494
94829f84 495# collect all the headers to <binary dir>/inc folder
f2e9c853 496COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
94829f84 497
d94d80e5 498string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
499message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
500
096ef695 501OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_SHARE_DIR}")
03c69aec 502
096ef695 503# OCCT samples
0e617b05 504if (INSTALL_SAMPLES)
096ef695 505 if (WIN32)
506 OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_SHARE_DIR}/samples")
507 OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_SHARE_DIR}/samples")
508 endif()
509
510 OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_SHARE_DIR}/samples")
511 OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_SHARE_DIR}/samples")
512 OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_SHARE_DIR}/samples")
910970ab 513endif()
03c69aec 514
096ef695 515OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_SHARE_DIR}/samples")
516
0e617b05 517if (INSTALL_TEST_CASES)
096ef695 518 OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_SHARE_DIR}")
910970ab 519endif()
03c69aec 520
910970ab 521if (WIN32)
522 set (SCRIPT_EXT bat)
523else()
524 set (SCRIPT_EXT sh)
525endif()
03c69aec 526
096ef695 527# copy draw script to install script folder
109aa56e 528if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
096ef695 529 install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_SCRIPT_DIR}"
530 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
910970ab 531else()
096ef695 532 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_SCRIPT_DIR}"
533 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
910970ab 534endif()
096ef695 535
536# copy draw script to CMake binary folder
910970ab 537OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
9f33b387 538
316d77d9 539set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 540
910970ab 541if (WIN32)
316d77d9 542 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %VCVER% %ARCH% %CASDEB% \n)")
910970ab 543else()
096ef695 544 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
910970ab 545endif()
32856b63 546
910970ab 547 # change custom.bat/sh
096ef695 548if (EXISTS "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}")
549 file (READ "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 550
910970ab 551 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 552
096ef695 553 file (WRITE "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
910970ab 554else()
096ef695 555 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_SCRIPT_DIR}")
910970ab 556endif()
32856b63 557
316d77d9 558# write current custom.bat/sh (for install directory)
559set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
096ef695 560OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_SCRIPT_DIR}")
03c69aec 561
316d77d9 562# write current custom.bat/sh (for build directory)
563OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
564
565if (BUILD_MODULE_OcctMfcSamples)
096ef695 566 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_SCRIPT_DIR}")
f2e9c853 567 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
9f33b387 568endif()
569
316d77d9 570# env script for draw in building environment
910970ab 571OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
316d77d9 572
573# end script for draw in standalone environment
096ef695 574if (UNIX)
575 OCCT_CONFIGURE ("adm/templates/env.install.sh.in" "env.install.sh")
576 install (FILES "${CMAKE_BINARY_DIR}/env.install.sh" DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.sh")
577else()
578 # release version
579 set (CURRENT_BUILD_LETTER "")
580 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.release.bat")
581 install (FILES "${CMAKE_BINARY_DIR}/env.install.release.bat"
582 CONFIGURATIONS Release
583 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
584
585 # debug version
586 set (CURRENT_BUILD_LETTER "d")
587 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.debug.bat")
588 install (FILES "${CMAKE_BINARY_DIR}/env.install.debug.bat"
589 CONFIGURATIONS Debug
590 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
591
592 # release with debug info version
593 set (CURRENT_BUILD_LETTER "i")
594 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.relwithdebinfo.bat")
595 install (FILES "${CMAKE_BINARY_DIR}/env.install.relwithdebinfo.bat"
596 CONFIGURATIONS RelWithDebInfo
597 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
598endif()
316d77d9 599
600# copy DrawAppliInit from OCCT source to build directory
f2e9c853 601if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
602 OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
316d77d9 603endif()
910970ab 604
9f33b387 605# RESOURCES
19286d7c 606FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
607foreach(RESOURCE ${RESOURCES})
608 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
609 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
610 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
096ef695 611 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_OCCT_RESOURCE_DIR}/${RESOURCE_FOLDER}")
19286d7c 612 else()
096ef695 613 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_OCCT_RESOURCE_DIR}")
19286d7c 614 endif()
615endforeach()
03c69aec 616
fb3267c7 617# define CSF variable
618OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
619
33839ae6 620# include patched toolkit projects or original ones
316d77d9 621foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
f2e9c853 622 OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
19286d7c 623endforeach()
234e52be 624
316d77d9 625if (BUILD_DOC_OcctOverview)
f2e9c853 626 OCCT_ADD_SUBDIRECTORY (dox)
adc33035 627endif()
628
94829f84 629# patch DRAWEXE
630if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 631 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 632 if (${DRAWEXE_INDEX} GREATER -1)
633 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
634 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
635
636 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
637 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
638 endforeach()
639
640 OCCT_MAKE_COMPILER_BITNESS()
641 set (X_COMPILER_BITNESS "x64")
642 if ("${COMPILER_BITNESS}" STREQUAL "32")
643 set (X_COMPILER_BITNESS "Win32")
644 endif()
645
f2e9c853 646 OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
94829f84 647 endif()
648endif()
649
33839ae6 650# samples do not support patch usage
316d77d9 651if (BUILD_MODULE_OcctMfcSamples)
19286d7c 652 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
234e52be 653
19286d7c 654 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
655 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 656
9f33b387 657 add_subdirectory(samples/mfc/standard/mfcsample)
658 add_subdirectory(samples/mfc/standard/01_Geometry)
659 add_subdirectory(samples/mfc/standard/02_Modeling)
660 add_subdirectory(samples/mfc/standard/03_Viewer2d)
661 add_subdirectory(samples/mfc/standard/04_Viewer3d)
662 add_subdirectory(samples/mfc/standard/05_ImportExport)
663 add_subdirectory(samples/mfc/standard/06_Ocaf)
664 add_subdirectory(samples/mfc/standard/07_Triangulation)
665 add_subdirectory(samples/mfc/standard/08_HLR)
666 add_subdirectory(samples/mfc/standard/09_Animation)
667 add_subdirectory(samples/mfc/standard/10_Convert)
19286d7c 668endif()