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