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