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