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