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