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