0027802: [Regression to 7.0] Solid classifier raises exception ConstructionError
[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)
46bd680a 27
28 if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX)
29 set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE)
30 endif()
c259930b 31else()
32 unset (BUILD_SHARED_LIBS)
3321f684 33 message (STATUS "Info: Only 3rdparty's header files are used for building of static OCCT libraries")
46bd680a 34 unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX)
c259930b 35endif()
36
9f33b387 37# the name of the project
38project (OCCT)
03c69aec 39
096ef695 40# include occt macros
41OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
42
9f33b387 43# Solution folder property
44set_property (GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 45
096ef695 46# get current OCCT version
47OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
48
49set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
50set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
51set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
52
0e617b05 53set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
096ef695 54
ee5befae 55# Regeneration of OCCT resource files
56set (BUILD_RESOURCES OFF CACHE BOOL "${BUILD_RESOURCES_DESCR}")
57
096ef695 58# single-configuration generator
59set (SINGLE_GENERATOR OFF)
60if (CMAKE_BUILD_TYPE)
61 set (SINGLE_GENERATOR ON)
62endif()
63
316d77d9 64# a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable
65# check this variable and set if it's required
66if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator.
67 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 68endif()
69
898f6a92 70# enable extended messages of many OCCT algorithms
742cc8b0 71if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore"))
e13e5f39 72 if (NOT BUILD_WITH_DEBUG)
73 set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
74 endif()
75else()
76 OCCT_CHECK_AND_UNSET (BUILD_WITH_DEBUG)
77endif()
78
109aa56e 79if (BUILD_WITH_DEBUG)
e13e5f39 80 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:DEBUG>:OCCT_DEBUG>)
898f6a92 81endif()
316d77d9 82
19286d7c 83# copy samples to install directory
0e617b05 84set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}")
19286d7c 85
096ef695 86# install dir of the project
87if (NOT DEFINED INSTALL_DIR)
4b3541c6 88 # set default install directory for Windows
84258256 89 if (WIN32 AND NOT DEFINED CMAKE_INSTALL_PREFIX)
4b3541c6 90 set (CMAKE_INSTALL_PREFIX "C:/opencascade-${OCC_VERSION_STRING_EXT}")
91 endif()
096ef695 92 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
84258256 93else()
1d505bb0 94 file (TO_CMAKE_PATH "${INSTALL_DIR}" INSTALL_DIR)
84258256 95 set (INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
096ef695 96endif()
97
4b3541c6 98# choose a variant of the layout of the install paths
99if (NOT INSTALL_DIR_LAYOUT)
100 if (WIN32)
101 set (INSTALL_DIR_LAYOUT "Windows" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
102 else()
103 set (INSTALL_DIR_LAYOUT "Unix" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
104 endif()
105 SET_PROPERTY(CACHE INSTALL_DIR_LAYOUT PROPERTY STRINGS Windows Unix)
106endif()
107
108# check INSTALL_DIR_LAYOUT changes and update INSTALL_DIR_* paths if necessary
109if (NOT DEFINED INSTALL_DIR_LAYOUT_PREV)
110 set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
111elseif (NOT "${INSTALL_DIR_LAYOUT_PREV}" STREQUAL "${INSTALL_DIR_LAYOUT}")
112 set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
113 # The structure of install folder should be reset due to changed layout
114 OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
115
116 # Unset INSTALL_DIR_WITH_VERSION on windows
117 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
118 OCCT_CHECK_AND_UNSET (INSTALL_DIR_WITH_VERSION)
119 else()
120 if (NOT DEFINED INSTALL_DIR_WITH_VERSION)
121 set (INSTALL_DIR_WITH_VERSION OFF CACHE BOOL "${INSTALL_DIR_WITH_VERSION_DESCR}")
122 endif()
123 endif()
124endif()
125
126# check CMAKE_INSTALL_PREFIX changes and update INSTALL_DIR if necessary
d573adcf 127if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
128 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
129elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
130 # CMAKE_INSTALL_PREFIX has been changed at previous step
131 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
132
133 # INSTALL_DIR is required to be updated
134 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
135endif()
136
4b3541c6 137# check INSTALL_DIR changes and update CMAKE_INSTALL_PREFIX if necessary
d573adcf 138if (NOT DEFINED INSTALL_DIR_PREV)
139 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
140elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
141 # INSTALL_DIR has been changed at previous step
142 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
143
144 # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
145 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
146
147 # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
148 set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
4b3541c6 149endif()
d573adcf 150
4b3541c6 151if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
152 if (NOT DEFINED INSTALL_DIR_WITH_VERSION_PREV)
153 set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
154 elseif (NOT "${INSTALL_DIR_WITH_VERSION_PREV}" STREQUAL "${INSTALL_DIR_WITH_VERSION}")
155 # INSTALL_DIR_WITH_VERSION has been changed at previous step
156 set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
157
158 OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
159 endif()
096ef695 160endif()
161
162# hide CMAKE_INSTALL_PREFIX from a user
163set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
164
165set (BIN_LETTER "")
166if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
167 set (BIN_LETTER "d")
168elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
169 set (BIN_LETTER "i")
170endif()
03c69aec 171
096ef695 172# Get all used variables: OS_WITH_BIT, COMPILER
173OCCT_MAKE_OS_WITH_BITNESS()
174OCCT_MAKE_COMPILER_SHORT_NAME()
175
4b3541c6 176# do not define INSTALL_DIR_BIN for win.
096ef695 177# Leave library structure for win: <prefix>/win64/vc10/bin(d)
4b3541c6 178if (NOT DEFINED INSTALL_DIR_BIN)
179 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
180 set (INSTALL_DIR_BIN "bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
096ef695 181 else()
4b3541c6 182 set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
096ef695 183 endif()
184endif()
185
186# define folder contaning all shell/batch scripts
4b3541c6 187if (NOT DEFINED INSTALL_DIR_SCRIPT)
188 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
189 set (INSTALL_DIR_SCRIPT "${INSTALL_DIR_BIN}" CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
096ef695 190 else()
4b3541c6 191 set (INSTALL_DIR_SCRIPT "." CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
096ef695 192 endif()
193endif()
194
195# place the libraries to <prefix>/lib folder for unix and leave old structure for windows
4b3541c6 196if (NOT DEFINED INSTALL_DIR_LIB)
197 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
198 set (INSTALL_DIR_LIB "lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
096ef695 199 else()
4b3541c6 200 set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
096ef695 201 endif()
202endif()
203
204# OCCT headers: <prefix>/inc for windows,
205# <prefix>/include/opencascade-7.0.0 for unix
4b3541c6 206if (NOT DEFINED INSTALL_DIR_INCLUDE)
207 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
208 set (INSTALL_DIR_INCLUDE "include/opencascade" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
209 if (INSTALL_DIR_WITH_VERSION)
210 set (INSTALL_DIR_INCLUDE "include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}" FORCE)
211 endif()
096ef695 212 else()
4b3541c6 213 set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
096ef695 214 endif()
215endif()
216
217# OCCT resources: <prefix>/src for windows,
218# <prefix>/share/opencascade-7.0.0/resources for unix
4b3541c6 219if (NOT DEFINED INSTALL_DIR_RESOURCE)
220 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
221 set (INSTALL_DIR_RESOURCE "share/opencascade/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
222 if (INSTALL_DIR_WITH_VERSION)
223 set (INSTALL_DIR_RESOURCE "share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}" FORCE)
224 endif()
096ef695 225 else()
4b3541c6 226 set (INSTALL_DIR_RESOURCE "src" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
096ef695 227 endif()
228endif()
229
230# OCCT data
4b3541c6 231if (NOT DEFINED INSTALL_DIR_DATA)
232 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
233 set (INSTALL_DIR_DATA "share/opencascade/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
234 if (INSTALL_DIR_WITH_VERSION)
235 set (INSTALL_DIR_DATA "share/opencascade-${OCC_VERSION_STRING_EXT}/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}" FORCE)
236 endif()
237 else()
238 set (INSTALL_DIR_DATA "data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
239 endif()
240endif()
241
242# OCCT samples
243if (NOT DEFINED INSTALL_DIR_SAMPLES)
244 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
245 set (INSTALL_DIR_SAMPLES "share/opencascade/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
246 if (INSTALL_DIR_WITH_VERSION)
247 set (INSTALL_DIR_SAMPLES "share/opencascade-${OCC_VERSION_STRING_EXT}/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}" FORCE)
248 endif()
249 else()
250 set (INSTALL_DIR_SAMPLES "samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
251 endif()
252endif()
253
254# OCCT tests
255if (NOT DEFINED INSTALL_DIR_TESTS)
256 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
257 set (INSTALL_DIR_TESTS "share/opencascade/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
258 if (INSTALL_DIR_WITH_VERSION)
259 set (INSTALL_DIR_TESTS "share/opencascade-${OCC_VERSION_STRING_EXT}/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}" FORCE)
260 endif()
261 else()
262 set (INSTALL_DIR_TESTS "tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
263 endif()
264endif()
265
266# OCCT doc
267if (NOT DEFINED INSTALL_DIR_DOC)
268 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
269 set (INSTALL_DIR_DOC "share/doc/opencascade" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
270 if (INSTALL_DIR_WITH_VERSION)
271 set (INSTALL_DIR_DOC "share/doc/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_DOC_DESCR}" FORCE)
272 endif()
096ef695 273 else()
4b3541c6 274 set (INSTALL_DIR_DOC "doc" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
096ef695 275 endif()
276endif()
277
2e48c1cb 278# define folder contaning CMake configuration files
279if (NOT DEFINED INSTALL_DIR_CMAKE)
280 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
281 if (INSTALL_DIR_WITH_VERSION)
282 set (INSTALL_DIR_CMAKE "lib/cmake/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
283 else()
284 set (INSTALL_DIR_CMAKE "lib/cmake/opencascade" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
285 endif()
286 else()
ada9ef40 287 set (INSTALL_DIR_CMAKE "cmake" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
2e48c1cb 288 endif()
289endif()
290
ee5befae 291# include occt macros
292OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_resources")
293
4b3541c6 294# install LICENSE_LGPL_21.txt and OCCT_LGPL_EXCEPTION.txt files
295if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
d26375e2 296 OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" "${INSTALL_DIR_DOC}")
297 OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" "${INSTALL_DIR_DOC}")
4b3541c6 298else()
d26375e2 299 OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" ".")
300 OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" ".")
4b3541c6 301endif()
302
09eca2b5 303if(APPLE)
304 set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)")
305endif()
306
096ef695 307# a directory recognized as a 'patch' for OCCT
109aa56e 308set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
03c69aec 309
9f33b387 310# the list of being built toolkits
316d77d9 311set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
312separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 313
ad211ad3 314if (MSVC)
4b3541c6 315 set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}")
85bcc072 316endif()
317
742cc8b0 318# uwp sample
319if (MSVC)
320 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
321 set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}")
322 else()
323 unset (BUILD_MODULE_UwpSample)
324 endif()
325endif()
326
9f33b387 327# whether use optional 3rdparty or not
328if (APPLE)
316d77d9 329 set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
03c69aec 330endif()
096ef695 331
f60111dc 332if (WIN32)
333 set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
334endif()
85bcc072 335
9f33b387 336# include the patched or original list of modules
19286d7c 337# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
338# list <OCCT_MODULES> will contain all modules
339OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
03c69aec 340
316d77d9 341foreach (OCCT_MODULE ${OCCT_MODULES})
342 BUILD_MODULE (${OCCT_MODULE})
19286d7c 343endforeach()
344
e713baee 345if (ANDROID AND BUILD_MODULE_Draw)
346 message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
347 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
348endif()
49e5d238 349if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND BUILD_MODULE_Draw)
350 message (STATUS "Info. Draw module is turned off due to it is not supported on UWP")
351 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
352endif()
e713baee 353
adc33035 354# Overview
9d034c37 355if (NOT DEFINED BUILD_DOC_Overview)
356 set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
357 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
358 set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
359
360 if (CAN_DOXYGEN_BE_USED)
361 message (STATUS "Info. Overview building is turned on")
362 endif()
363
364 set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
365endif()
adc33035 366
f60111dc 367if (NOT USE_D3D)
368 list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost)
369endif()
370
316d77d9 371# accumulate used toolkits (first level) in BUILD_TOOLKITS variable
372list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
19286d7c 373
316d77d9 374foreach (OCCT_MODULE ${OCCT_MODULES})
375 if (BUILD_MODULE_${OCCT_MODULE})
376 list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
19286d7c 377 endif()
378endforeach()
379
380# DRAWEXE excluded when library build is static
381if (NOT BUILD_SHARED_LIBS)
316d77d9 382 list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE)
19286d7c 383 message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
384endif()
385
386# accumulate all used toolkits
316d77d9 387list (REMOVE_DUPLICATES BUILD_TOOLKITS)
388set (RAW_BUILD_TOOLKITS)
096ef695 389foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
316d77d9 390 OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
391 list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
19286d7c 392endforeach()
393
316d77d9 394list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
395set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
03c69aec 396
9f33b387 397# include the patched or original list of definitions and flags
19286d7c 398OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
03c69aec 399
19286d7c 400OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
03c69aec 401
a6874708 402# search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
403list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
404if (CAN_USE_VTK EQUAL -1)
405 list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
406endif()
407
408if (NOT CAN_USE_VTK EQUAL -1)
409 if (NOT DEFINED USE_VTK)
410 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
411 endif()
412else()
413 OCCT_CHECK_AND_UNSET (USE_VTK)
414endif()
415
5682a6fa 416# Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
417list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH)
418list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
419
fb3267c7 420if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
109aa56e 421 set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
5682a6fa 422else()
109aa56e 423 OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
5682a6fa 424endif()
425
9f33b387 426if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 427 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
e713baee 428 get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
84258256 429else()
1d505bb0 430 file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
84258256 431 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE)
9f33b387 432endif()
234e52be 433
9f33b387 434# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
f2e9c853 435OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
03c69aec 436
fb3267c7 437if (USE_TCL)
5682a6fa 438 message (STATUS "Info: TCL is used by OCCT")
19286d7c 439 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
82f443b6 440
441 message (STATUS "Info: TK is used by OCCT")
442 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
9f33b387 443else()
9ccea0c6 444 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
445 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
5682a6fa 446
447 OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
82f443b6 448 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
9f33b387 449endif()
03c69aec 450
9f33b387 451# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
f2e9c853 452OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE)
03c69aec 453
fb3267c7 454if (USE_FREETYPE)
5682a6fa 455 message (STATUS "Info: Freetype is used by OCCT")
19286d7c 456 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
9f33b387 457else()
9ccea0c6 458 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 459 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
460 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
5682a6fa 461 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
9f33b387 462endif()
03c69aec 463
09c597c9 464# VTK
465if (USE_VTK)
466 add_definitions (-DHAVE_VTK)
19286d7c 467 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
f2e9c853 468else()
469 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
a6874708 470
471 if (NOT CAN_USE_VTK EQUAL -1)
472 message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
473
474 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
475 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
476 endif()
09c597c9 477endif()
478
f60111dc 479# D3D
480if (USE_D3D)
481 add_definitions (-DHAVE_D3D)
482 #if(MSVC_VERSION LESS 1700)
483 #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
484 #endif()
485endif()
486
09c597c9 487# GLX
488if (USE_GLX)
489 add_definitions (-DMACOSX_USE_GLX)
19286d7c 490 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
09c597c9 491endif()
492
03c69aec 493# FREEIMAGE
5682a6fa 494# search for CSF_FREEIMAGE variable in EXTERNLIB of each being used toolkit
60273f77 495OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
5682a6fa 496
60273f77 497if (CAN_USE_FREEIMAGE)
5682a6fa 498 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
499
500 if (USE_FREEIMAGE)
501 add_definitions (-DHAVE_FREEIMAGE)
502 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
5682a6fa 503 else()
504 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
5682a6fa 505 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
5682a6fa 506 endif()
9f33b387 507else()
5682a6fa 508 OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
509
9f33b387 510 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
9f33b387 511 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
9f33b387 512endif()
03c69aec 513
1ce0716b 514# OpenGL ES 2.0
515OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_GLES2)
516if (WIN32 AND CAN_USE_GLES2)
517 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
518 set (USE_GLES2 ON)
519 else()
520 set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}")
521 endif()
522
523 if (USE_GLES2)
524 add_definitions (-DHAVE_GLES2)
525 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl")
526 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2")
527 else()
528 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
529 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
530 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
531 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
532 endif()
533else()
534 OCCT_CHECK_AND_UNSET ("USE_GLES2")
535
536 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
537 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
538 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
539 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
540endif()
541
03c69aec 542# GL2PS
5682a6fa 543# search for CSF_GL2PS variable in EXTERNLIB of each being used toolkit
544OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS)
545
546if (NOT DEFINED ANDROID AND CAN_USE_GL2PS)
547 set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
548
549 if (USE_GL2PS)
550 add_definitions (-DHAVE_GL2PS)
551 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
552 else()
553 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
554 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
555 endif()
9f33b387 556else()
5682a6fa 557 OCCT_CHECK_AND_UNSET ("USE_GL2PS")
558
9f33b387 559 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
560 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
561endif()
03c69aec 562
9f33b387 563# TBB
5682a6fa 564# search for CSF_TBB variable in EXTERNLIB of each being used toolkit
565OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
566
567if (NOT DEFINED ANDROID AND CAN_USE_TBB)
568 set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
569
570 if (USE_TBB)
571 add_definitions (-DHAVE_TBB)
572 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
573 else()
574 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
575 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
576 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
577 endif()
9f33b387 578else()
5682a6fa 579 OCCT_CHECK_AND_UNSET ("USE_TBB")
580
9f33b387 581 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
582 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
583 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
584endif()
234e52be 585
adc33035 586# Doxygen
4b3541c6 587if (BUILD_DOC_Overview)
588 if (NOT DEFINED INSTALL_DOC_Overview)
589 set (INSTALL_DOC_Overview OFF CACHE BOOL "${INSTALL_DOC_Overview_DESCR}")
adc33035 590 endif()
591
4b3541c6 592 if (INSTALL_DOC_Overview)
d26375e2 593 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_DIR_DOC}")
f2e9c853 594
096ef695 595 # create overview.html only for windows
4b3541c6 596 if (WIN32 AND "${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
d26375e2 597 OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR_DOC}/..")
096ef695 598 endif()
adc33035 599 endif()
600
601 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
602else()
4b3541c6 603 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_Overview")
adc33035 604
605 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
109aa56e 606 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
adc33035 607endif()
608
316d77d9 609# bison
109aa56e 610if (BUILD_YACCLEX)
316d77d9 611 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
612else()
613 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
614endif()
615
616# flex
109aa56e 617if (BUILD_YACCLEX)
316d77d9 618 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
619else()
620 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
621endif()
622
9f33b387 623string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 624
9f33b387 625# check all 3rdparty paths
626if (3RDPARTY_NOT_INCLUDED)
627 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
628endif()
7c633a3e 629
9bb81d6c 630if (3RDPARTY_INCLUDE_DIRS)
631 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
632 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
ada9ef40 633 message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
9bb81d6c 634 include_directories (${3RDPARTY_INCLUDE_DIRS})
635endif()
636
94829f84 637# include <cmake binary folder>/inc
638include_directories (${CMAKE_BINARY_DIR}/inc)
639
3321f684 640if (3RDPARTY_LIBRARY_DIRS AND BUILD_SHARED_LIBS)
9bb81d6c 641 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
642 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
ada9ef40 643 message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
9bb81d6c 644 link_directories (${3RDPARTY_LIBRARY_DIRS})
645endif()
234e52be 646
9f33b387 647# build directories
4b3541c6 648if (SINGLE_GENERATOR)
649 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
650 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
651 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
652 if (WIN32)
653 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
654 endif()
655endif()
656
fa0cbe55 657set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
658set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
659set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 660
316d77d9 661set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
662set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
663set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 664
fa0cbe55 665set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
666set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
667set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 668
fa0cbe55 669if (WIN32)
f2e9c853 670 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
671 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
672 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 673endif()
03c69aec 674
d94d80e5 675string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
676message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
94829f84 677
94829f84 678# collect all the headers to <binary dir>/inc folder
f2e9c853 679COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
94829f84 680
d94d80e5 681string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
682message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
683
d26375e2 684list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
685if (${DRAWEXE_INDEX} GREATER -1)
686 OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
687 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
688endif()
689
4b3541c6 690if (WIN32)
691 set (SCRIPT_EXT bat)
692else()
693 set (SCRIPT_EXT sh)
694endif()
03c69aec 695
096ef695 696# OCCT samples
d26375e2 697# get absolute path from INSTALL_DIR
698set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}")
699if(NOT IS_ABSOLUTE "${INSTALL_DIR_ABSOLUTE}")
700 get_filename_component(INSTALL_DIR_ABSOLUTE "${CMAKE_BINARY_DIR}/${INSTALL_DIR}" ABSOLUTE)
701endif()
702
0e617b05 703if (INSTALL_SAMPLES)
4b3541c6 704 OCCT_CONFIGURE ("adm/templates/env.samples.${SCRIPT_EXT}.in" "env.samples.${SCRIPT_EXT}")
096ef695 705 if (WIN32)
d26375e2 706 OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR_SAMPLES}")
707 OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR_SAMPLES}")
4b3541c6 708
742cc8b0 709 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
d26375e2 710 OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR_SAMPLES}")
742cc8b0 711 endif()
712
d26375e2 713 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}")
714 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}")
096ef695 715 endif()
03c69aec 716
d26375e2 717 OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR_SAMPLES}")
718 OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR_SAMPLES}")
719 OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR_SAMPLES}")
096ef695 720
d26375e2 721 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}")
722 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}")
723 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}")
910970ab 724endif()
03c69aec 725
4b3541c6 726if (INSTALL_TEST_CASES)
d26375e2 727 OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR_TESTS}")
910970ab 728endif()
03c69aec 729
3eabbe1b 730list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
731if (${DRAWEXE_INDEX} GREATER -1)
732 # copy data and samples/tcl folders to install script folder
d26375e2 733 OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
734 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
096ef695 735
3eabbe1b 736 # copy draw script to install script folder
737 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
d26375e2 738 install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
3eabbe1b 739 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
740 else()
d26375e2 741 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
3eabbe1b 742 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
743 endif()
744
745 # copy draw script to CMake binary folder
746 OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
747endif()
9f33b387 748
316d77d9 749set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 750
910970ab 751if (WIN32)
4b3541c6 752 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %1 %2 %3 \n)")
910970ab 753else()
096ef695 754 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
910970ab 755endif()
32856b63 756
910970ab 757 # change custom.bat/sh
4b3541c6 758if (EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}")
759 file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 760
910970ab 761 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 762
4b3541c6 763 file (WRITE "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
910970ab 764else()
d26375e2 765 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
910970ab 766endif()
32856b63 767
316d77d9 768# write current custom.bat/sh (for install directory)
769set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
d26375e2 770OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}")
03c69aec 771
316d77d9 772# write current custom.bat/sh (for build directory)
773OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
774
4b3541c6 775if (BUILD_MODULE_MfcSamples)
d26375e2 776 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR_SCRIPT}")
f2e9c853 777 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
9f33b387 778endif()
779
316d77d9 780# env script for draw in building environment
4b3541c6 781OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
316d77d9 782
4b3541c6 783# install env script
d26375e2 784install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}")
316d77d9 785
786# copy DrawAppliInit from OCCT source to build directory
f2e9c853 787if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
788 OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
316d77d9 789endif()
910970ab 790
9f33b387 791# RESOURCES
19286d7c 792FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
793foreach(RESOURCE ${RESOURCES})
794 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
795 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
796 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
d26375e2 797 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}")
19286d7c 798 else()
d26375e2 799 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}")
19286d7c 800 endif()
801endforeach()
03c69aec 802
46bd680a 803# patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed
804if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
805 OCCT_UPDATE_DRAW_DEFAULT_FILE()
806endif()
807
fb3267c7 808# define CSF variable
809OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
810
33839ae6 811# include patched toolkit projects or original ones
316d77d9 812foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
f2e9c853 813 OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
19286d7c 814endforeach()
234e52be 815
4b3541c6 816if (BUILD_DOC_Overview)
f2e9c853 817 OCCT_ADD_SUBDIRECTORY (dox)
adc33035 818endif()
819
94829f84 820# patch DRAWEXE
821if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 822 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 823 if (${DRAWEXE_INDEX} GREATER -1)
824 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
825 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
826
827 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
828 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
829 endforeach()
830
831 OCCT_MAKE_COMPILER_BITNESS()
832 set (X_COMPILER_BITNESS "x64")
833 if ("${COMPILER_BITNESS}" STREQUAL "32")
834 set (X_COMPILER_BITNESS "Win32")
835 endif()
836
f2e9c853 837 OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
94829f84 838 endif()
839endif()
840
33839ae6 841# samples do not support patch usage
4b3541c6 842if (BUILD_MODULE_MfcSamples)
19286d7c 843 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
234e52be 844
19286d7c 845 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
846 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 847
9f33b387 848 add_subdirectory(samples/mfc/standard/mfcsample)
849 add_subdirectory(samples/mfc/standard/01_Geometry)
850 add_subdirectory(samples/mfc/standard/02_Modeling)
851 add_subdirectory(samples/mfc/standard/03_Viewer2d)
852 add_subdirectory(samples/mfc/standard/04_Viewer3d)
853 add_subdirectory(samples/mfc/standard/05_ImportExport)
854 add_subdirectory(samples/mfc/standard/06_Ocaf)
855 add_subdirectory(samples/mfc/standard/07_Triangulation)
856 add_subdirectory(samples/mfc/standard/08_HLR)
857 add_subdirectory(samples/mfc/standard/09_Animation)
858 add_subdirectory(samples/mfc/standard/10_Convert)
19286d7c 859endif()
2e48c1cb 860
742cc8b0 861if (BUILD_MODULE_UwpSample)
862 add_subdirectory(samples/xaml)
863endif()
864
2e48c1cb 865# Prepare variables for configuration of OpenCASCADE cmake config file
866set (OCCT_MODULES_ENABLED)
867set (OCCT_LIBRARIES)
ada9ef40 868set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n")
a3d2cb24 869set (OCCT_COMPILE_DEFINITIONS)
870
2e48c1cb 871foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS})
872 if (TARGET ${OCCT_TOOLKIT})
873
874 # get all libraries
875 get_target_property (${OCCT_TOOLKIT}_TYPE ${OCCT_TOOLKIT} "TYPE")
876 if ("${${OCCT_TOOLKIT}_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${${OCCT_TOOLKIT}_TYPE}" STREQUAL "SHARED_LIBRARY" )
877 list (APPEND OCCT_LIBRARIES ${OCCT_TOOLKIT})
2e48c1cb 878
ada9ef40 879 # get all modules
880 get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE")
881 list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE})
882 list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT})
a3d2cb24 883
884 # get compile definitions of target directory
885 get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS")
886 list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS})
2e48c1cb 887 endif()
888 endif()
889endforeach()
890list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED)
a3d2cb24 891list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS)
892
893# export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files
894foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
895 set (SET_OpenCASCADE_COMPILE_DEFINITIONS)
896 string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER)
897 string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER)
898 foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS})
899 string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
900 string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
901 set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${OCCT_CONFIGURATION}>:${COMPILE_DEFINITION}>)\n")
902 endforeach()
903 set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
904 set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
905 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY)
906endforeach()
907# install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration
908install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)")
909install (CODE "configure_file(\"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" COPYONLY)")
2e48c1cb 910
ada9ef40 911foreach (OCCT_MODULE ${OCCT_MODULES})
912 if (BUILD_MODULE_${OCCT_MODULE})
913 set (SET_OpenCASCADE_MODULES_TOOLKITS "${SET_OpenCASCADE_MODULES_TOOLKITS}set (OpenCASCADE_${OCCT_MODULE}_LIBRARIES ${OpenCASCADE_${OCCT_MODULE}_TOOLKITS})\n")
914 endif()
f7ac9097 915
916 # sort enabled modules for correct work of OpenCASCADE config file
917 list(FIND OCCT_MODULES_ENABLED "${OCCT_MODULE}" OCCT_MODULE_INDEX)
918 if (NOT ${OCCT_MODULE_INDEX} EQUAL -1)
919 list (APPEND OCCT_MODULES_ENABLED_SORTED ${OCCT_MODULE})
920 endif()
ada9ef40 921endforeach()
f7ac9097 922set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED})
ada9ef40 923
924# Add all targets to the build-tree export set
925export (TARGETS ${OCCT_LIBRARIES} FILE "${CMAKE_BINARY_DIR}/OpenCASCADETargets.cmake")
926
927# Export the package for use from the build-tree
928# (this registers the build-tree with a global CMake-registry)
929export(PACKAGE OpenCASCADE)
930
2e48c1cb 931if (CMAKE_BUILD_TYPE)
932 set (SET_OpenCASCADE_BUILD_TYPE "set (OpenCASCADE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
933endif()
934
935if (BUILD_SHARED_LIBS)
936 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS}\")")
937else()
938 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_STATIC_LINKER_FLAGS}\")")
939endif()
940
941if (WIN32)
942 set (SET_OpenCASCADE_WITH_D3D "set (OpenCASCADE_WITH_D3D ${USE_D3D})")
943endif()
944if (APPLE)
945 set (SET_OpenCASCADE_WITH_GLX "set (OpenCASCADE_WITH_GLX ${USE_GLX})")
946endif()
947
ada9ef40 948if (NOT SINGLE_GENERATOR)
949 OCCT_INSERT_CODE_FOR_TARGET()
950endif()
951
2e48c1cb 952# Configure and install cmake config file
ada9ef40 953configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADEConfig.cmake.in" "OpenCASCADEConfig.cmake" @ONLY)
d26375e2 954install(FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfig.cmake" DESTINATION "${INSTALL_DIR_CMAKE}")
2e48c1cb 955
956# Configure cmake version file
957include(CMakePackageConfigHelpers)
958write_basic_package_version_file( ${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake
959 VERSION ${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}
960 COMPATIBILITY ExactVersion )
961
962# Install cmake version file
d26375e2 963install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR_CMAKE}")
ada9ef40 964
965# Install the export set for use with the install-tree for each configuration
f7ac9097 966foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED})
967 install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}")
ada9ef40 968endforeach()
969
970# Update generated OpenCASCADETargets-*.cmake files
971# to have correct paths to libraries depending on the configuration
972OCCT_UPDATE_TARGET_FILE ()