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