0032402: Coding Rules - eliminate msvc warning C4668 (symbol is not defined as a...
[occt.git] / CMakeLists.txt
CommitLineData
19286d7c 1cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
166d6cd7 2
896faa72 3set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake")
4
576f8b11 5set (CMAKE_SUPPRESS_REGENERATION TRUE)
6
fa0cbe55 7set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
03c69aec 8
316d77d9 9# macro: include patched file if it exists
10macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
109aa56e 11 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake")
12 include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 13 else()
f2e9c853 14 include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 15 endif()
16endmacro()
17
18# include variable description
19OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr")
20
c259930b 21# set type of OCCT libraries
22if (NOT BUILD_LIBRARY_TYPE)
316d77d9 23 set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE)
c259930b 24 SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
25endif()
26
27if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
28 set (BUILD_SHARED_LIBS ON)
46bd680a 29
30 if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX)
31 set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE)
32 endif()
c259930b 33else()
34 unset (BUILD_SHARED_LIBS)
46bd680a 35 unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX)
c259930b 36endif()
37
9f33b387 38# the name of the project
39project (OCCT)
03c69aec 40
ad03c234 41if (WIN32)
42 add_definitions(-DUNICODE)
43 add_definitions(-D_UNICODE)
44endif()
45
096ef695 46# include occt macros
47OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
48
9f33b387 49# Solution folder property
50set_property (GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 51
096ef695 52# get current OCCT version
53OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
54
55set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
56set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
57set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
58
0e617b05 59set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
096ef695 60
ee5befae 61# Regeneration of OCCT resource files
62set (BUILD_RESOURCES OFF CACHE BOOL "${BUILD_RESOURCES_DESCR}")
63
096ef695 64# single-configuration generator
65set (SINGLE_GENERATOR OFF)
798a95ed 66if (DEFINED CMAKE_BUILD_TYPE)
096ef695 67 set (SINGLE_GENERATOR ON)
68endif()
69
316d77d9 70# a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable
71# check this variable and set if it's required
72if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator.
73 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 74endif()
75
898f6a92 76# enable extended messages of many OCCT algorithms
742cc8b0 77if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore"))
e13e5f39 78 if (NOT BUILD_WITH_DEBUG)
79 set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
80 endif()
81else()
82 OCCT_CHECK_AND_UNSET (BUILD_WITH_DEBUG)
83endif()
84
109aa56e 85if (BUILD_WITH_DEBUG)
e13e5f39 86 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:DEBUG>:OCCT_DEBUG>)
898f6a92 87endif()
316d77d9 88
6072d597 89# option disabling OCCT exceptions in Release builds (No_Exception)
90if (NOT DEFINED BUILD_RELEASE_DISABLE_EXCEPTIONS)
91 set (BUILD_RELEASE_DISABLE_EXCEPTIONS ON CACHE BOOL "${BUILD_RELEASE_DISABLE_EXCEPTIONS_DESCR}")
92endif()
93
896faa72 94# option to enable or disable use of precompiled headers
95if (NOT DEFINED BUILD_USE_PCH)
96 set (BUILD_USE_PCH OFF CACHE BOOL "${BUILD_USE_PCH_DESCR}")
97endif()
98
99if (BUILD_USE_PCH)
100
101 # Load Cotire tool for accelerating build procedure
102 include(cotire)
103
c4d4fcea 104 # Set Cotire to ignore lxx, pxx, gxx
896faa72 105 set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "lxx;pxx;gxx" CACHE STRING "Set Cotire to ignore OCCT specific files that can be #included" FORCE)
106
107 # Set priority for inclusion of system headers in PCH to reduce problems
108 # due to incomplete inclusion or wrong order.
109 if (WIN32)
110 # on Windows, assume that SDK (windows.h) is in default location
111 set(ProgramFilesX86 "ProgramFiles(x86)")
112 file(TO_CMAKE_PATH "$ENV{${ProgramFilesX86}}" ProgramFilesX86)
113 set_property (DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "${ProgramFilesX86}")
114 unset(ProgramFilesX86)
115 endif()
116
117endif()
118
19286d7c 119# copy samples to install directory
0e617b05 120set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}")
19286d7c 121
096ef695 122# install dir of the project
123if (NOT DEFINED INSTALL_DIR)
4b3541c6 124 # set default install directory for Windows
84258256 125 if (WIN32 AND NOT DEFINED CMAKE_INSTALL_PREFIX)
4b3541c6 126 set (CMAKE_INSTALL_PREFIX "C:/opencascade-${OCC_VERSION_STRING_EXT}")
127 endif()
096ef695 128 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
84258256 129else()
1d505bb0 130 file (TO_CMAKE_PATH "${INSTALL_DIR}" INSTALL_DIR)
84258256 131 set (INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
096ef695 132endif()
133
4b3541c6 134# choose a variant of the layout of the install paths
135if (NOT INSTALL_DIR_LAYOUT)
136 if (WIN32)
137 set (INSTALL_DIR_LAYOUT "Windows" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
138 else()
139 set (INSTALL_DIR_LAYOUT "Unix" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE)
140 endif()
141 SET_PROPERTY(CACHE INSTALL_DIR_LAYOUT PROPERTY STRINGS Windows Unix)
142endif()
143
144# check INSTALL_DIR_LAYOUT changes and update INSTALL_DIR_* paths if necessary
145if (NOT DEFINED INSTALL_DIR_LAYOUT_PREV)
146 set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
147elseif (NOT "${INSTALL_DIR_LAYOUT_PREV}" STREQUAL "${INSTALL_DIR_LAYOUT}")
148 set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE)
149 # The structure of install folder should be reset due to changed layout
150 OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
151
152 # Unset INSTALL_DIR_WITH_VERSION on windows
153 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
154 OCCT_CHECK_AND_UNSET (INSTALL_DIR_WITH_VERSION)
155 else()
156 if (NOT DEFINED INSTALL_DIR_WITH_VERSION)
157 set (INSTALL_DIR_WITH_VERSION OFF CACHE BOOL "${INSTALL_DIR_WITH_VERSION_DESCR}")
158 endif()
159 endif()
160endif()
161
162# check CMAKE_INSTALL_PREFIX changes and update INSTALL_DIR if necessary
d573adcf 163if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
164 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
165elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
166 # CMAKE_INSTALL_PREFIX has been changed at previous step
167 set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
c4d4fcea 168
d573adcf 169 # INSTALL_DIR is required to be updated
170 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
171endif()
172
4b3541c6 173# check INSTALL_DIR changes and update CMAKE_INSTALL_PREFIX if necessary
d573adcf 174if (NOT DEFINED INSTALL_DIR_PREV)
175 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
176elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
177 # INSTALL_DIR has been changed at previous step
178 set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
179
c4d4fcea 180 # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
d573adcf 181 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
182
c4d4fcea 183 # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
d573adcf 184 set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
4b3541c6 185endif()
d573adcf 186
4b3541c6 187if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
188 if (NOT DEFINED INSTALL_DIR_WITH_VERSION_PREV)
189 set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
190 elseif (NOT "${INSTALL_DIR_WITH_VERSION_PREV}" STREQUAL "${INSTALL_DIR_WITH_VERSION}")
191 # INSTALL_DIR_WITH_VERSION has been changed at previous step
192 set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE)
193
194 OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS ()
195 endif()
096ef695 196endif()
197
198# hide CMAKE_INSTALL_PREFIX from a user
199set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
200
201set (BIN_LETTER "")
202if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
203 set (BIN_LETTER "d")
204elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
205 set (BIN_LETTER "i")
206endif()
03c69aec 207
096ef695 208# Get all used variables: OS_WITH_BIT, COMPILER
209OCCT_MAKE_OS_WITH_BITNESS()
210OCCT_MAKE_COMPILER_SHORT_NAME()
211
4b3541c6 212# do not define INSTALL_DIR_BIN for win.
096ef695 213# Leave library structure for win: <prefix>/win64/vc10/bin(d)
4b3541c6 214if (NOT DEFINED INSTALL_DIR_BIN)
215 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
216 set (INSTALL_DIR_BIN "bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
096ef695 217 else()
4b3541c6 218 set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}")
096ef695 219 endif()
220endif()
221
a110c4a3 222# define folder containing all shell/batch scripts
4b3541c6 223if (NOT DEFINED INSTALL_DIR_SCRIPT)
224 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
225 set (INSTALL_DIR_SCRIPT "${INSTALL_DIR_BIN}" CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
096ef695 226 else()
4b3541c6 227 set (INSTALL_DIR_SCRIPT "." CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}")
096ef695 228 endif()
229endif()
230
231# place the libraries to <prefix>/lib folder for unix and leave old structure for windows
4b3541c6 232if (NOT DEFINED INSTALL_DIR_LIB)
233 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
234 set (INSTALL_DIR_LIB "lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
096ef695 235 else()
4b3541c6 236 set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}")
096ef695 237 endif()
238endif()
239
240# OCCT headers: <prefix>/inc for windows,
241# <prefix>/include/opencascade-7.0.0 for unix
4b3541c6 242if (NOT DEFINED INSTALL_DIR_INCLUDE)
243 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
244 set (INSTALL_DIR_INCLUDE "include/opencascade" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
245 if (INSTALL_DIR_WITH_VERSION)
246 set (INSTALL_DIR_INCLUDE "include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}" FORCE)
247 endif()
096ef695 248 else()
4b3541c6 249 set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}")
096ef695 250 endif()
251endif()
252
253# OCCT resources: <prefix>/src for windows,
254# <prefix>/share/opencascade-7.0.0/resources for unix
4b3541c6 255if (NOT DEFINED INSTALL_DIR_RESOURCE)
256 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
257 set (INSTALL_DIR_RESOURCE "share/opencascade/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
258 if (INSTALL_DIR_WITH_VERSION)
259 set (INSTALL_DIR_RESOURCE "share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}" FORCE)
260 endif()
096ef695 261 else()
4b3541c6 262 set (INSTALL_DIR_RESOURCE "src" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}")
096ef695 263 endif()
264endif()
265
266# OCCT data
4b3541c6 267if (NOT DEFINED INSTALL_DIR_DATA)
268 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
269 set (INSTALL_DIR_DATA "share/opencascade/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
270 if (INSTALL_DIR_WITH_VERSION)
271 set (INSTALL_DIR_DATA "share/opencascade-${OCC_VERSION_STRING_EXT}/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}" FORCE)
272 endif()
273 else()
274 set (INSTALL_DIR_DATA "data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}")
275 endif()
276endif()
277
278# OCCT samples
279if (NOT DEFINED INSTALL_DIR_SAMPLES)
280 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
281 set (INSTALL_DIR_SAMPLES "share/opencascade/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
282 if (INSTALL_DIR_WITH_VERSION)
283 set (INSTALL_DIR_SAMPLES "share/opencascade-${OCC_VERSION_STRING_EXT}/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}" FORCE)
284 endif()
285 else()
286 set (INSTALL_DIR_SAMPLES "samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}")
287 endif()
288endif()
289
290# OCCT tests
291if (NOT DEFINED INSTALL_DIR_TESTS)
292 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
293 set (INSTALL_DIR_TESTS "share/opencascade/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
294 if (INSTALL_DIR_WITH_VERSION)
295 set (INSTALL_DIR_TESTS "share/opencascade-${OCC_VERSION_STRING_EXT}/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}" FORCE)
296 endif()
297 else()
298 set (INSTALL_DIR_TESTS "tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}")
299 endif()
300endif()
301
302# OCCT doc
303if (NOT DEFINED INSTALL_DIR_DOC)
304 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
305 set (INSTALL_DIR_DOC "share/doc/opencascade" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
306 if (INSTALL_DIR_WITH_VERSION)
307 set (INSTALL_DIR_DOC "share/doc/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_DOC_DESCR}" FORCE)
308 endif()
096ef695 309 else()
4b3541c6 310 set (INSTALL_DIR_DOC "doc" CACHE PATH "${INSTALL_DIR_DOC_DESCR}")
096ef695 311 endif()
312endif()
313
a110c4a3 314# define folder containing CMake configuration files
2e48c1cb 315if (NOT DEFINED INSTALL_DIR_CMAKE)
316 if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
317 if (INSTALL_DIR_WITH_VERSION)
318 set (INSTALL_DIR_CMAKE "lib/cmake/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
319 else()
320 set (INSTALL_DIR_CMAKE "lib/cmake/opencascade" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
321 endif()
322 else()
ada9ef40 323 set (INSTALL_DIR_CMAKE "cmake" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}")
2e48c1cb 324 endif()
325endif()
326
ee5befae 327# include occt macros
328OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_resources")
329
4b3541c6 330# install LICENSE_LGPL_21.txt and OCCT_LGPL_EXCEPTION.txt files
331if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix")
d26375e2 332 OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" "${INSTALL_DIR_DOC}")
333 OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" "${INSTALL_DIR_DOC}")
4b3541c6 334else()
d26375e2 335 OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" ".")
336 OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" ".")
4b3541c6 337endif()
338
09eca2b5 339if(APPLE)
340 set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)")
341endif()
342
096ef695 343# a directory recognized as a 'patch' for OCCT
109aa56e 344set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
03c69aec 345
9f33b387 346# the list of being built toolkits
316d77d9 347set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
348separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 349
ad211ad3 350if (MSVC)
510d9690 351 set (BUILD_SAMPLES_MFC OFF CACHE BOOL "${BUILD_SAMPLES_MFC_DESCR}")
85bcc072 352endif()
510d9690 353set (BUILD_SAMPLES_QT OFF CACHE BOOL "${BUILD_SAMPLES_QT_DESCR}")
85bcc072 354
4f4b8935 355set (BUILD_Inspector OFF CACHE BOOL "${BUILD_Inspector_DESCR}")
356
742cc8b0 357# uwp sample
358if (MSVC)
359 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
360 set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}")
361 else()
362 unset (BUILD_MODULE_UwpSample)
363 endif()
364endif()
365
9f33b387 366# whether use optional 3rdparty or not
87b68a0f 367set (USE_TK ON CACHE BOOL "${USE_TK_DESCR}")
5c9493b3 368set (USE_FREETYPE ON CACHE BOOL "${USE_FREETYPE_DESCR}")
369set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
370set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
371set (USE_OPENVR OFF CACHE BOOL "${USE_OPENVR_DESCR}")
372set (USE_RAPIDJSON OFF CACHE BOOL "${USE_RAPIDJSON_DESCR}")
373set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
374set (USE_EIGEN OFF CACHE BOOL "${USE_EIGEN_DESCR}")
375
b69e576a 376if (WIN32 OR ANDROID OR IOS OR EMSCRIPTEN)
377 # no Xlib
378elseif (APPLE)
379 set (USE_XLIB OFF CACHE BOOL "${USE_XLIB_DESCR}")
bbc5899a 380else()
b69e576a 381 set (USE_XLIB ON CACHE BOOL "${USE_XLIB_DESCR}")
03c69aec 382endif()
096ef695 383
f60111dc 384if (WIN32)
385 set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
bbc5899a 386else()
387 set (USE_D3D OFF)
f60111dc 388endif()
85bcc072 389
7a59f4ce 390# Enable/Disable the floating point exceptions (FPE) during runtime.
391if (NOT BUILD_ENABLE_FPE_SIGNAL_HANDLER)
392 set (BUILD_ENABLE_FPE_SIGNAL_HANDLER OFF CACHE BOOL "${BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR}" FORCE)
393endif()
394
395if (BUILD_ENABLE_FPE_SIGNAL_HANDLER)
396 set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 1)
397else()
398 set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 0)
399endif()
400
bbc5899a 401# OpenGL
402if (ANDROID OR IOS OR EMSCRIPTEN OR "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
403 set (USE_OPENGL OFF)
404 set (USE_GLES2 ON)
405else()
406 set (USE_OPENGL ON CACHE BOOL "${USE_OPENGL_DESCR}")
407 set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}")
408endif()
409
9f33b387 410# include the patched or original list of modules
19286d7c 411# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
412# list <OCCT_MODULES> will contain all modules
1fa16152 413OCCT_MODULES_AND_TOOLKITS (MODULES "TOOLKITS" OCCT_MODULES)
03c69aec 414
316d77d9 415foreach (OCCT_MODULE ${OCCT_MODULES})
416 BUILD_MODULE (${OCCT_MODULE})
19286d7c 417endforeach()
418
e713baee 419if (ANDROID AND BUILD_MODULE_Draw)
420 message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
421 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
422endif()
49e5d238 423if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND BUILD_MODULE_Draw)
424 message (STATUS "Info. Draw module is turned off due to it is not supported on UWP")
425 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
426endif()
e713baee 427
adc33035 428# Overview
9d034c37 429if (NOT DEFINED BUILD_DOC_Overview)
430 set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
431 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
432 set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
c4d4fcea 433
9d034c37 434 if (CAN_DOXYGEN_BE_USED)
435 message (STATUS "Info. Overview building is turned on")
436 endif()
437
438 set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
439endif()
adc33035 440
316d77d9 441# accumulate used toolkits (first level) in BUILD_TOOLKITS variable
442list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
19286d7c 443
316d77d9 444foreach (OCCT_MODULE ${OCCT_MODULES})
445 if (BUILD_MODULE_${OCCT_MODULE})
446 list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
19286d7c 447 endif()
448endforeach()
449
19286d7c 450# accumulate all used toolkits
316d77d9 451list (REMOVE_DUPLICATES BUILD_TOOLKITS)
452set (RAW_BUILD_TOOLKITS)
096ef695 453foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
316d77d9 454 OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
455 list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
19286d7c 456endforeach()
457
316d77d9 458list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
459set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
03c69aec 460
9f33b387 461# include the patched or original list of definitions and flags
19286d7c 462OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
03c69aec 463
19286d7c 464OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
03c69aec 465
a6874708 466# search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
467list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
468if (CAN_USE_VTK EQUAL -1)
469 list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
470endif()
471
472if (NOT CAN_USE_VTK EQUAL -1)
473 if (NOT DEFINED USE_VTK)
474 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
475 endif()
476else()
477 OCCT_CHECK_AND_UNSET (USE_VTK)
478endif()
479
5682a6fa 480# Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
481list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH)
482list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
483
fb3267c7 484if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
109aa56e 485 set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
5682a6fa 486else()
109aa56e 487 OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
5682a6fa 488endif()
489
9f33b387 490if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 491 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
e713baee 492 get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
84258256 493else()
1d505bb0 494 file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
84258256 495 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE)
9f33b387 496endif()
234e52be 497
4fecc365 498# search for CSF variable in EXTERNLIB of each being used toolkit
499OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
f2e9c853 500OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
87b68a0f 501OCCT_IS_PRODUCT_REQUIRED (CSF_TclTkLibs CAN_USE_TK)
b69e576a 502OCCT_IS_PRODUCT_REQUIRED (CSF_XwLibs CAN_USE_XLIB)
5c9493b3 503OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE CAN_USE_FREETYPE)
b8ef513c 504OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL)
505OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2)
4fecc365 506OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
507OCCT_IS_PRODUCT_REQUIRED (CSF_EIGEN CAN_USE_EIGEN)
508
509# define CSF variable
510OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
03c69aec 511
87b68a0f 512# Tcl (mandatory for Draw Harness)
fb3267c7 513if (USE_TCL)
5682a6fa 514 message (STATUS "Info: TCL is used by OCCT")
19286d7c 515 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
9f33b387 516else()
9ccea0c6 517 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
5682a6fa 518 OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
87b68a0f 519endif()
520
521# Tk (optional for Draw Harness)
522if (CAN_USE_TK)
523 if (USE_TK)
524 message (STATUS "Info: TK is used by OCCT")
525 add_definitions (-DHAVE_TK)
526 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
527 else()
528 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
529 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
530 endif()
531else()
532 OCCT_CHECK_AND_UNSET ("USE_TK")
533 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
82f443b6 534 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
9f33b387 535endif()
03c69aec 536
b69e576a 537# Xlib
538if (CAN_USE_XLIB)
539 if (USE_XLIB)
540 message (STATUS "Info: Xlib is used by OCCT")
541 add_definitions (-DHAVE_XLIB)
542 if (APPLE)
543 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
544 endif()
545 endif()
546else()
547 OCCT_CHECK_AND_UNSET ("USE_XLIB")
548endif()
549
5c9493b3 550# FreeType
551if (CAN_USE_FREETYPE)
552 if (USE_FREETYPE)
553 message (STATUS "Info: FreeType is used by OCCT")
554 add_definitions (-DHAVE_FREETYPE)
555 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
556 else()
557 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
558 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
559 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
560 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
561 endif()
9f33b387 562else()
5c9493b3 563 OCCT_CHECK_AND_UNSET ("USE_FREETYPE")
9ccea0c6 564 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
5682a6fa 565 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
9f33b387 566endif()
03c69aec 567
09c597c9 568# VTK
569if (USE_VTK)
570 add_definitions (-DHAVE_VTK)
c22e576d 571 set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE)
19286d7c 572 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
f2e9c853 573else()
574 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
c4d4fcea 575
a6874708 576 if (NOT CAN_USE_VTK EQUAL -1)
577 message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
578
579 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
580 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
581 endif()
09c597c9 582endif()
583
03c69aec 584# FREEIMAGE
60273f77 585if (CAN_USE_FREEIMAGE)
5682a6fa 586 if (USE_FREEIMAGE)
587 add_definitions (-DHAVE_FREEIMAGE)
588 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
5682a6fa 589 else()
590 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
5682a6fa 591 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
5682a6fa 592 endif()
9f33b387 593else()
5682a6fa 594 OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
595
9f33b387 596 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
9f33b387 597 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
9f33b387 598endif()
03c69aec 599
16ed73be 600# OpenVR
601# search for CSF_OpenVR variable in EXTERNLIB of each being used toolkit
602OCCT_IS_PRODUCT_REQUIRED (CSF_OpenVR CAN_USE_OPENVR)
603if (CAN_USE_OPENVR)
16ed73be 604 if (USE_OPENVR)
605 add_definitions (-DHAVE_OPENVR)
606 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/openvr")
607 else()
608 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
609 OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
610 endif()
611else()
612 OCCT_CHECK_AND_UNSET ("USE_OPENVR")
613
614 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
615 OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
616endif()
617
08f8a185 618# FFmpeg
619# search for CSF_FFmpeg variable in EXTERNLIB of each being used toolkit
620OCCT_IS_PRODUCT_REQUIRED (CSF_FFmpeg CAN_USE_FFMPEG)
621
622if (CAN_USE_FFMPEG)
08f8a185 623 if (USE_FFMPEG)
624 add_definitions (-DHAVE_FFMPEG)
625 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/ffmpeg")
626 else()
627 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG")
628 OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG")
629 endif()
630else()
631 OCCT_CHECK_AND_UNSET ("USE_FFMPEG")
632
633 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG")
634 OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG")
635endif()
636
b8ef513c 637# OpenGL
638if (CAN_USE_OPENGL)
b8ef513c 639 if (USE_OPENGL)
640 add_definitions (-DHAVE_OPENGL_EXT)
bbc5899a 641 else()
642 list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGl)
643 list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGlTest)
b8ef513c 644 endif()
645else()
646 OCCT_CHECK_AND_UNSET ("USE_OPENGL")
647endif()
648
1ce0716b 649# OpenGL ES 2.0
8bf738e6 650if (CAN_USE_GLES2)
1ce0716b 651 if (USE_GLES2)
b8ef513c 652 add_definitions (-DHAVE_GLES2_EXT)
1ce0716b 653 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl")
b8ef513c 654 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2")
1ce0716b 655 else()
656 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
657 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
658 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
659 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
bbc5899a 660 list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGles)
661 list (REMOVE_ITEM BUILD_TOOLKITS TKOpenGlesTest)
1ce0716b 662 endif()
663else()
664 OCCT_CHECK_AND_UNSET ("USE_GLES2")
665
666 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL")
667 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2")
668 OCCT_CHECK_AND_UNSET ("INSTALL_EGL")
669 OCCT_CHECK_AND_UNSET ("INSTALL_GLES2")
670endif()
671
bbc5899a 672# D3D
673if (USE_D3D)
674 add_definitions (-DHAVE_D3D)
675 #if(MSVC_VERSION LESS 1700)
676 #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
677 #endif()
678else()
679 list (REMOVE_ITEM BUILD_TOOLKITS TKD3DHost)
680 list (REMOVE_ITEM BUILD_TOOLKITS TKD3DHostTest)
681endif()
682
9f33b387 683# TBB
5682a6fa 684if (NOT DEFINED ANDROID AND CAN_USE_TBB)
5682a6fa 685 if (USE_TBB)
686 add_definitions (-DHAVE_TBB)
687 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
688 else()
689 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
690 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
691 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
692 endif()
9f33b387 693else()
5682a6fa 694 OCCT_CHECK_AND_UNSET ("USE_TBB")
695
9f33b387 696 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
697 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
698 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
699endif()
234e52be 700
0a419c51 701# RapidJSON
702# search for CSF_RapidJSON variable in EXTERNLIB of each being used toolkit
703OCCT_IS_PRODUCT_REQUIRED (CSF_RapidJSON CAN_USE_RAPIDJSON)
704if (CAN_USE_RAPIDJSON)
0a419c51 705 if (USE_RAPIDJSON)
706 add_definitions (-DHAVE_RAPIDJSON)
707 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/rapidjson")
708 else()
709 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
710 OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
711 endif()
712else()
713 OCCT_CHECK_AND_UNSET ("USE_RAPIDJSON")
714
715 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
716 OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
717endif()
718
3b1a2e51 719# EIGEN
3b1a2e51 720if (CAN_USE_EIGEN)
3b1a2e51 721 if (USE_EIGEN)
722 add_definitions (-DHAVE_EIGEN)
723 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/eigen")
724 else()
725 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN")
7d7a3e84 726 OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN")
3b1a2e51 727 endif()
728else()
729 OCCT_CHECK_AND_UNSET ("USE_EIGEN")
730
731 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN")
7d7a3e84 732 OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN")
3b1a2e51 733endif()
734
adc33035 735# Doxygen
4b3541c6 736if (BUILD_DOC_Overview)
737 if (NOT DEFINED INSTALL_DOC_Overview)
738 set (INSTALL_DOC_Overview OFF CACHE BOOL "${INSTALL_DOC_Overview_DESCR}")
adc33035 739 endif()
740
4b3541c6 741 if (INSTALL_DOC_Overview)
d26375e2 742 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_DIR_DOC}")
f2e9c853 743
096ef695 744 # create overview.html only for windows
4b3541c6 745 if (WIN32 AND "${INSTALL_DIR_LAYOUT}" STREQUAL "Windows")
d26375e2 746 OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR_DOC}/..")
096ef695 747 endif()
adc33035 748 endif()
749
750 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
751else()
4b3541c6 752 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_Overview")
adc33035 753
754 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
109aa56e 755 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
adc33035 756endif()
757
c4d4fcea 758# bison
109aa56e 759if (BUILD_YACCLEX)
316d77d9 760 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
761else()
762 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
763endif()
764
c4d4fcea 765# flex
109aa56e 766if (BUILD_YACCLEX)
316d77d9 767 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
768else()
769 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
770endif()
771
05ed7ed8 772# qt for inspector and samples
773if (BUILD_Inspector OR BUILD_SAMPLES_QT)
774 # check qt 3rdparty path
775 add_definitions (-DHAVE_QT)
776 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt")
777 message (STATUS "Info: Qt is used by OCCT")
778else()
779 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT")
780 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC")
781 OCCT_CHECK_AND_UNSET ("INSTALL_QT")
782endif()
783
0553a8ea 784# check all 3rdparty include paths
9f33b387 785string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
9f33b387 786if (3RDPARTY_NOT_INCLUDED)
0553a8ea 787 message (FATAL_ERROR "Could not find headers of used third-party products: ${3RDPARTY_NOT_INCLUDED}" )
9f33b387 788endif()
7c633a3e 789
9bb81d6c 790if (3RDPARTY_INCLUDE_DIRS)
791 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
792 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
ada9ef40 793 message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
9bb81d6c 794 include_directories (${3RDPARTY_INCLUDE_DIRS})
795endif()
796
94829f84 797# include <cmake binary folder>/inc
14bbbdcb 798include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE})
94829f84 799
0553a8ea 800# check all 3rdparty library paths
801string (REGEX REPLACE ";" " " 3RDPARTY_NO_LIBS "${3RDPARTY_NO_LIBS}")
802if (3RDPARTY_NO_LIBS)
803 if (BUILD_SHARED_LIBS)
804 message (SEND_ERROR "Could not find libraries of used third-party products: ${3RDPARTY_NO_LIBS}" )
805 else()
806 message (WARNING "Could not find libraries of used third-party products: ${3RDPARTY_NO_LIBS}" )
807 endif()
808endif()
809if (3RDPARTY_LIBRARY_DIRS)
9bb81d6c 810 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
811 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
ada9ef40 812 message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
9bb81d6c 813 link_directories (${3RDPARTY_LIBRARY_DIRS})
814endif()
234e52be 815
0553a8ea 816# report not found 3rdparty dll paths
817string (REGEX REPLACE ";" " " 3RDPARTY_NO_DLLS "${3RDPARTY_NO_DLLS}")
818if (3RDPARTY_NO_DLLS)
819 message (WARNING "Could not find DLLs of used third-party products: ${3RDPARTY_NO_DLLS}" )
820endif()
821
9f33b387 822# build directories
4b3541c6 823if (SINGLE_GENERATOR)
824 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
825 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
826 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}")
827 if (WIN32)
828 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}")
829 endif()
830endif()
831
fa0cbe55 832set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
833set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
834set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 835
316d77d9 836set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
837set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
838set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 839
fa0cbe55 840set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
841set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
842set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 843
c4d4fcea 844if (WIN32)
f2e9c853 845 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
846 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
847 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 848endif()
03c69aec 849
d94d80e5 850string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
851message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
94829f84 852
94829f84 853# collect all the headers to <binary dir>/inc folder
14bbbdcb 854COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CMAKE_SOURCE_DIR}/src" "${INSTALL_DIR_INCLUDE}")
94829f84 855
d94d80e5 856string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
857message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
858
d26375e2 859list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
860if (${DRAWEXE_INDEX} GREATER -1)
861 OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
862 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
863endif()
864
4b3541c6 865if (WIN32)
866 set (SCRIPT_EXT bat)
867else()
868 set (SCRIPT_EXT sh)
869endif()
03c69aec 870
14bbbdcb 871# OCCT tools
872# include the patched or original list of tools
873# list <TOOLNAME>_TOOLKITS is created foreach tool and contains its toolkits
874# list <OCCT_TOOLS> will contain all tools
1fa16152 875if (BUILD_Inspector)
ae5225df 876 add_definitions (-DHAVE_Inspector)
877
1fa16152 878 OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS)
14bbbdcb 879 foreach (OCCT_TOOL ${OCCT_TOOLS})
880 list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS})
881 endforeach()
882
1fa16152 883 # collect all the headers to <binary dir>/inc/inspector folder
14bbbdcb 884 string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
1fa16152 885 message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/inc/inspector ...")
0cb512c0 886 COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector")
14bbbdcb 887endif()
888
096ef695 889# OCCT samples
d26375e2 890# get absolute path from INSTALL_DIR
891set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}")
892if(NOT IS_ABSOLUTE "${INSTALL_DIR_ABSOLUTE}")
893 get_filename_component(INSTALL_DIR_ABSOLUTE "${CMAKE_BINARY_DIR}/${INSTALL_DIR}" ABSOLUTE)
894endif()
895
0e617b05 896if (INSTALL_SAMPLES)
4b3541c6 897 OCCT_CONFIGURE ("adm/templates/env.samples.${SCRIPT_EXT}.in" "env.samples.${SCRIPT_EXT}")
096ef695 898 if (WIN32)
d26375e2 899 OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR_SAMPLES}")
900 OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR_SAMPLES}")
4b3541c6 901
742cc8b0 902 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
d26375e2 903 OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR_SAMPLES}")
742cc8b0 904 endif()
905
d26375e2 906 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}")
907 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}")
096ef695 908 endif()
03c69aec 909
d26375e2 910 OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR_SAMPLES}")
911 OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR_SAMPLES}")
912 OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR_SAMPLES}")
c4d4fcea 913 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code" "${INSTALL_DIR_SAMPLES}/OCCTOverview")
096ef695 914
d26375e2 915 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}")
916 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}")
c4d4fcea 917 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/OCCTOverview" RENAME "env.${SCRIPT_EXT}")
d26375e2 918 install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}")
910970ab 919endif()
03c69aec 920
4b3541c6 921if (INSTALL_TEST_CASES)
d26375e2 922 OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR_TESTS}")
910970ab 923endif()
03c69aec 924
3eabbe1b 925list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
926if (${DRAWEXE_INDEX} GREATER -1)
927 # copy data and samples/tcl folders to install script folder
d26375e2 928 OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}")
929 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}")
096ef695 930
3eabbe1b 931 # copy draw script to install script folder
932 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
d26375e2 933 install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
3eabbe1b 934 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
935 else()
d26375e2 936 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
3eabbe1b 937 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
938 endif()
939
940 # copy draw script to CMake binary folder
941 OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
942endif()
9f33b387 943
316d77d9 944set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 945
910970ab 946if (WIN32)
4b3541c6 947 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %1 %2 %3 \n)")
910970ab 948else()
096ef695 949 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
910970ab 950endif()
32856b63 951
910970ab 952 # change custom.bat/sh
4b3541c6 953if (EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}")
954 file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 955
910970ab 956 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 957
4b3541c6 958 file (WRITE "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
910970ab 959else()
d26375e2 960 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
910970ab 961endif()
32856b63 962
249dd6ed 963if (WIN32)
964 set (THIRDPARTY_DIR_REPLACE "%THIRDPARTY_DIR%")
965else()
966 set (THIRDPARTY_DIR_REPLACE "\${THIRDPARTY_DIR}")
967endif()
968get_cmake_property(USED_3RDPARTY_CACHE_VARIABLES VARIABLES)
969string (REGEX MATCHALL "(^|;)USED_3RDPARTY_[^;]+_DIR[^;]*" USED_3RDPARTY_CACHE_VARIABLES "${USED_3RDPARTY_CACHE_VARIABLES}")
970file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
971foreach (USED_3RDPARTY_CACHE_VARIABLE ${USED_3RDPARTY_CACHE_VARIABLES})
972 file (TO_CMAKE_PATH "${${USED_3RDPARTY_CACHE_VARIABLE}}" ${USED_3RDPARTY_CACHE_VARIABLE})
973 string (REPLACE "${3RDPARTY_DIR}" "${THIRDPARTY_DIR_REPLACE}" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
974 if (NOT WIN32)
975 string (REGEX REPLACE ";" ":" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
976 endif()
977endforeach()
978
316d77d9 979# write current custom.bat/sh (for install directory)
980set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
d26375e2 981OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}")
03c69aec 982
316d77d9 983# write current custom.bat/sh (for build directory)
984OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
985
510d9690 986if (BUILD_SAMPLES_MFC OR BUILD_SAMPLES_QT)
6664a9c2 987 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
988 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
9f33b387 989endif()
990
798a95ed 991if (WIN32)
992 # env script for draw in building environment
993 OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
994 # install env script
995 install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}")
a75f5cdd 996 # copy build.bat and install.bat scripts to CMake binary folder
997 OCCT_COPY_FILE_OR_DIR ("adm/templates/build.bat" "${CMAKE_BINARY_DIR}")
998 OCCT_COPY_FILE_OR_DIR ("adm/templates/install.bat" "${CMAKE_BINARY_DIR}")
798a95ed 999else()
1000 set (SUB_ENV_NAME "env.${SCRIPT_EXT}")
1001 set (SUB_ENV_BUILD_NAME "env.install.${SCRIPT_EXT}")
1002 # install env script
1003 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.install.${SCRIPT_EXT}.in" "${SUB_ENV_BUILD_NAME}" "${SUB_ENV_NAME}" "${INSTALL_DIR_SCRIPT}")
1004 # env script for draw in building environment
1005 OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
1006endif()
316d77d9 1007
1008# copy DrawAppliInit from OCCT source to build directory
f2e9c853 1009if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
1010 OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
316d77d9 1011endif()
910970ab 1012
9f33b387 1013# RESOURCES
19286d7c 1014FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
1015foreach(RESOURCE ${RESOURCES})
1016 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
1017 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
1018 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
d26375e2 1019 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}")
19286d7c 1020 else()
d26375e2 1021 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}")
19286d7c 1022 endif()
1023endforeach()
03c69aec 1024
510d9690 1025if (BUILD_SAMPLES_QT)
1fa16152 1026 FILE_TO_LIST ("adm/SAMPLES_RESOURCES" SAMPLES_RESOURCES)
1027 foreach(RESOURCE ${SAMPLES_RESOURCES})
1028 OCCT_INSTALL_FILE_OR_DIR ("samples/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/samples")
1029 #message("Copy Sample resources: samples/${RESOURCE} into ${INSTALL_DIR_RESOURCE}/samples")
1030 endforeach()
c4d4fcea 1031
1032 ## Copy sources of OCCTOverview for using in the sample
1033 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/DataExchangeSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1034 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/OcafSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1035 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/GeometrySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1036 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TopologySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1037 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TriangulationSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1038 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer2dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1039 OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer3dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
1fa16152 1040endif()
1041
1042
46bd680a 1043# patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed
1044if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
1045 OCCT_UPDATE_DRAW_DEFAULT_FILE()
1046endif()
1047
33839ae6 1048# include patched toolkit projects or original ones
316d77d9 1049foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
f2e9c853 1050 OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
19286d7c 1051endforeach()
234e52be 1052
4b3541c6 1053if (BUILD_DOC_Overview)
f2e9c853 1054 OCCT_ADD_SUBDIRECTORY (dox)
adc33035 1055endif()
1056
94829f84 1057# patch DRAWEXE
1058if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 1059 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 1060 if (${DRAWEXE_INDEX} GREATER -1)
1061 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
1062 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
1063
1064 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
1065 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
1066 endforeach()
1067
1068 OCCT_MAKE_COMPILER_BITNESS()
1069 set (X_COMPILER_BITNESS "x64")
1070 if ("${COMPILER_BITNESS}" STREQUAL "32")
1071 set (X_COMPILER_BITNESS "Win32")
1072 endif()
1073
f2e9c853 1074 OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
94829f84 1075 endif()
1076endif()
1077
14bbbdcb 1078# include patched toolkit projects or original ones
1079if (BUILD_TOOL_TOOLKITS)
1080 foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS})
1081 OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}")
1082 endforeach()
1083endif()
896faa72 1084
14bbbdcb 1085message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
33839ae6 1086# samples do not support patch usage
510d9690 1087if (BUILD_SAMPLES_MFC OR BUILD_SAMPLES_QT)
19286d7c 1088 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
1fa16152 1089endif()
234e52be 1090
510d9690 1091if (BUILD_SAMPLES_MFC)
19286d7c 1092 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
1093 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 1094
9f33b387 1095 add_subdirectory(samples/mfc/standard/mfcsample)
1096 add_subdirectory(samples/mfc/standard/01_Geometry)
1097 add_subdirectory(samples/mfc/standard/02_Modeling)
1098 add_subdirectory(samples/mfc/standard/03_Viewer2d)
1099 add_subdirectory(samples/mfc/standard/04_Viewer3d)
1100 add_subdirectory(samples/mfc/standard/05_ImportExport)
1101 add_subdirectory(samples/mfc/standard/06_Ocaf)
1102 add_subdirectory(samples/mfc/standard/07_Triangulation)
1103 add_subdirectory(samples/mfc/standard/08_HLR)
1104 add_subdirectory(samples/mfc/standard/09_Animation)
1105 add_subdirectory(samples/mfc/standard/10_Convert)
896faa72 1106
1107 message (STATUS "Info: \(${CURRENT_TIME}\) MFC Sample projects added")
19286d7c 1108endif()
2e48c1cb 1109
1fa16152 1110OCCT_MODULES_AND_TOOLKITS (SAMPLES "SAMPLES_TOOLKITS" OCCT_SAMPLES)
1111
510d9690 1112if (BUILD_Inspector OR BUILD_SAMPLES_QT)
1113 if (BUILD_SAMPLES_QT)
6822a3be 1114 if (NOT Qt5_FOUND OR "${Qt5Gui_EGL_INCLUDE_DIRS}" STREQUAL "" OR NOT WIN32)
6664a9c2 1115 list (REMOVE_ITEM qt_SAMPLES_TOOLKITS AndroidQt)
6822a3be 1116 message (STATUS "Info: AndroidQt sample excluded due to OS is not Windows or Qt is configured without ANGLE")
6664a9c2 1117 endif()
1118 else()
1119 list (REMOVE_ITEM OCCT_SAMPLES qt)
510d9690 1120 message (STATUS "Info: qt samples excluded due to BUILD_SAMPLES_QT is disabled")
1fa16152 1121 endif()
1122
1fa16152 1123 foreach (OCCT_SAMPLE ${OCCT_SAMPLES})
1124 list (APPEND BUILD_SAMPLE_TOOLKITS ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
1125
1126 # collect all the headers to <binary dir>/inc/samples folder
1127 string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
1128 message (STATUS "Info: \(${CURRENT_TIME}\) ${OCCT_SAMPLE} Sample projects added")
1129
1130 # include patched toolkit projects or original ones
1131 foreach (BUILD_SAMPLE_TOOLKIT ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
1132 OCCT_ADD_SUBDIRECTORY ("samples/${OCCT_SAMPLE}/${BUILD_SAMPLE_TOOLKIT}")
1133 endforeach()
1134 endforeach()
1135endif()
1136
742cc8b0 1137if (BUILD_MODULE_UwpSample)
1138 add_subdirectory(samples/xaml)
1139endif()
1140
14bbbdcb 1141if (BUILD_TOOL_TOOLKITS)
1142 # copy tinspector script to install script folder
4f4b8935 1143 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}")
1144 install (FILES "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
14bbbdcb 1145 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
1146 else()
4f4b8935 1147 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
14bbbdcb 1148 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
1149 endif()
1150
ae5225df 1151 set (OpenCASCADE_BINARY_DIR "${INSTALL_DIR}/${INSTALL_DIR_BIN}")
4f4b8935 1152 # patch TInspectorEXE
ae5225df 1153 OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/tools/TInspectorEXE/TInspectorEXE.vcxproj.user")
14bbbdcb 1154endif()
1155
2e48c1cb 1156# Prepare variables for configuration of OpenCASCADE cmake config file
1157set (OCCT_MODULES_ENABLED)
1158set (OCCT_LIBRARIES)
ada9ef40 1159set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n")
a3d2cb24 1160set (OCCT_COMPILE_DEFINITIONS)
1161
2e48c1cb 1162foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS})
1163 if (TARGET ${OCCT_TOOLKIT})
1164
1165 # get all libraries
1166 get_target_property (${OCCT_TOOLKIT}_TYPE ${OCCT_TOOLKIT} "TYPE")
1167 if ("${${OCCT_TOOLKIT}_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${${OCCT_TOOLKIT}_TYPE}" STREQUAL "SHARED_LIBRARY" )
1168 list (APPEND OCCT_LIBRARIES ${OCCT_TOOLKIT})
2e48c1cb 1169
ada9ef40 1170 # get all modules
1171 get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE")
1172 list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE})
1173 list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT})
a3d2cb24 1174
1175 # get compile definitions of target directory
1176 get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS")
1177 list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS})
2e48c1cb 1178 endif()
1179 endif()
1180endforeach()
1181list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED)
a3d2cb24 1182list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS)
b8ef513c 1183# these macros are defined for specific tookits, not globalwise
1184list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_OPENGL)
1185list (REMOVE_ITEM OCCT_COMPILE_DEFINITIONS HAVE_GLES2)
a3d2cb24 1186
1187# export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files
1188foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
1189 set (SET_OpenCASCADE_COMPILE_DEFINITIONS)
1190 string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER)
1191 string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER)
1192 foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS})
1193 string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
1194 string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}")
1195 set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${OCCT_CONFIGURATION}>:${COMPILE_DEFINITION}>)\n")
1196 endforeach()
1197 set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
1198 set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}")
1199 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY)
1200endforeach()
1201# install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration
1202install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)")
1203install (CODE "configure_file(\"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" COPYONLY)")
2e48c1cb 1204
ada9ef40 1205foreach (OCCT_MODULE ${OCCT_MODULES})
1206 if (BUILD_MODULE_${OCCT_MODULE})
1207 set (SET_OpenCASCADE_MODULES_TOOLKITS "${SET_OpenCASCADE_MODULES_TOOLKITS}set (OpenCASCADE_${OCCT_MODULE}_LIBRARIES ${OpenCASCADE_${OCCT_MODULE}_TOOLKITS})\n")
1208 endif()
f7ac9097 1209
1210 # sort enabled modules for correct work of OpenCASCADE config file
1211 list(FIND OCCT_MODULES_ENABLED "${OCCT_MODULE}" OCCT_MODULE_INDEX)
1212 if (NOT ${OCCT_MODULE_INDEX} EQUAL -1)
1213 list (APPEND OCCT_MODULES_ENABLED_SORTED ${OCCT_MODULE})
1214 endif()
ada9ef40 1215endforeach()
f7ac9097 1216set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED})
ada9ef40 1217
1218# Add all targets to the build-tree export set
1219export (TARGETS ${OCCT_LIBRARIES} FILE "${CMAKE_BINARY_DIR}/OpenCASCADETargets.cmake")
1220
1221# Export the package for use from the build-tree
1222# (this registers the build-tree with a global CMake-registry)
1223export(PACKAGE OpenCASCADE)
1224
2e48c1cb 1225if (CMAKE_BUILD_TYPE)
1226 set (SET_OpenCASCADE_BUILD_TYPE "set (OpenCASCADE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
1227endif()
1228
1229if (BUILD_SHARED_LIBS)
1230 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS}\")")
1231else()
1232 set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_STATIC_LINKER_FLAGS}\")")
1233endif()
1234
1235if (WIN32)
1236 set (SET_OpenCASCADE_WITH_D3D "set (OpenCASCADE_WITH_D3D ${USE_D3D})")
1237endif()
1238if (APPLE)
b69e576a 1239 set (SET_OpenCASCADE_WITH_GLX "set (OpenCASCADE_WITH_GLX ${USE_XLIB})")
2e48c1cb 1240endif()
1241
1242# Configure and install cmake config file
ada9ef40 1243configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADEConfig.cmake.in" "OpenCASCADEConfig.cmake" @ONLY)
d26375e2 1244install(FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfig.cmake" DESTINATION "${INSTALL_DIR_CMAKE}")
2e48c1cb 1245
1246# Configure cmake version file
1247include(CMakePackageConfigHelpers)
1248write_basic_package_version_file( ${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake
1249 VERSION ${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}
1250 COMPATIBILITY ExactVersion )
1251
1252# Install cmake version file
d26375e2 1253install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR_CMAKE}")
ada9ef40 1254
1255# Install the export set for use with the install-tree for each configuration
f7ac9097 1256foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED})
1257 install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}")
ada9ef40 1258endforeach()
1259
c4d4fcea 1260# Update generated OpenCASCADETargets-*.cmake files
ada9ef40 1261# to have correct paths to libraries depending on the configuration
1262OCCT_UPDATE_TARGET_FILE ()
896faa72 1263
1264message (STATUS "Info: \(${CURRENT_TIME}\) OCCT configuration files prepared")