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