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