0026916: Configuration, CMake - configure variables to customize installation path...
[occt.git] / CMakeLists.txt
CommitLineData
19286d7c 1cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
166d6cd7 2
576f8b11 3set (CMAKE_SUPPRESS_REGENERATION TRUE)
4
fa0cbe55 5set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
03c69aec 6
316d77d9 7# macro: include patched file if it exists
8macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
109aa56e 9 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake")
10 include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 11 else()
f2e9c853 12 include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
316d77d9 13 endif()
14endmacro()
15
16# include variable description
17OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr")
18
c259930b 19# set type of OCCT libraries
20if (NOT BUILD_LIBRARY_TYPE)
316d77d9 21 set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE)
c259930b 22 SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
23endif()
24
25if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
26 set (BUILD_SHARED_LIBS ON)
27else()
28 unset (BUILD_SHARED_LIBS)
29endif()
30
9f33b387 31# the name of the project
32project (OCCT)
03c69aec 33
096ef695 34# include occt macros
35OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
36
9f33b387 37# Solution folder property
38set_property (GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 39
096ef695 40# get current OCCT version
41OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
42
43set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR})
44set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR})
45set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE})
46
0e617b05 47set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}")
096ef695 48
49# single-configuration generator
50set (SINGLE_GENERATOR OFF)
51if (CMAKE_BUILD_TYPE)
52 set (SINGLE_GENERATOR ON)
53endif()
54
316d77d9 55# a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable
56# check this variable and set if it's required
57if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator.
58 set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
19286d7c 59endif()
60
898f6a92 61# enable extended messages of many OCCT algorithms
109aa56e 62set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}")
63if (BUILD_WITH_DEBUG)
898f6a92 64 add_definitions (-DOCCT_DEBUG)
65endif()
316d77d9 66
19286d7c 67# copy samples to install directory
0e617b05 68set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}")
19286d7c 69
096ef695 70# install dir of the project
71if (NOT DEFINED INSTALL_DIR)
72 set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
73endif()
74
75if ("${INSTALL_DIR}" STREQUAL "")
76 get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
77 set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
78 message (STATUS "Info: INSTALL_DIR has been set as ${INSTALL_DIR}")
79endif()
80
81# hide CMAKE_INSTALL_PREFIX from a user
82set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
83
84set (BIN_LETTER "")
85if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
86 set (BIN_LETTER "d")
87elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
88 set (BIN_LETTER "i")
89endif()
03c69aec 90
096ef695 91# Get all used variables: OS_WITH_BIT, COMPILER
92OCCT_MAKE_OS_WITH_BITNESS()
93OCCT_MAKE_COMPILER_SHORT_NAME()
94
95# do not define INSTALL_BIN_DIR for win.
96# Leave library structure for win: <prefix>/win64/vc10/bin(d)
97if (NOT DEFINED INSTALL_BIN_DIR)
98 if (UNIX)
99 set (INSTALL_BIN_DIR "${INSTALL_DIR}/bin" CACHE PATH "${INSTALL_BIN_DIR_DESCR}")
100 else()
101 if (SINGLE_GENERATOR)
102 set (INSTALL_BIN_DIR "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}" CACHE PATH "${INSTALL_BIN_DIR_DESCR}")
103 endif()
104 endif()
105endif()
106
107# define folder contaning all shell/batch scripts
108if (NOT DEFINED INSTALL_SCRIPT_DIR)
109 if (UNIX)
110 set (INSTALL_SCRIPT_DIR "${INSTALL_BIN_DIR}/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_SCRIPT_DIR_DESCR}")
111 else()
112 set (INSTALL_SCRIPT_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_SCRIPT_DIR_DESCR}")
113 endif()
114endif()
115
116# place the libraries to <prefix>/lib folder for unix and leave old structure for windows
117if (NOT DEFINED INSTALL_LIB_DIR)
118 if (UNIX)
119 set (INSTALL_LIB_DIR "${INSTALL_DIR}/lib" CACHE PATH "${INSTALL_LIB_DIR_DESCR}")
120 else()
121 if (SINGLE_GENERATOR)
122 set (INSTALL_LIB_DIR "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}" CACHE PATH "${INSTALL_LIB_DIR_DESCR}")
123 endif()
124 endif()
125endif()
126
127# OCCT headers: <prefix>/inc for windows,
128# <prefix>/include/opencascade-7.0.0 for unix
129if (NOT DEFINED INSTALL_INCLUDE_DIR)
130 if (UNIX)
131 set (INSTALL_INCLUDE_DIR "${INSTALL_DIR}/include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_INCLUDE_DIR_DESCR}")
132 else()
133 set (INSTALL_INCLUDE_DIR "${INSTALL_DIR}/inc" CACHE PATH "${INSTALL_INCLUDE_DIR_DESCR}")
134 endif()
135endif()
136
137# OCCT resources: <prefix>/src for windows,
138# <prefix>/share/opencascade-7.0.0/resources for unix
139if (NOT DEFINED INSTALL_OCCT_RESOURCE_DIR)
140 if (UNIX)
141 set (INSTALL_OCCT_RESOURCE_DIR "${INSTALL_DIR}/share/opencascade-${OCC_VERSION_STRING_EXT}/resoures" CACHE PATH "${INSTALL_OCCT_RESOURCE_DIR_DESCR}")
142 else()
143 set (INSTALL_OCCT_RESOURCE_DIR "${INSTALL_DIR}/src" CACHE PATH "${INSTALL_OCCT_RESOURCE_DIR_DESCR}")
144 endif()
145endif()
146
147# OCCT data
148if (NOT DEFINED INSTALL_SHARE_DIR)
149 if (UNIX)
150 set (INSTALL_SHARE_DIR "${INSTALL_DIR}/share/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_SHARE_DIR_DESCR}")
151 else()
152 set (INSTALL_SHARE_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_SHARE_DIR_DESCR}")
153 endif()
154endif()
155
156# a directory recognized as a 'patch' for OCCT
109aa56e 157set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}")
03c69aec 158
9f33b387 159# the list of being built toolkits
316d77d9 160set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
161separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 162
ad211ad3 163if (MSVC)
316d77d9 164 set (BUILD_MODULE_OcctMfcSamples OFF CACHE BOOL "${BUILD_MODULE_OcctMfcSamples_DESCR}")
85bcc072 165endif()
166
9f33b387 167# whether use optional 3rdparty or not
168if (APPLE)
316d77d9 169 set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
03c69aec 170endif()
096ef695 171
f60111dc 172if (WIN32)
173 set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
174endif()
85bcc072 175
9f33b387 176# include the patched or original list of modules
19286d7c 177# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
178# list <OCCT_MODULES> will contain all modules
179OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
03c69aec 180
316d77d9 181foreach (OCCT_MODULE ${OCCT_MODULES})
182 BUILD_MODULE (${OCCT_MODULE})
19286d7c 183endforeach()
184
e713baee 185if (ANDROID AND BUILD_MODULE_Draw)
186 message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
187 set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
188endif()
189
adc33035 190# Overview
316d77d9 191set (BUILD_DOC_OcctOverview OFF CACHE BOOL "${BUILD_DOC_OcctOverview_DESCR}")
adc33035 192
f60111dc 193if (NOT USE_D3D)
194 list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost)
195endif()
196
316d77d9 197# accumulate used toolkits (first level) in BUILD_TOOLKITS variable
198list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
19286d7c 199
316d77d9 200foreach (OCCT_MODULE ${OCCT_MODULES})
201 if (BUILD_MODULE_${OCCT_MODULE})
202 list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
19286d7c 203 endif()
204endforeach()
205
206# DRAWEXE excluded when library build is static
207if (NOT BUILD_SHARED_LIBS)
316d77d9 208 list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE)
19286d7c 209 message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
210endif()
211
212# accumulate all used toolkits
316d77d9 213list (REMOVE_DUPLICATES BUILD_TOOLKITS)
214set (RAW_BUILD_TOOLKITS)
096ef695 215foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
316d77d9 216 OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS)
217 list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS})
19286d7c 218endforeach()
219
316d77d9 220list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
221set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
03c69aec 222
9f33b387 223# include the patched or original list of definitions and flags
19286d7c 224OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
03c69aec 225
19286d7c 226OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
03c69aec 227
a6874708 228# search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS
229list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK)
230if (CAN_USE_VTK EQUAL -1)
231 list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK)
232endif()
233
234if (NOT CAN_USE_VTK EQUAL -1)
235 if (NOT DEFINED USE_VTK)
236 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
237 endif()
238else()
239 OCCT_CHECK_AND_UNSET (USE_VTK)
240endif()
241
5682a6fa 242# Rebuild *.yacc and *.lex files that are contained by TKMath toolkit
243list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH)
244list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE)
245
fb3267c7 246if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1)
109aa56e 247 set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}")
5682a6fa 248else()
109aa56e 249 OCCT_CHECK_AND_UNSET (BUILD_YACCLEX)
5682a6fa 250endif()
251
9f33b387 252if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 253 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
e713baee 254 get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
9f33b387 255endif()
234e52be 256
9f33b387 257# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
f2e9c853 258OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
03c69aec 259
fb3267c7 260if (USE_TCL)
5682a6fa 261 message (STATUS "Info: TCL is used by OCCT")
19286d7c 262 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
82f443b6 263
264 message (STATUS "Info: TK is used by OCCT")
265 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
9f33b387 266else()
9ccea0c6 267 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
268 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
5682a6fa 269
270 OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
82f443b6 271 OCCT_CHECK_AND_UNSET ("INSTALL_TK")
9f33b387 272endif()
03c69aec 273
9f33b387 274# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
f2e9c853 275OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE)
03c69aec 276
fb3267c7 277if (USE_FREETYPE)
5682a6fa 278 message (STATUS "Info: Freetype is used by OCCT")
19286d7c 279 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
9f33b387 280else()
9ccea0c6 281 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 282 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
283 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
5682a6fa 284 OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
9f33b387 285endif()
03c69aec 286
09c597c9 287# VTK
288if (USE_VTK)
289 add_definitions (-DHAVE_VTK)
19286d7c 290 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
f2e9c853 291else()
292 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
a6874708 293
294 if (NOT CAN_USE_VTK EQUAL -1)
295 message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
296
297 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk)
298 list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw)
299 endif()
09c597c9 300endif()
301
f60111dc 302# D3D
303if (USE_D3D)
304 add_definitions (-DHAVE_D3D)
305 #if(MSVC_VERSION LESS 1700)
306 #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d")
307 #endif()
308endif()
309
09c597c9 310# GLX
311if (USE_GLX)
312 add_definitions (-DMACOSX_USE_GLX)
19286d7c 313 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
09c597c9 314endif()
315
03c69aec 316# FREEIMAGE
5682a6fa 317# search for CSF_FREEIMAGE variable in EXTERNLIB of each being used toolkit
318OCCT_IS_PRODUCT_REQUIRED (CSF_FREEIMAGE CAN_USE_FREEIMAGE)
319OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGEPLUS)
320
321if (CAN_USE_FREEIMAGE OR CAN_USE_FREEIMAGEPLUS)
322 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
323
324 if (USE_FREEIMAGE)
325 add_definitions (-DHAVE_FREEIMAGE)
326 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
327 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
328 else()
329 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
330 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
331 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
332 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
333 endif()
9f33b387 334else()
5682a6fa 335 OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE")
336
9f33b387 337 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
338 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
339 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
340 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
341endif()
03c69aec 342
343# GL2PS
5682a6fa 344# search for CSF_GL2PS variable in EXTERNLIB of each being used toolkit
345OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS)
346
347if (NOT DEFINED ANDROID AND CAN_USE_GL2PS)
348 set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
349
350 if (USE_GL2PS)
351 add_definitions (-DHAVE_GL2PS)
352 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
353 else()
354 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
355 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
356 endif()
9f33b387 357else()
5682a6fa 358 OCCT_CHECK_AND_UNSET ("USE_GL2PS")
359
9f33b387 360 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
361 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
362endif()
03c69aec 363
9f33b387 364# TBB
5682a6fa 365# search for CSF_TBB variable in EXTERNLIB of each being used toolkit
366OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
367
368if (NOT DEFINED ANDROID AND CAN_USE_TBB)
369 set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
370
371 if (USE_TBB)
372 add_definitions (-DHAVE_TBB)
373 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
374 else()
375 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
376 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
377 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
378 endif()
9f33b387 379else()
5682a6fa 380 OCCT_CHECK_AND_UNSET ("USE_TBB")
381
9f33b387 382 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
383 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
384 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
385endif()
234e52be 386
adc33035 387# Doxygen
316d77d9 388if (BUILD_DOC_OcctOverview)
389 if (NOT DEFINED INSTALL_DOC_OcctOverview)
390 set (INSTALL_DOC_OcctOverview OFF CACHE BOOL "${INSTALL_DOC_OcctOverview_DESCR}")
adc33035 391 endif()
392
316d77d9 393 if (INSTALL_DOC_OcctOverview)
096ef695 394 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_SHARE_DIR}/doc")
f2e9c853 395
096ef695 396 # create overview.html only for windows
397 if (WIN32)
398 OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_SCRIPT_DIR}")
399 endif()
adc33035 400 endif()
401
402 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
403else()
316d77d9 404 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_OcctOverview")
adc33035 405
406 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
109aa56e 407 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
adc33035 408endif()
409
316d77d9 410# bison
109aa56e 411if (BUILD_YACCLEX)
316d77d9 412 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
413else()
414 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
415endif()
416
417# flex
109aa56e 418if (BUILD_YACCLEX)
316d77d9 419 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
420else()
421 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
422endif()
423
9f33b387 424string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 425
9f33b387 426# check all 3rdparty paths
427if (3RDPARTY_NOT_INCLUDED)
428 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
429endif()
7c633a3e 430
9bb81d6c 431if (3RDPARTY_INCLUDE_DIRS)
432 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
433 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
a6874708 434 message (STATUS "Info: The directories of 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
9bb81d6c 435 include_directories (${3RDPARTY_INCLUDE_DIRS})
436endif()
437
94829f84 438# include <cmake binary folder>/inc
439include_directories (${CMAKE_BINARY_DIR}/inc)
440
9bb81d6c 441if (3RDPARTY_LIBRARY_DIRS)
442 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
443 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
a6874708 444 message (STATUS "Info: The directories of 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
9bb81d6c 445 link_directories (${3RDPARTY_LIBRARY_DIRS})
446endif()
234e52be 447
9f33b387 448# build directories
fa0cbe55 449set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
450set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
451set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 452
316d77d9 453set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
454set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
455set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 456
fa0cbe55 457set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
458set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
459set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 460
fa0cbe55 461if (WIN32)
f2e9c853 462 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
463 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
464 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 465endif()
03c69aec 466
d94d80e5 467string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
468message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
94829f84 469
94829f84 470# collect all the headers to <binary dir>/inc folder
f2e9c853 471COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
94829f84 472
d94d80e5 473string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
474message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
475
096ef695 476OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_SHARE_DIR}")
03c69aec 477
096ef695 478# OCCT samples
0e617b05 479if (INSTALL_SAMPLES)
096ef695 480 if (WIN32)
481 OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_SHARE_DIR}/samples")
482 OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_SHARE_DIR}/samples")
483 endif()
484
485 OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_SHARE_DIR}/samples")
486 OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_SHARE_DIR}/samples")
487 OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_SHARE_DIR}/samples")
910970ab 488endif()
03c69aec 489
096ef695 490OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_SHARE_DIR}/samples")
491
0e617b05 492if (INSTALL_TEST_CASES)
096ef695 493 OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_SHARE_DIR}")
910970ab 494endif()
03c69aec 495
910970ab 496if (WIN32)
497 set (SCRIPT_EXT bat)
498else()
499 set (SCRIPT_EXT sh)
500endif()
03c69aec 501
096ef695 502# copy draw script to install script folder
109aa56e 503if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}")
096ef695 504 install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_SCRIPT_DIR}"
505 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
910970ab 506else()
096ef695 507 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_SCRIPT_DIR}"
508 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
910970ab 509endif()
096ef695 510
511# copy draw script to CMake binary folder
910970ab 512OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
9f33b387 513
316d77d9 514set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 515
910970ab 516if (WIN32)
316d77d9 517 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %VCVER% %ARCH% %CASDEB% \n)")
910970ab 518else()
096ef695 519 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi")
910970ab 520endif()
32856b63 521
910970ab 522 # change custom.bat/sh
096ef695 523if (EXISTS "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}")
524 file (READ "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 525
910970ab 526 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 527
096ef695 528 file (WRITE "${INSTALL_BIN_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
910970ab 529else()
096ef695 530 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_SCRIPT_DIR}")
910970ab 531endif()
32856b63 532
316d77d9 533# write current custom.bat/sh (for install directory)
534set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
096ef695 535OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_SCRIPT_DIR}")
03c69aec 536
316d77d9 537# write current custom.bat/sh (for build directory)
538OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
539
540if (BUILD_MODULE_OcctMfcSamples)
096ef695 541 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_SCRIPT_DIR}")
f2e9c853 542 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
9f33b387 543endif()
544
316d77d9 545# env script for draw in building environment
910970ab 546OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
316d77d9 547
548# end script for draw in standalone environment
096ef695 549if (UNIX)
550 OCCT_CONFIGURE ("adm/templates/env.install.sh.in" "env.install.sh")
551 install (FILES "${CMAKE_BINARY_DIR}/env.install.sh" DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.sh")
552else()
553 # release version
554 set (CURRENT_BUILD_LETTER "")
555 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.release.bat")
556 install (FILES "${CMAKE_BINARY_DIR}/env.install.release.bat"
557 CONFIGURATIONS Release
558 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
559
560 # debug version
561 set (CURRENT_BUILD_LETTER "d")
562 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.debug.bat")
563 install (FILES "${CMAKE_BINARY_DIR}/env.install.debug.bat"
564 CONFIGURATIONS Debug
565 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
566
567 # release with debug info version
568 set (CURRENT_BUILD_LETTER "i")
569 OCCT_CONFIGURE ("adm/templates/env.install.bat.in" "env.install.relwithdebinfo.bat")
570 install (FILES "${CMAKE_BINARY_DIR}/env.install.relwithdebinfo.bat"
571 CONFIGURATIONS RelWithDebInfo
572 DESTINATION "${INSTALL_SCRIPT_DIR}" RENAME "env.bat")
573endif()
316d77d9 574
575# copy DrawAppliInit from OCCT source to build directory
f2e9c853 576if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
577 OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}")
316d77d9 578endif()
910970ab 579
9f33b387 580# RESOURCES
19286d7c 581FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
582foreach(RESOURCE ${RESOURCES})
583 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
584 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
585 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
096ef695 586 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_OCCT_RESOURCE_DIR}/${RESOURCE_FOLDER}")
19286d7c 587 else()
096ef695 588 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_OCCT_RESOURCE_DIR}")
19286d7c 589 endif()
590endforeach()
03c69aec 591
fb3267c7 592# define CSF variable
593OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
594
33839ae6 595# include patched toolkit projects or original ones
316d77d9 596foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
f2e9c853 597 OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
19286d7c 598endforeach()
234e52be 599
316d77d9 600if (BUILD_DOC_OcctOverview)
f2e9c853 601 OCCT_ADD_SUBDIRECTORY (dox)
adc33035 602endif()
603
94829f84 604# patch DRAWEXE
605if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 606 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 607 if (${DRAWEXE_INDEX} GREATER -1)
608 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
609 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
610
611 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
612 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
613 endforeach()
614
615 OCCT_MAKE_COMPILER_BITNESS()
616 set (X_COMPILER_BITNESS "x64")
617 if ("${COMPILER_BITNESS}" STREQUAL "32")
618 set (X_COMPILER_BITNESS "Win32")
619 endif()
620
f2e9c853 621 OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
94829f84 622 endif()
623endif()
624
33839ae6 625# samples do not support patch usage
316d77d9 626if (BUILD_MODULE_OcctMfcSamples)
19286d7c 627 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
234e52be 628
19286d7c 629 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
630 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 631
9f33b387 632 add_subdirectory(samples/mfc/standard/mfcsample)
633 add_subdirectory(samples/mfc/standard/01_Geometry)
634 add_subdirectory(samples/mfc/standard/02_Modeling)
635 add_subdirectory(samples/mfc/standard/03_Viewer2d)
636 add_subdirectory(samples/mfc/standard/04_Viewer3d)
637 add_subdirectory(samples/mfc/standard/05_ImportExport)
638 add_subdirectory(samples/mfc/standard/06_Ocaf)
639 add_subdirectory(samples/mfc/standard/07_Triangulation)
640 add_subdirectory(samples/mfc/standard/08_HLR)
641 add_subdirectory(samples/mfc/standard/09_Animation)
642 add_subdirectory(samples/mfc/standard/10_Convert)
19286d7c 643endif()