0030422: Random behaviour of BRepAdaptor_CompCurve
[occt.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
2
3 set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake")
4
5 set (CMAKE_SUPPRESS_REGENERATION TRUE)
6
7 set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
8
9 # macro: include patched file if it exists
10 macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
11   if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake")
12     include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake)
13   else()
14     include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
15   endif()
16 endmacro()
17
18 # include variable description
19 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr")
20
21 # set type of OCCT libraries
22 if (NOT BUILD_LIBRARY_TYPE)
23   set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE)
24   SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
25 endif()
26
27 if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
28   set (BUILD_SHARED_LIBS ON)
29
30   if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX)
31     set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE)
32   endif()
33 else()
34   unset (BUILD_SHARED_LIBS)
35   unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX)
36 endif()
37
38 # the name of the project
39 project (OCCT)
40
41 if (WIN32)
42   add_definitions(-DUNICODE)
43   add_definitions(-D_UNICODE)
44 endif()
45
46 # include occt macros
47 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
48
49 # Solution folder property
50 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
51
52 # get current OCCT version
53 OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
54
55 set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
56 set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
57 set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
58
59 set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
60
61 # Regeneration of OCCT resource files
62 set (BUILD_RESOURCES OFF CACHE BOOL "${BUILD_RESOURCES_DESCR}")
63
64 # single-configuration generator
65 set (SINGLE_GENERATOR OFF)
66 if (DEFINED CMAKE_BUILD_TYPE)
67   set (SINGLE_GENERATOR ON)
68 endif()
69
70 # a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable
71 # check this variable and set if it's required
72 if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator.
73   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)
74 endif()
75
76 # enable extended messages of many OCCT algorithms
77 if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore"))
78   if (NOT BUILD_WITH_DEBUG)
79     set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
80   endif()
81 else()
82   OCCT_CHECK_AND_UNSET (BUILD_WITH_DEBUG)
83 endif()
84
85 if (BUILD_WITH_DEBUG)
86   set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:DEBUG>:OCCT_DEBUG>)
87 endif()
88
89 # option disabling OCCT exceptions in Release builds (No_Exception)
90 if (NOT DEFINED BUILD_RELEASE_DISABLE_EXCEPTIONS)
91   set (BUILD_RELEASE_DISABLE_EXCEPTIONS ON CACHE BOOL "${BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR}")
92 endif()
93
94 if (MSVC)
95   set (BUILD_FORCE_RelWithDebInfo OFF CACHE BOOL "${BUILD_FORCE_RelWithDebInfo_DESCR}")
96 else()
97   set (BUILD_FORCE_RelWithDebInfo OFF)
98 endif()
99
100 if (BUILD_FORCE_RelWithDebInfo)
101   set (CMAKE_CONFIGURATION_TYPES Release Debug CACHE INTERNAL "" FORCE)
102 endif()
103
104 # option to enable or disable use of precompiled headers
105 if (NOT DEFINED BUILD_USE_PCH)
106   set (BUILD_USE_PCH OFF CACHE BOOL "${BUILD_USE_PCH_DESCR}")
107 endif()
108
109 if (BUILD_USE_PCH)
110
111   # Load Cotire tool for accelerating build procedure
112   include(cotire)
113
114   # Set Cotire to ignore lxx, pxx, gxx
115   set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "lxx;pxx;gxx" CACHE STRING "Set Cotire to ignore OCCT specific files that can be #included" FORCE)
116
117   # Set priority for inclusion of system headers in PCH to reduce problems
118   # due to incomplete inclusion or wrong order.
119   if (WIN32)
120     # on Windows, assume that SDK (windows.h) is in default location
121     set(ProgramFilesX86 "ProgramFiles(x86)")
122     file(TO_CMAKE_PATH "$ENV{${ProgramFilesX86}}" ProgramFilesX86)
123     set_property (DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "${ProgramFilesX86}")
124     unset(ProgramFilesX86)
125   endif()
126
127 endif()
128
129 # copy samples to install directory
130 set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}")
131
132 # install dir of the project
133 if (NOT DEFINED INSTALL_DIR)
134   # set default install directory for Windows
135   if (WIN32 AND NOT DEFINED CMAKE_INSTALL_PREFIX)
136     set (CMAKE_INSTALL_PREFIX "C:/opencascade-${OCC_VERSION_STRING_EXT}")
137   endif()
138   set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
139 else()
140   file (TO_CMAKE_PATH "${INSTALL_DIR}" INSTALL_DIR)
141   set (INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
142 endif()
143
144 # choose a variant of the layout of the install paths
145 if (NOT INSTALL_DIR_LAYOUT)
146   if (WIN32)
147     set (INSTALL_DIR_LAYOUT "Windows" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
148   else()
149     set (INSTALL_DIR_LAYOUT "Unix" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
150   endif()
151   SET_PROPERTY(CACHE INSTALL_DIR_LAYOUT PROPERTY STRINGS Windows Unix)
152 endif()
153
154 # check INSTALL_DIR_LAYOUT changes and update INSTALL_DIR_* paths if necessary
155 if (NOT DEFINED INSTALL_DIR_LAYOUT_PREV)
156   set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
157 elseif (NOT "${INSTALL_DIR_LAYOUT_PREV}" STREQUAL "${INSTALL_DIR_LAYOUT}")
158   set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
159   # The structure of install folder should be reset due to changed layout
160   OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
161
162   # Unset INSTALL_DIR_WITH_VERSION on windows
163   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
164     OCCT_CHECK_AND_UNSET (INSTALL_DIR_WITH_VERSION)
165   else()
166     if (NOT DEFINED INSTALL_DIR_WITH_VERSION)
167       set (INSTALL_DIR_WITH_VERSION OFF CACHE BOOL "${INSTALL_DIR_WITH_VERSION_DESCR}")
168     endif()
169   endif()
170 endif()
171
172 # check CMAKE_INSTALL_PREFIX changes and update INSTALL_DIR if necessary
173 if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
174   set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
175 elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
176   # CMAKE_INSTALL_PREFIX has been changed at previous step
177   set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
178
179   # INSTALL_DIR is required to be updated
180   set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
181 endif()
182
183 # check INSTALL_DIR changes and update CMAKE_INSTALL_PREFIX if necessary
184 if (NOT DEFINED INSTALL_DIR_PREV)
185   set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
186 elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
187   # INSTALL_DIR has been changed at previous step
188   set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
189
190   # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
191   set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
192
193   # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
194   set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
195 endif()
196
197 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
198   if (NOT DEFINED INSTALL_DIR_WITH_VERSION_PREV)
199     set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
200   elseif (NOT "${INSTALL_DIR_WITH_VERSION_PREV}" STREQUAL "${INSTALL_DIR_WITH_VERSION}")
201     # INSTALL_DIR_WITH_VERSION has been changed at previous step
202     set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
203
204     OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
205   endif()
206 endif()
207
208 # hide CMAKE_INSTALL_PREFIX from a user
209 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
210
211 set (BIN_LETTER "")
212 if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
213   set (BIN_LETTER "d")
214 elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
215   set (BIN_LETTER "i")
216 endif()
217
218 # Get all used variables: OS_WITH_BIT, COMPILER
219 OCCT_MAKE_OS_WITH_BITNESS()
220 OCCT_MAKE_COMPILER_SHORT_NAME()
221
222 # do not define INSTALL_DIR_BIN for win.
223 # Leave library structure for win: <prefix>/win64/vc10/bin(d)
224 if (NOT DEFINED INSTALL_DIR_BIN)
225   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
226     set (INSTALL_DIR_BIN "bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
227   else()
228     set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
229   endif()
230 endif()
231
232 # define folder containing all shell/batch scripts
233 if (NOT DEFINED INSTALL_DIR_SCRIPT)
234   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
235     set (INSTALL_DIR_SCRIPT "${INSTALL_DIR_BIN}" CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
236   else()
237     set (INSTALL_DIR_SCRIPT "." CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
238   endif()
239 endif()
240
241 # place the libraries to <prefix>/lib folder for unix and leave old structure for windows
242 if (NOT DEFINED INSTALL_DIR_LIB)
243   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
244     set (INSTALL_DIR_LIB "lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
245   else()
246     set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
247   endif()
248 endif()
249
250 # OCCT headers: <prefix>/inc for windows,
251 #               <prefix>/include/opencascade-7.0.0 for unix
252 if (NOT DEFINED INSTALL_DIR_INCLUDE)
253   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
254     set (INSTALL_DIR_INCLUDE "include/opencascade" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
255     if (INSTALL_DIR_WITH_VERSION)
256       set (INSTALL_DIR_INCLUDE "include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}" FORCE)
257     endif()
258   else()
259     set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
260   endif()
261 endif()
262
263 # OCCT resources: <prefix>/src for windows,
264 #                 <prefix>/share/opencascade-7.0.0/resources for unix
265 if (NOT DEFINED INSTALL_DIR_RESOURCE)
266   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
267     set (INSTALL_DIR_RESOURCE "share/opencascade/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
268     if (INSTALL_DIR_WITH_VERSION)
269       set (INSTALL_DIR_RESOURCE "share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}" FORCE)
270     endif()
271   else()
272     set (INSTALL_DIR_RESOURCE "src" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
273   endif()
274 endif()
275
276 # OCCT data
277 if (NOT DEFINED INSTALL_DIR_DATA)
278   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
279     set (INSTALL_DIR_DATA "share/opencascade/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
280     if (INSTALL_DIR_WITH_VERSION)
281       set (INSTALL_DIR_DATA "share/opencascade-${OCC_VERSION_STRING_EXT}/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}" FORCE)
282     endif()
283   else()
284     set (INSTALL_DIR_DATA "data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
285   endif()
286 endif()
287
288 # OCCT samples
289 if (NOT DEFINED INSTALL_DIR_SAMPLES)
290   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
291     set (INSTALL_DIR_SAMPLES "share/opencascade/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
292     if (INSTALL_DIR_WITH_VERSION)
293       set (INSTALL_DIR_SAMPLES "share/opencascade-${OCC_VERSION_STRING_EXT}/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}" FORCE)
294     endif()
295   else()
296     set (INSTALL_DIR_SAMPLES "samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
297   endif()
298 endif()
299
300 # OCCT tests
301 if (NOT DEFINED INSTALL_DIR_TESTS)
302   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
303     set (INSTALL_DIR_TESTS "share/opencascade/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
304     if (INSTALL_DIR_WITH_VERSION)
305       set (INSTALL_DIR_TESTS "share/opencascade-${OCC_VERSION_STRING_EXT}/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}" FORCE)
306     endif()
307   else()
308     set (INSTALL_DIR_TESTS "tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
309   endif()
310 endif()
311
312 # OCCT doc
313 if (NOT DEFINED INSTALL_DIR_DOC)
314   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
315     set (INSTALL_DIR_DOC "share/doc/opencascade" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
316     if (INSTALL_DIR_WITH_VERSION)
317       set (INSTALL_DIR_DOC "share/doc/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_DOC_DESCR}" FORCE)
318     endif()
319   else()
320     set (INSTALL_DIR_DOC "doc" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
321   endif()
322 endif()
323
324 # define folder containing CMake configuration files
325 if (NOT DEFINED INSTALL_DIR_CMAKE)
326   if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
327     if (INSTALL_DIR_WITH_VERSION)
328       set (INSTALL_DIR_CMAKE "lib/cmake/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
329     else()
330       set (INSTALL_DIR_CMAKE "lib/cmake/opencascade" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
331     endif()
332   else()
333     set (INSTALL_DIR_CMAKE "cmake" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
334   endif()
335 endif()
336
337 # include occt macros
338 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_resources")
339
340 # install LICENSE_LGPL_21.txt and OCCT_LGPL_EXCEPTION.txt files
341 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
342   OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" "${INSTALL_DIR_DOC}")
343   OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" "${INSTALL_DIR_DOC}")
344 else()
345   OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" ".")
346   OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" ".")
347 endif()
348
349 if(APPLE)
350   set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)")
351 endif()
352
353 # a directory recognized as a 'patch' for OCCT
354 set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
355
356 # the list of being built toolkits
357 set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
358 separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
359
360 if (MSVC)
361   set (BUILD_SAMPLES_MFC OFF CACHE BOOL "${BUILD_SAMPLES_MFC_DESCR}")
362 endif()
363 set (BUILD_SAMPLES_QT OFF CACHE BOOL "${BUILD_SAMPLES_QT_DESCR}")
364
365 set (BUILD_Inspector OFF CACHE BOOL "${BUILD_Inspector_DESCR}")
366
367 # uwp sample
368 if (MSVC)
369   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
370     set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}")
371   else()
372     unset (BUILD_MODULE_UwpSample)
373   endif()
374 endif()
375
376 # whether use optional 3rdparty or not
377 set (USE_TK        ON  CACHE BOOL "${USE_TK_DESCR}")
378 set (USE_FREETYPE  ON  CACHE BOOL "${USE_FREETYPE_DESCR}")
379 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
380 set (USE_FFMPEG    OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
381 set (USE_OPENVR    OFF CACHE BOOL "${USE_OPENVR_DESCR}")
382 set (USE_RAPIDJSON OFF CACHE BOOL "${USE_RAPIDJSON_DESCR}")
383 set (USE_DRACO     OFF CACHE BOOL "${USE_DRACO_DESCR}")
384 set (USE_TBB       OFF CACHE BOOL "${USE_TBB_DESCR}")
385 set (USE_EIGEN     OFF CACHE BOOL "${USE_EIGEN_DESCR}")
386
387 if (WIN32 OR ANDROID OR IOS OR EMSCRIPTEN)
388   # no Xlib
389 elseif (APPLE)
390   set (USE_XLIB OFF CACHE BOOL "${USE_XLIB_DESCR}")
391 else()
392   set (USE_XLIB ON  CACHE BOOL "${USE_XLIB_DESCR}")
393 endif()
394
395 if (WIN32)
396   set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
397 else()
398   set (USE_D3D OFF)
399 endif()
400
401 # Enable/Disable the floating point exceptions (FPE) during runtime.
402 if (NOT BUILD_ENABLE_FPE_SIGNAL_HANDLER)
403   set (BUILD_ENABLE_FPE_SIGNAL_HANDLER OFF CACHE BOOL "${BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR}" FORCE)
404 endif()
405
406 if (BUILD_ENABLE_FPE_SIGNAL_HANDLER)
407   set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 1)
408 else()
409   set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 0)
410 endif()
411
412 # OpenGL
413 if (ANDROID OR IOS OR EMSCRIPTEN OR "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
414   set (USE_OPENGL OFF)
415   set (USE_GLES2 ON)
416 else()
417   set (USE_OPENGL ON CACHE BOOL "${USE_OPENGL_DESCR}")
418   set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}")
419 endif()
420
421 # include the patched or original list of modules
422 # list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
423 # list <OCCT_MODULES> will contain all modules
424 OCCT_MODULES_AND_TOOLKITS (MODULES "TOOLKITS" OCCT_MODULES)
425
426 foreach (OCCT_MODULE ${OCCT_MODULES})
427   BUILD_MODULE (${OCCT_MODULE})
428 endforeach()
429
430 if (ANDROID AND BUILD_MODULE_Draw)
431   message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
432   set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
433 endif()
434 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND BUILD_MODULE_Draw)
435   message (STATUS "Info. Draw module is turned off due to it is not supported on UWP")
436   set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
437 endif()
438
439 # Overview
440 if (NOT DEFINED BUILD_DOC_Overview)
441   set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
442   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
443   set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
444
445   if (CAN_DOXYGEN_BE_USED)
446     message (STATUS "Info. Overview building is turned on")
447   endif()
448
449   set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
450 endif()
451
452 # accumulate used toolkits (first level) in BUILD_TOOLKITS variable
453 list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
454
455 foreach (OCCT_MODULE ${OCCT_MODULES})
456   if (BUILD_MODULE_${OCCT_MODULE})
457     list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
458   endif()
459 endforeach()
460
461 # accumulate all used toolkits
462 list (REMOVE_DUPLICATES BUILD_TOOLKITS)
463 set (RAW_BUILD_TOOLKITS)
464 foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
465   OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
466   list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
467 endforeach()
468
469 list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
470 set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
471
472 # include the patched or original list of definitions and flags
473 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
474
475 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
476
477 # search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
478 list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
479 if (CAN_USE_VTK EQUAL -1)
480   list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
481 endif()
482
483 if (NOT CAN_USE_VTK EQUAL -1)
484   if (NOT DEFINED USE_VTK)
485     set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
486   endif()
487 else()
488   OCCT_CHECK_AND_UNSET (USE_VTK)
489 endif()
490
491 # Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
492 list (FIND BUILD_TOOLKITS TKMath   CAN_REBUILD_PDC_FOR_TKMATH)
493 list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
494
495 if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
496   set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
497 else()
498   OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
499 endif()
500
501 if (NOT DEFINED 3RDPARTY_DIR)
502   set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
503   get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
504 else()
505   file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
506   set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE)
507 endif()
508
509 # search for CSF variable in EXTERNLIB of each being used toolkit
510 OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
511 OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
512 OCCT_IS_PRODUCT_REQUIRED (CSF_TclTkLibs CAN_USE_TK)
513 OCCT_IS_PRODUCT_REQUIRED (CSF_XwLibs CAN_USE_XLIB)
514 OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE CAN_USE_FREETYPE)
515 OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL)
516 OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2)
517 OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
518 OCCT_IS_PRODUCT_REQUIRED (CSF_EIGEN CAN_USE_EIGEN)
519
520 # define CSF variable
521 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
522
523 # Tcl (mandatory for Draw Harness)
524 if (USE_TCL)
525   message (STATUS "Info: TCL is used by OCCT")
526   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
527 else()
528   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
529   OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
530 endif()
531
532 # Tk (optional for Draw Harness)
533 if (CAN_USE_TK)
534   if (USE_TK)
535     message (STATUS "Info: TK is used by OCCT")
536     add_definitions (-DHAVE_TK)
537     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
538   else()
539     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
540     OCCT_CHECK_AND_UNSET ("INSTALL_TK")
541   endif()
542 else()
543   OCCT_CHECK_AND_UNSET ("USE_TK")
544   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
545   OCCT_CHECK_AND_UNSET ("INSTALL_TK")
546 endif()
547
548 # Xlib
549 if (CAN_USE_XLIB)
550   if (USE_XLIB)
551     message (STATUS "Info: Xlib is used by OCCT")
552     add_definitions (-DHAVE_XLIB)
553     if (APPLE)
554       OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
555     endif()
556   endif()
557 else()
558   OCCT_CHECK_AND_UNSET ("USE_XLIB")
559 endif()
560
561 # FreeType
562 if (CAN_USE_FREETYPE)
563   if (USE_FREETYPE)
564     message (STATUS "Info: FreeType is used by OCCT")
565     add_definitions (-DHAVE_FREETYPE)
566     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
567   else()
568     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
569     OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
570     OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
571     OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
572   endif()
573 else()
574   OCCT_CHECK_AND_UNSET ("USE_FREETYPE")
575   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
576   OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
577 endif()
578
579 # VTK
580 if (USE_VTK)
581   add_definitions (-DHAVE_VTK)
582   set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE)
583   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
584 else()
585   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
586
587   if (NOT CAN_USE_VTK EQUAL -1)
588     message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
589
590     list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
591     list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
592   endif()
593 endif()
594
595 # FREEIMAGE
596 if (CAN_USE_FREEIMAGE)
597   if (USE_FREEIMAGE)
598     add_definitions (-DHAVE_FREEIMAGE)
599     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
600   else()
601     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
602     OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
603   endif()
604 else()
605   OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
606
607   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
608   OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
609 endif()
610
611 # OpenVR
612 # search for CSF_OpenVR variable in EXTERNLIB of each being used toolkit
613 OCCT_IS_PRODUCT_REQUIRED (CSF_OpenVR CAN_USE_OPENVR)
614 if (CAN_USE_OPENVR)
615   if (USE_OPENVR)
616     add_definitions (-DHAVE_OPENVR)
617     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/openvr")
618   else()
619     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
620     OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
621   endif()
622 else()
623   OCCT_CHECK_AND_UNSET ("USE_OPENVR")
624
625   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
626   OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
627 endif()
628
629 # FFmpeg
630 # search for CSF_FFmpeg variable in EXTERNLIB of each being used toolkit
631 OCCT_IS_PRODUCT_REQUIRED (CSF_FFmpeg CAN_USE_FFMPEG)
632
633 if (CAN_USE_FFMPEG)
634   if (USE_FFMPEG)
635     add_definitions (-DHAVE_FFMPEG)
636     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/ffmpeg")
637   else()
638     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG")
639     OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG")
640   endif()
641 else()
642   OCCT_CHECK_AND_UNSET ("USE_FFMPEG")
643
644   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG")
645   OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG")
646 endif()
647
648 # OpenGL
649 if (CAN_USE_OPENGL)
650   if (USE_OPENGL)
651     add_definitions (-DHAVE_OPENGL_EXT)
652   else()
653     list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGl)
654     list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGlTest)
655   endif()
656 else()
657   OCCT_CHECK_AND_UNSET ("USE_OPENGL")
658 endif()
659
660 # OpenGL ES 2.0
661 if (CAN_USE_GLES2)
662   if (USE_GLES2)
663     add_definitions (-DHAVE_GLES2_EXT)
664     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl")
665     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2")
666   else()
667     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
668     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
669     OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
670     OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
671     list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGles)
672     list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGlesTest)
673   endif()
674 else()
675   OCCT_CHECK_AND_UNSET ("USE_GLES2")
676
677   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
678   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
679   OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
680   OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
681 endif()
682
683 # D3D
684 if (USE_D3D)
685   add_definitions (-DHAVE_D3D)
686   #if(MSVC_VERSION LESS 1700)
687   #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
688   #endif()
689 else()
690   list (REMOVE_ITEM BUILD_TOOLKITS TKD3DHost)
691   list (REMOVE_ITEM BUILD_TOOLKITS TKD3DHostTest)
692 endif()
693
694 # TBB
695 if (NOT DEFINED ANDROID AND CAN_USE_TBB)
696   if (USE_TBB)
697     add_definitions (-DHAVE_TBB)
698     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
699   else()
700     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
701     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
702     OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
703   endif()
704 else()
705   OCCT_CHECK_AND_UNSET ("USE_TBB")
706
707   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
708   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
709   OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
710 endif()
711
712 # RapidJSON
713 # search for CSF_RapidJSON variable in EXTERNLIB of each being used toolkit
714 OCCT_IS_PRODUCT_REQUIRED (CSF_RapidJSON CAN_USE_RAPIDJSON)
715 if (CAN_USE_RAPIDJSON)
716   if (USE_RAPIDJSON)
717     add_definitions (-DHAVE_RAPIDJSON)
718     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/rapidjson")
719   else()
720     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
721     OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
722   endif()
723 else()
724   OCCT_CHECK_AND_UNSET ("USE_RAPIDJSON")
725
726   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
727   OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
728 endif()
729
730 # Draco library
731 # search for CSF_Draco variable in EXTERNLIB of each being used toolkit
732 OCCT_IS_PRODUCT_REQUIRED (CSF_Draco CAN_USE_DRACO)
733 if (CAN_USE_DRACO)
734   if (USE_DRACO)
735     add_definitions (-DHAVE_DRACO)
736     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/draco")
737   else()
738     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_DRACO")
739     OCCT_CHECK_AND_UNSET ("INSTALL_DRACO")
740   endif()
741 else()
742   OCCT_CHECK_AND_UNSET ("USE_DRACO")
743
744   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_DRACO")
745   OCCT_CHECK_AND_UNSET ("INSTALL_DRACO")
746 endif()
747
748 # EIGEN
749 if (CAN_USE_EIGEN)
750   if (USE_EIGEN)
751     add_definitions (-DHAVE_EIGEN)
752     OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/eigen")
753   else()
754     OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN")
755     OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN")
756   endif()
757 else()
758   OCCT_CHECK_AND_UNSET ("USE_EIGEN")
759
760   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN")
761   OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN")
762 endif()
763
764 # Doxygen
765 if (BUILD_DOC_Overview)
766   if (NOT DEFINED INSTALL_DOC_Overview)
767     set (INSTALL_DOC_Overview OFF CACHE BOOL "${INSTALL_DOC_Overview_DESCR}")
768   endif()
769
770   if (INSTALL_DOC_Overview)
771     install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION  "${INSTALL_DIR_DOC}")
772
773     # create overview.html only for windows
774     if (WIN32 AND "${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
775       OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR_DOC}/..")
776     endif()
777   endif()
778
779   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
780 else()
781   OCCT_CHECK_AND_UNSET ("INSTALL_DOC_Overview")
782
783   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
784   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
785 endif()
786
787 # bison
788 if (BUILD_YACCLEX)
789   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
790 else()
791   OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
792 endif()
793
794 # flex
795 if (BUILD_YACCLEX)
796   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
797 else()
798   OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
799 endif()
800
801 # qt for inspector and samples
802 if (BUILD_Inspector OR BUILD_SAMPLES_QT)
803   # check qt 3rdparty path
804   add_definitions (-DHAVE_QT)
805   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt")
806   message (STATUS "Info: Qt is used by OCCT")
807 else()
808   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT")
809   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC")
810   OCCT_CHECK_AND_UNSET ("INSTALL_QT")
811 endif()
812
813 # check all 3rdparty include paths
814 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
815 if (3RDPARTY_NOT_INCLUDED)
816   message (FATAL_ERROR "Could not find headers of used third-party products: ${3RDPARTY_NOT_INCLUDED}" )
817 endif()
818
819 if (3RDPARTY_INCLUDE_DIRS)
820   list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
821   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
822   message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
823   include_directories (${3RDPARTY_INCLUDE_DIRS})
824 endif()
825
826 # include <cmake binary folder>/inc
827 include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE})
828
829 # check all 3rdparty library paths
830 string (REGEX REPLACE ";" " " 3RDPARTY_NO_LIBS "${3RDPARTY_NO_LIBS}")
831 if (3RDPARTY_NO_LIBS)
832   if (BUILD_SHARED_LIBS)
833     message (SEND_ERROR "Could not find libraries of used third-party products: ${3RDPARTY_NO_LIBS}" )
834   else()
835     message (WARNING "Could not find libraries of used third-party products: ${3RDPARTY_NO_LIBS}" )
836   endif()
837 endif()
838 if (3RDPARTY_LIBRARY_DIRS)
839   list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
840   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
841   message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
842   link_directories (${3RDPARTY_LIBRARY_DIRS})
843 endif()
844
845 # report not found 3rdparty dll paths
846 string (REGEX REPLACE ";" " " 3RDPARTY_NO_DLLS "${3RDPARTY_NO_DLLS}")
847 if (3RDPARTY_NO_DLLS)
848   message (WARNING "Could not find DLLs of used third-party products: ${3RDPARTY_NO_DLLS}" )
849 endif()
850
851 # build directories
852 if (SINGLE_GENERATOR)
853   set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
854   set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
855   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
856   if (WIN32)
857     set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
858   endif()
859 endif()
860
861 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
862 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
863 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
864
865 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
866 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
867 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
868
869 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
870 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
871 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
872
873 if (WIN32)
874   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE        "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
875   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
876   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG          "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
877 endif()
878
879 string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
880 message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
881
882 # collect all the headers to <binary dir>/inc folder
883 COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CMAKE_SOURCE_DIR}/src" "${INSTALL_DIR_INCLUDE}")
884
885 string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
886 message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
887
888 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
889 if (${DRAWEXE_INDEX} GREATER -1)
890   OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
891   OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
892 endif()
893
894 if (WIN32)
895   set (SCRIPT_EXT bat)
896 else()
897   set (SCRIPT_EXT sh)
898 endif()
899
900 # OCCT tools
901 # include the patched or original list of tools
902 # list <TOOLNAME>_TOOLKITS is created foreach tool and contains its toolkits
903 # list <OCCT_TOOLS> will contain all tools
904 if (BUILD_Inspector)
905   add_definitions (-DHAVE_Inspector)
906
907   OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS)
908   foreach (OCCT_TOOL ${OCCT_TOOLS})
909     list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS})
910   endforeach()
911
912   # collect all the headers to <binary dir>/inc/inspector folder
913   string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
914   message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/inc/inspector ...")
915   COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector")
916 endif()
917
918 # OCCT samples
919 # get absolute path from INSTALL_DIR
920 set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}")
921 if(NOT IS_ABSOLUTE "${INSTALL_DIR_ABSOLUTE}")
922   get_filename_component(INSTALL_DIR_ABSOLUTE "${CMAKE_BINARY_DIR}/${INSTALL_DIR}" ABSOLUTE)
923 endif()
924
925 if (INSTALL_SAMPLES)
926   OCCT_CONFIGURE ("adm/templates/env.samples.${SCRIPT_EXT}.in" "env.samples.${SCRIPT_EXT}")
927   if (WIN32)
928     OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR_SAMPLES}")
929     OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR_SAMPLES}")
930
931     if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
932       OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR_SAMPLES}")
933     endif()
934
935     install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}")
936     install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}")
937   endif()
938
939   OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR_SAMPLES}")
940   OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR_SAMPLES}")
941   OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR_SAMPLES}")
942   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code" "${INSTALL_DIR_SAMPLES}/OCCTOverview")
943
944   install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}")
945   install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}")
946   install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/OCCTOverview" RENAME "env.${SCRIPT_EXT}")
947   install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}")
948 endif()
949
950 if (INSTALL_TEST_CASES)
951   OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR_TESTS}")
952 endif()
953
954 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
955 if (${DRAWEXE_INDEX} GREATER -1)
956   # copy data and samples/tcl folders to install script folder
957   OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
958   OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
959
960   # copy draw script to install script folder
961   if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
962     install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
963             PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
964   else()
965     install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
966             PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
967   endif()
968
969   # copy draw script to CMake binary folder
970   OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
971 endif()
972
973 set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
974
975 if (WIN32)
976   set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n  call \"%~dp0${SUB_CUSTOM_NAME}\" %1 %2 %3 \n)")
977 else()
978   set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n  source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
979 endif()
980
981  # change custom.bat/sh
982 if (EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}")
983   file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
984
985   set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
986
987   file (WRITE "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
988 else()
989   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
990 endif()
991
992 if (WIN32)
993   set (THIRDPARTY_DIR_REPLACE "%THIRDPARTY_DIR%")
994 else()
995   set (THIRDPARTY_DIR_REPLACE "\${THIRDPARTY_DIR}")
996 endif()
997 get_cmake_property(USED_3RDPARTY_CACHE_VARIABLES VARIABLES)
998 string (REGEX MATCHALL "(^|;)USED_3RDPARTY_[^;]+_DIR[^;]*" USED_3RDPARTY_CACHE_VARIABLES "${USED_3RDPARTY_CACHE_VARIABLES}")
999 file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
1000 foreach (USED_3RDPARTY_CACHE_VARIABLE ${USED_3RDPARTY_CACHE_VARIABLES})
1001    file (TO_CMAKE_PATH "${${USED_3RDPARTY_CACHE_VARIABLE}}" ${USED_3RDPARTY_CACHE_VARIABLE})
1002    string (REPLACE "${3RDPARTY_DIR}" "${THIRDPARTY_DIR_REPLACE}" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
1003    if (NOT WIN32)
1004      string (REGEX REPLACE ";" ":" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
1005    endif()
1006 endforeach()
1007
1008 # write current custom.bat/sh (for install directory)
1009 set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
1010 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}")
1011
1012 # write current custom.bat/sh (for build directory)
1013 OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
1014
1015 if (BUILD_SAMPLES_MFC OR BUILD_SAMPLES_QT)
1016   OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
1017   OCCT_COPY_FILE_OR_DIR    ("adm/templates/sample.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
1018 endif()
1019
1020 if (WIN32)
1021   # env script for draw in building environment
1022   OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
1023   # install env script
1024   install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}")
1025   # copy build.bat and install.bat scripts to CMake binary folder
1026   OCCT_COPY_FILE_OR_DIR ("adm/templates/build.bat" "${CMAKE_BINARY_DIR}")
1027   OCCT_COPY_FILE_OR_DIR ("adm/templates/install.bat" "${CMAKE_BINARY_DIR}")
1028 else()
1029   set (SUB_ENV_NAME "env.${SCRIPT_EXT}")
1030   set (SUB_ENV_BUILD_NAME "env.install.${SCRIPT_EXT}")
1031   # install env script
1032   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.install.${SCRIPT_EXT}.in" "${SUB_ENV_BUILD_NAME}" "${SUB_ENV_NAME}" "${INSTALL_DIR_SCRIPT}")
1033   # env script for draw in building environment
1034   OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
1035 endif()
1036
1037 # copy DrawAppliInit from OCCT source to build directory
1038 if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
1039   OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
1040 endif()
1041
1042 # RESOURCES
1043 FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
1044 foreach(RESOURCE ${RESOURCES})
1045   get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
1046   if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
1047     get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
1048     OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}")
1049   else()
1050     OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}")
1051   endif()
1052 endforeach()
1053
1054 if (BUILD_SAMPLES_QT)
1055   FILE_TO_LIST ("adm/SAMPLES_RESOURCES" SAMPLES_RESOURCES)
1056   foreach(RESOURCE ${SAMPLES_RESOURCES})
1057     OCCT_INSTALL_FILE_OR_DIR ("samples/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/samples")
1058     #message("Copy Sample resources: samples/${RESOURCE} into ${INSTALL_DIR_RESOURCE}/samples")
1059   endforeach()
1060
1061   ## Copy sources of OCCTOverview for using in the sample
1062   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/DataExchangeSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1063   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/OcafSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1064   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/GeometrySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1065   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TopologySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1066   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TriangulationSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1067   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer2dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1068   OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer3dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1069 endif()
1070
1071
1072 # patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed
1073 if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
1074   OCCT_UPDATE_DRAW_DEFAULT_FILE()
1075 endif()
1076
1077 # include patched toolkit projects or original ones
1078 foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
1079   OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
1080 endforeach()
1081
1082 if (BUILD_DOC_Overview)
1083   OCCT_ADD_SUBDIRECTORY (dox)
1084 endif()
1085
1086 # patch DRAWEXE
1087 if (MSVC AND 3RDPARTY_DLL_DIRS)
1088   list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
1089   if (${DRAWEXE_INDEX} GREATER -1)
1090     list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
1091     set (3RDPARTY_DLL_DIRS_FOR_PATH "")
1092
1093     foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
1094       set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
1095     endforeach()
1096
1097     OCCT_MAKE_COMPILER_BITNESS()
1098     set (X_COMPILER_BITNESS "x64")
1099     if ("${COMPILER_BITNESS}" STREQUAL "32")
1100       set (X_COMPILER_BITNESS "Win32")
1101     endif()
1102
1103     OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
1104   endif()
1105 endif()
1106
1107 # include patched toolkit projects or original ones
1108 if (BUILD_TOOL_TOOLKITS)
1109   foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS})
1110     OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}")
1111   endforeach()
1112 endif()
1113
1114 message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
1115 # samples do not support patch usage
1116 if (BUILD_SAMPLES_MFC OR BUILD_SAMPLES_QT)
1117   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
1118 endif()
1119
1120 if (BUILD_SAMPLES_MFC)
1121   set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
1122   set (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
1123
1124   add_subdirectory(samples/mfc/standard/mfcsample)
1125   add_subdirectory(samples/mfc/standard/01_Geometry)
1126   add_subdirectory(samples/mfc/standard/02_Modeling)
1127   add_subdirectory(samples/mfc/standard/03_Viewer2d)
1128   add_subdirectory(samples/mfc/standard/04_Viewer3d)
1129   add_subdirectory(samples/mfc/standard/05_ImportExport)
1130   add_subdirectory(samples/mfc/standard/06_Ocaf)
1131   add_subdirectory(samples/mfc/standard/07_Triangulation)
1132   add_subdirectory(samples/mfc/standard/08_HLR)
1133   add_subdirectory(samples/mfc/standard/09_Animation)
1134   add_subdirectory(samples/mfc/standard/10_Convert)
1135
1136   message (STATUS "Info: \(${CURRENT_TIME}\) MFC Sample projects added")
1137 endif()
1138
1139 OCCT_MODULES_AND_TOOLKITS (SAMPLES "SAMPLES_TOOLKITS" OCCT_SAMPLES)
1140
1141 if (BUILD_Inspector OR BUILD_SAMPLES_QT)
1142   if (BUILD_SAMPLES_QT)
1143     if (NOT Qt5_FOUND OR "${Qt5Gui_EGL_INCLUDE_DIRS}" STREQUAL "" OR NOT WIN32)
1144       list (REMOVE_ITEM qt_SAMPLES_TOOLKITS AndroidQt)
1145       message (STATUS "Info: AndroidQt sample excluded due to OS is not Windows or Qt is configured without ANGLE")
1146     endif()
1147   else()
1148     list (REMOVE_ITEM OCCT_SAMPLES qt)
1149     message (STATUS "Info: qt samples excluded due to BUILD_SAMPLES_QT is disabled")
1150   endif()
1151
1152   foreach (OCCT_SAMPLE ${OCCT_SAMPLES})
1153     list (APPEND BUILD_SAMPLE_TOOLKITS ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
1154
1155     # collect all the headers to <binary dir>/inc/samples folder
1156     string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
1157     message (STATUS "Info: \(${CURRENT_TIME}\) ${OCCT_SAMPLE} Sample projects added")
1158
1159     # include patched toolkit projects or original ones
1160     foreach (BUILD_SAMPLE_TOOLKIT ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
1161       OCCT_ADD_SUBDIRECTORY ("samples/${OCCT_SAMPLE}/${BUILD_SAMPLE_TOOLKIT}")
1162     endforeach()
1163   endforeach()
1164 endif()
1165
1166 if (BUILD_MODULE_UwpSample)
1167   add_subdirectory(samples/xaml)
1168 endif()
1169
1170 if (BUILD_TOOL_TOOLKITS)
1171   # copy tinspector script to install script folder
1172   if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}")
1173     install (FILES "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
1174             PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
1175   else()
1176     install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
1177             PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
1178   endif()
1179
1180   set (OpenCASCADE_BINARY_DIR "${INSTALL_DIR}/${INSTALL_DIR_BIN}")
1181   # patch TInspectorEXE
1182   OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/tools/TInspectorEXE/TInspectorEXE.vcxproj.user")
1183 endif()
1184
1185 # Prepare variables for configuration of OpenCASCADE cmake config file
1186 set (OCCT_MODULES_ENABLED)
1187 set (OCCT_LIBRARIES)
1188 set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n")
1189 set (OCCT_COMPILE_DEFINITIONS)
1190
1191 foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS})
1192   if (TARGET ${OCCT_TOOLKIT})
1193
1194     # get all libraries
1195     get_target_property (${OCCT_TOOLKIT}_TYPE ${OCCT_TOOLKIT} "TYPE")
1196     if ("${${OCCT_TOOLKIT}_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${${OCCT_TOOLKIT}_TYPE}" STREQUAL "SHARED_LIBRARY" )
1197       list (APPEND OCCT_LIBRARIES ${OCCT_TOOLKIT})
1198
1199       # get all modules
1200       get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE")
1201       list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE})
1202       list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT})
1203
1204       # get compile definitions of target directory
1205       get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS")
1206       list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS})
1207     endif()
1208   endif()
1209 endforeach()
1210 list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED)
1211 list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS)
1212 # these macros are defined for specific tookits, not globalwise
1213 list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_OPENGL)
1214 list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_GLES2)
1215
1216 # export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files
1217 foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
1218   set (SET_OpenCASCADE_COMPILE_DEFINITIONS)
1219   string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER)
1220   string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER)
1221   foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS})
1222     string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
1223     string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
1224     set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${OCCT_CONFIGURATION}>:${COMPILE_DEFINITION}>)\n")
1225   endforeach()
1226   set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
1227   set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
1228   configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY)
1229 endforeach()
1230 # install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration
1231 install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)")
1232 install (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)")
1233
1234 foreach (OCCT_MODULE ${OCCT_MODULES})
1235   if (BUILD_MODULE_${OCCT_MODULE})
1236     set (SET_OpenCASCADE_MODULES_TOOLKITS "${SET_OpenCASCADE_MODULES_TOOLKITS}set (OpenCASCADE_${OCCT_MODULE}_LIBRARIES ${OpenCASCADE_${OCCT_MODULE}_TOOLKITS})\n")
1237   endif()
1238
1239   # sort enabled modules for correct work of OpenCASCADE config file
1240   list(FIND OCCT_MODULES_ENABLED "${OCCT_MODULE}" OCCT_MODULE_INDEX)
1241   if (NOT ${OCCT_MODULE_INDEX} EQUAL -1)
1242     list (APPEND OCCT_MODULES_ENABLED_SORTED ${OCCT_MODULE})
1243   endif()
1244 endforeach()
1245 set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED})
1246
1247 # Add all targets to the build-tree export set
1248 export (TARGETS ${OCCT_LIBRARIES} FILE "${CMAKE_BINARY_DIR}/OpenCASCADETargets.cmake")
1249
1250 # Export the package for use from the build-tree
1251 # (this registers the build-tree with a global CMake-registry)
1252 export(PACKAGE OpenCASCADE)
1253
1254 if (CMAKE_BUILD_TYPE)
1255   set (SET_OpenCASCADE_BUILD_TYPE "set (OpenCASCADE_BUILD_TYPE        \"${CMAKE_BUILD_TYPE}\")")
1256 endif()
1257
1258 if (BUILD_SHARED_LIBS)
1259   set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS   \"${CMAKE_SHARED_LINKER_FLAGS}\")")
1260 else()
1261   set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS   \"${CMAKE_STATIC_LINKER_FLAGS}\")")
1262 endif()
1263
1264 if (WIN32)
1265   set (SET_OpenCASCADE_WITH_D3D "set (OpenCASCADE_WITH_D3D       ${USE_D3D})")
1266 endif()
1267 if (APPLE)
1268   set (SET_OpenCASCADE_WITH_GLX "set (OpenCASCADE_WITH_GLX       ${USE_XLIB})")
1269 endif()
1270
1271 # Configure and install cmake config file
1272 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADEConfig.cmake.in" "OpenCASCADEConfig.cmake" @ONLY)
1273 install(FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfig.cmake" DESTINATION  "${INSTALL_DIR_CMAKE}")
1274
1275 # Configure cmake version file
1276 include(CMakePackageConfigHelpers)
1277 write_basic_package_version_file( ${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake
1278                                   VERSION ${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}
1279                                   COMPATIBILITY ExactVersion )
1280
1281 # Install cmake version file
1282 install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR_CMAKE}")
1283
1284 # Install the export set for use with the install-tree for each configuration
1285 foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED})
1286   install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}")
1287 endforeach()
1288
1289 # Update generated OpenCASCADETargets-*.cmake files
1290 # to have correct paths to libraries depending on the configuration
1291 OCCT_UPDATE_TARGET_FILE ()
1292
1293 message (STATUS "Info: \(${CURRENT_TIME}\) OCCT configuration files prepared")