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