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