0027836: Visualization, TKOpenGl - gradient background is lost at some camera positions
[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
742cc8b0 68if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore"))
e13e5f39 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
09eca2b5 297if(APPLE)
298 set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)")
299endif()
300
096ef695 301# a directory recognized as a 'patch' for OCCT
109aa56e 302set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
03c69aec 303
9f33b387 304# the list of being built toolkits
316d77d9 305set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
306separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 307
ad211ad3 308if (MSVC)
4b3541c6 309 set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}")
85bcc072 310endif()
311
742cc8b0 312# uwp sample
313if (MSVC)
314 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
315 set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}")
316 else()
317 unset (BUILD_MODULE_UwpSample)
318 endif()
319endif()
320
9f33b387 321# whether use optional 3rdparty or not
322if (APPLE)
316d77d9 323 set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
03c69aec 324endif()
096ef695 325
f60111dc 326if (WIN32)
327 set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
328endif()
85bcc072 329
9f33b387 330# include the patched or original list of modules
19286d7c 331# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
332# list <OCCT_MODULES> will contain all modules
333OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
03c69aec 334
316d77d9 335foreach (OCCT_MODULE ${OCCT_MODULES})
336 BUILD_MODULE (${OCCT_MODULE})
19286d7c 337endforeach()
338
e713baee 339if (ANDROID AND BUILD_MODULE_Draw)
340 message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
341 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
342endif()
343
adc33035 344# Overview
9d034c37 345if (NOT DEFINED BUILD_DOC_Overview)
346 set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
347 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
348 set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
349
350 if (CAN_DOXYGEN_BE_USED)
351 message (STATUS "Info. Overview building is turned on")
352 endif()
353
354 set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
355endif()
adc33035 356
f60111dc 357if (NOT USE_D3D)
358 list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost)
359endif()
360
316d77d9 361# accumulate used toolkits (first level) in BUILD_TOOLKITS variable
362list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
19286d7c 363
316d77d9 364foreach (OCCT_MODULE ${OCCT_MODULES})
365 if (BUILD_MODULE_${OCCT_MODULE})
366 list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
19286d7c 367 endif()
368endforeach()
369
370# DRAWEXE excluded when library build is static
371if (NOT BUILD_SHARED_LIBS)
316d77d9 372 list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE)
19286d7c 373 message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
374endif()
375
376# accumulate all used toolkits
316d77d9 377list (REMOVE_DUPLICATES BUILD_TOOLKITS)
378set (RAW_BUILD_TOOLKITS)
096ef695 379foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
316d77d9 380 OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
381 list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
19286d7c 382endforeach()
383
316d77d9 384list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
385set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
03c69aec 386
9f33b387 387# include the patched or original list of definitions and flags
19286d7c 388OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
03c69aec 389
19286d7c 390OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
03c69aec 391
a6874708 392# search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
393list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
394if (CAN_USE_VTK EQUAL -1)
395 list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
396endif()
397
398if (NOT CAN_USE_VTK EQUAL -1)
399 if (NOT DEFINED USE_VTK)
400 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
401 endif()
402else()
403 OCCT_CHECK_AND_UNSET (USE_VTK)
404endif()
405
5682a6fa 406# Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
407list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH)
408list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
409
fb3267c7 410if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
109aa56e 411 set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
5682a6fa 412else()
109aa56e 413 OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
5682a6fa 414endif()
415
9f33b387 416if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 417 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
e713baee 418 get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
84258256 419else()
1d505bb0 420 file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
84258256 421 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE)
9f33b387 422endif()
234e52be 423
9f33b387 424# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
f2e9c853 425OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
03c69aec 426
fb3267c7 427if (USE_TCL)
5682a6fa 428 message (STATUS "Info: TCL is used by OCCT")
19286d7c 429 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
82f443b6 430
431 message (STATUS "Info: TK is used by OCCT")
432 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
9f33b387 433else()
9ccea0c6 434 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
435 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
5682a6fa 436
437 OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
82f443b6 438 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
9f33b387 439endif()
03c69aec 440
9f33b387 441# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
f2e9c853 442OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE)
03c69aec 443
fb3267c7 444if (USE_FREETYPE)
5682a6fa 445 message (STATUS "Info: Freetype is used by OCCT")
19286d7c 446 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
9f33b387 447else()
9ccea0c6 448 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 449 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
450 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
5682a6fa 451 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
9f33b387 452endif()
03c69aec 453
09c597c9 454# VTK
455if (USE_VTK)
456 add_definitions (-DHAVE_VTK)
19286d7c 457 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
f2e9c853 458else()
459 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
a6874708 460
461 if (NOT CAN_USE_VTK EQUAL -1)
462 message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
463
464 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
465 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
466 endif()
09c597c9 467endif()
468
f60111dc 469# D3D
470if (USE_D3D)
471 add_definitions (-DHAVE_D3D)
472 #if(MSVC_VERSION LESS 1700)
473 #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
474 #endif()
475endif()
476
09c597c9 477# GLX
478if (USE_GLX)
479 add_definitions (-DMACOSX_USE_GLX)
19286d7c 480 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
09c597c9 481endif()
482
03c69aec 483# FREEIMAGE
5682a6fa 484# search for CSF_FREEIMAGE variable in EXTERNLIB of each being used toolkit
60273f77 485OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
5682a6fa 486
60273f77 487if (CAN_USE_FREEIMAGE)
5682a6fa 488 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
489
490 if (USE_FREEIMAGE)
491 add_definitions (-DHAVE_FREEIMAGE)
492 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
5682a6fa 493 else()
494 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
5682a6fa 495 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
5682a6fa 496 endif()
9f33b387 497else()
5682a6fa 498 OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
499
9f33b387 500 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
9f33b387 501 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
9f33b387 502endif()
03c69aec 503
1ce0716b 504# OpenGL ES 2.0
505OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_GLES2)
506if (WIN32 AND CAN_USE_GLES2)
507 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
508 set (USE_GLES2 ON)
509 else()
510 set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}")
511 endif()
512
513 if (USE_GLES2)
514 add_definitions (-DHAVE_GLES2)
515 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl")
516 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2")
517 else()
518 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
519 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
520 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
521 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
522 endif()
523else()
524 OCCT_CHECK_AND_UNSET ("USE_GLES2")
525
526 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
527 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
528 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
529 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
530endif()
531
03c69aec 532# GL2PS
5682a6fa 533# search for CSF_GL2PS variable in EXTERNLIB of each being used toolkit
534OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS)
535
536if (NOT DEFINED ANDROID AND CAN_USE_GL2PS)
537 set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
538
539 if (USE_GL2PS)
540 add_definitions (-DHAVE_GL2PS)
541 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
542 else()
543 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
544 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
545 endif()
9f33b387 546else()
5682a6fa 547 OCCT_CHECK_AND_UNSET ("USE_GL2PS")
548
9f33b387 549 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
550 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
551endif()
03c69aec 552
9f33b387 553# TBB
5682a6fa 554# search for CSF_TBB variable in EXTERNLIB of each being used toolkit
555OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
556
557if (NOT DEFINED ANDROID AND CAN_USE_TBB)
558 set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
559
560 if (USE_TBB)
561 add_definitions (-DHAVE_TBB)
562 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
563 else()
564 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
565 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
566 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
567 endif()
9f33b387 568else()
5682a6fa 569 OCCT_CHECK_AND_UNSET ("USE_TBB")
570
9f33b387 571 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
572 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
573 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
574endif()
234e52be 575
adc33035 576# Doxygen
4b3541c6 577if (BUILD_DOC_Overview)
578 if (NOT DEFINED INSTALL_DOC_Overview)
579 set (INSTALL_DOC_Overview OFF CACHE BOOL "${INSTALL_DOC_Overview_DESCR}")
adc33035 580 endif()
581
4b3541c6 582 if (INSTALL_DOC_Overview)
583 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_DOC}")
f2e9c853 584
096ef695 585 # create overview.html only for windows
4b3541c6 586 if (WIN32 AND "${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
587 OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR}/${INSTALL_DIR_DOC}/..")
096ef695 588 endif()
adc33035 589 endif()
590
591 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
592else()
4b3541c6 593 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_Overview")
adc33035 594
595 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
109aa56e 596 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
adc33035 597endif()
598
316d77d9 599# bison
109aa56e 600if (BUILD_YACCLEX)
316d77d9 601 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
602else()
603 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
604endif()
605
606# flex
109aa56e 607if (BUILD_YACCLEX)
316d77d9 608 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
609else()
610 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
611endif()
612
9f33b387 613string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 614
9f33b387 615# check all 3rdparty paths
616if (3RDPARTY_NOT_INCLUDED)
617 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
618endif()
7c633a3e 619
9bb81d6c 620if (3RDPARTY_INCLUDE_DIRS)
621 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
622 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
ada9ef40 623 message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
9bb81d6c 624 include_directories (${3RDPARTY_INCLUDE_DIRS})
625endif()
626
94829f84 627# include <cmake binary folder>/inc
628include_directories (${CMAKE_BINARY_DIR}/inc)
629
3321f684 630if (3RDPARTY_LIBRARY_DIRS AND BUILD_SHARED_LIBS)
9bb81d6c 631 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
632 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
ada9ef40 633 message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
9bb81d6c 634 link_directories (${3RDPARTY_LIBRARY_DIRS})
635endif()
234e52be 636
9f33b387 637# build directories
4b3541c6 638if (SINGLE_GENERATOR)
639 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
640 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
641 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
642 if (WIN32)
643 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
644 endif()
645endif()
646
fa0cbe55 647set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
648set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
649set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 650
316d77d9 651set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
652set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
653set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 654
fa0cbe55 655set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
656set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
657set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 658
fa0cbe55 659if (WIN32)
f2e9c853 660 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
661 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
662 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 663endif()
03c69aec 664
d94d80e5 665string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
666message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
94829f84 667
94829f84 668# collect all the headers to <binary dir>/inc folder
f2e9c853 669COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
94829f84 670
d94d80e5 671string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
672message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
673
4b3541c6 674if (WIN32)
675 set (SCRIPT_EXT bat)
676else()
677 set (SCRIPT_EXT sh)
678endif()
03c69aec 679
096ef695 680# OCCT samples
0e617b05 681if (INSTALL_SAMPLES)
4b3541c6 682 OCCT_CONFIGURE ("adm/templates/env.samples.${SCRIPT_EXT}.in" "env.samples.${SCRIPT_EXT}")
096ef695 683 if (WIN32)
4b3541c6 684 OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
685 OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
686
742cc8b0 687 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
688 OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
689 endif()
690
4b3541c6 691 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}")
692 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}")
096ef695 693 endif()
03c69aec 694
4b3541c6 695 OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
696 OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
697 OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
096ef695 698
4b3541c6 699 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}")
700 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}")
701 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}")
910970ab 702endif()
03c69aec 703
4b3541c6 704if (INSTALL_TEST_CASES)
705 OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR}/${INSTALL_DIR_TESTS}")
910970ab 706endif()
03c69aec 707
3eabbe1b 708list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
709if (${DRAWEXE_INDEX} GREATER -1)
710 # copy data and samples/tcl folders to install script folder
711 OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR}/${INSTALL_DIR_DATA}")
712 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}")
096ef695 713
3eabbe1b 714 # copy draw script to install script folder
715 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
716 install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}"
717 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
718 else()
719 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}"
720 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
721 endif()
722
723 # copy draw script to CMake binary folder
724 OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
725endif()
9f33b387 726
316d77d9 727set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 728
910970ab 729if (WIN32)
4b3541c6 730 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %1 %2 %3 \n)")
910970ab 731else()
096ef695 732 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
910970ab 733endif()
32856b63 734
910970ab 735 # change custom.bat/sh
4b3541c6 736if (EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}")
737 file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 738
910970ab 739 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 740
4b3541c6 741 file (WRITE "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
910970ab 742else()
4b3541c6 743 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}")
910970ab 744endif()
32856b63 745
316d77d9 746# write current custom.bat/sh (for install directory)
747set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
4b3541c6 748OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}")
03c69aec 749
316d77d9 750# write current custom.bat/sh (for build directory)
751OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
752
4b3541c6 753if (BUILD_MODULE_MfcSamples)
754 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}")
f2e9c853 755 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
9f33b387 756endif()
757
316d77d9 758# env script for draw in building environment
4b3541c6 759OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
316d77d9 760
4b3541c6 761# install env script
762install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}")
316d77d9 763
764# copy DrawAppliInit from OCCT source to build directory
f2e9c853 765if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
766 OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
316d77d9 767endif()
910970ab 768
9f33b387 769# RESOURCES
19286d7c 770FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
771foreach(RESOURCE ${RESOURCES})
772 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
773 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
774 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
4b3541c6 775 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}")
19286d7c 776 else()
4b3541c6 777 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/${INSTALL_DIR_RESOURCE}")
19286d7c 778 endif()
779endforeach()
03c69aec 780
46bd680a 781# patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed
782if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
783 OCCT_UPDATE_DRAW_DEFAULT_FILE()
784endif()
785
fb3267c7 786# define CSF variable
787OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
788
33839ae6 789# include patched toolkit projects or original ones
316d77d9 790foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
f2e9c853 791 OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
19286d7c 792endforeach()
234e52be 793
4b3541c6 794if (BUILD_DOC_Overview)
f2e9c853 795 OCCT_ADD_SUBDIRECTORY (dox)
adc33035 796endif()
797
94829f84 798# patch DRAWEXE
799if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 800 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 801 if (${DRAWEXE_INDEX} GREATER -1)
802 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
803 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
804
805 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
806 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
807 endforeach()
808
809 OCCT_MAKE_COMPILER_BITNESS()
810 set (X_COMPILER_BITNESS "x64")
811 if ("${COMPILER_BITNESS}" STREQUAL "32")
812 set (X_COMPILER_BITNESS "Win32")
813 endif()
814
f2e9c853 815 OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
94829f84 816 endif()
817endif()
818
33839ae6 819# samples do not support patch usage
4b3541c6 820if (BUILD_MODULE_MfcSamples)
19286d7c 821 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
234e52be 822
19286d7c 823 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
824 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 825
9f33b387 826 add_subdirectory(samples/mfc/standard/mfcsample)
827 add_subdirectory(samples/mfc/standard/01_Geometry)
828 add_subdirectory(samples/mfc/standard/02_Modeling)
829 add_subdirectory(samples/mfc/standard/03_Viewer2d)
830 add_subdirectory(samples/mfc/standard/04_Viewer3d)
831 add_subdirectory(samples/mfc/standard/05_ImportExport)
832 add_subdirectory(samples/mfc/standard/06_Ocaf)
833 add_subdirectory(samples/mfc/standard/07_Triangulation)
834 add_subdirectory(samples/mfc/standard/08_HLR)
835 add_subdirectory(samples/mfc/standard/09_Animation)
836 add_subdirectory(samples/mfc/standard/10_Convert)
19286d7c 837endif()
2e48c1cb 838
742cc8b0 839if (BUILD_MODULE_UwpSample)
840 add_subdirectory(samples/xaml)
841endif()
842
2e48c1cb 843# Prepare variables for configuration of OpenCASCADE cmake config file
844set (OCCT_MODULES_ENABLED)
845set (OCCT_LIBRARIES)
ada9ef40 846set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n")
a3d2cb24 847set (OCCT_COMPILE_DEFINITIONS)
848
2e48c1cb 849foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS})
850 if (TARGET ${OCCT_TOOLKIT})
851
852 # get all libraries
853 get_target_property (${OCCT_TOOLKIT}_TYPE ${OCCT_TOOLKIT} "TYPE")
854 if ("${${OCCT_TOOLKIT}_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${${OCCT_TOOLKIT}_TYPE}" STREQUAL "SHARED_LIBRARY" )
855 list (APPEND OCCT_LIBRARIES ${OCCT_TOOLKIT})
2e48c1cb 856
ada9ef40 857 # get all modules
858 get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE")
859 list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE})
860 list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT})
a3d2cb24 861
862 # get compile definitions of target directory
863 get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS")
864 list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS})
2e48c1cb 865 endif()
866 endif()
867endforeach()
868list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED)
a3d2cb24 869list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS)
870
871# export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files
872foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
873 set (SET_OpenCASCADE_COMPILE_DEFINITIONS)
874 string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER)
875 string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER)
876 foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS})
877 string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
878 string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
879 set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${OCCT_CONFIGURATION}>:${COMPILE_DEFINITION}>)\n")
880 endforeach()
881 set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
882 set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
883 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY)
884endforeach()
885# install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration
886install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)")
887install (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 888
ada9ef40 889foreach (OCCT_MODULE ${OCCT_MODULES})
890 if (BUILD_MODULE_${OCCT_MODULE})
891 set (SET_OpenCASCADE_MODULES_TOOLKITS "${SET_OpenCASCADE_MODULES_TOOLKITS}set (OpenCASCADE_${OCCT_MODULE}_LIBRARIES ${OpenCASCADE_${OCCT_MODULE}_TOOLKITS})\n")
892 endif()
f7ac9097 893
894 # sort enabled modules for correct work of OpenCASCADE config file
895 list(FIND OCCT_MODULES_ENABLED "${OCCT_MODULE}" OCCT_MODULE_INDEX)
896 if (NOT ${OCCT_MODULE_INDEX} EQUAL -1)
897 list (APPEND OCCT_MODULES_ENABLED_SORTED ${OCCT_MODULE})
898 endif()
ada9ef40 899endforeach()
f7ac9097 900set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED})
ada9ef40 901
902# Add all targets to the build-tree export set
903export (TARGETS ${OCCT_LIBRARIES} FILE "${CMAKE_BINARY_DIR}/OpenCASCADETargets.cmake")
904
905# Export the package for use from the build-tree
906# (this registers the build-tree with a global CMake-registry)
907export(PACKAGE OpenCASCADE)
908
2e48c1cb 909if (CMAKE_BUILD_TYPE)
910 set (SET_OpenCASCADE_BUILD_TYPE "set (OpenCASCADE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
911endif()
912
913if (BUILD_SHARED_LIBS)
914 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS}\")")
915else()
916 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_STATIC_LINKER_FLAGS}\")")
917endif()
918
919if (WIN32)
920 set (SET_OpenCASCADE_WITH_D3D "set (OpenCASCADE_WITH_D3D ${USE_D3D})")
921endif()
922if (APPLE)
923 set (SET_OpenCASCADE_WITH_GLX "set (OpenCASCADE_WITH_GLX ${USE_GLX})")
924endif()
925
ada9ef40 926if (NOT SINGLE_GENERATOR)
927 OCCT_INSERT_CODE_FOR_TARGET()
928endif()
929
2e48c1cb 930# Configure and install cmake config file
ada9ef40 931configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADEConfig.cmake.in" "OpenCASCADEConfig.cmake" @ONLY)
932install(FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfig.cmake" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_CMAKE}")
2e48c1cb 933
934# Configure cmake version file
935include(CMakePackageConfigHelpers)
936write_basic_package_version_file( ${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake
937 VERSION ${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}
938 COMPATIBILITY ExactVersion )
939
940# Install cmake version file
941install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_CMAKE}")
ada9ef40 942
943# Install the export set for use with the install-tree for each configuration
f7ac9097 944foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED})
945 install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}")
ada9ef40 946endforeach()
947
948# Update generated OpenCASCADETargets-*.cmake files
949# to have correct paths to libraries depending on the configuration
950OCCT_UPDATE_TARGET_FILE ()