0026593: Coding rules - revert compatibility of NCollection_CellFilter constructor...
[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)
9 if (NOT "${APPLY_OCCT_PATCH_DIR}" STREQUAL "" AND EXISTS "${APPLY_OCCT_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
10 include (${APPLY_OCCT_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
11 else()
12 include (${BEING_INCLUDED_FILE}.cmake)
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
316d77d9 37set (INSTALL_OCCT_TEST_CASES OFF CACHE BOOL "${INSTALL_OCCT_TEST_CASES_DESCR}")
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
316d77d9 44
45# Rebuild *.yacc and *.lex files
46set (REBUILD_PLATFORM_DEPENDENT_CODE OFF CACHE BOOL "${REBUILD_PLATFORM_DEPENDENT_CODE_DESCR}")
47
19286d7c 48# copy samples to install directory
316d77d9 49set (INSTALL_OCCT_SAMPLES OFF CACHE BOOL "${INSTALL_OCCT_SAMPLES_DESCR}")
19286d7c 50
9f33b387 51# install dir of the built project
316d77d9 52set (INSTALL_DIR "" CACHE PATH "${INSTALL_DIR_DESCR}" )
9f33b387 53set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
03c69aec 54
316d77d9 55set (APPLY_OCCT_PATCH_DIR "" CACHE PATH "${APPLY_OCCT_PATCH_DIR_DESCR}")
03c69aec 56
9f33b387 57# the list of being built toolkits
316d77d9 58set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
59separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
03c69aec 60
ad211ad3 61if (MSVC)
316d77d9 62 set (BUILD_MODULE_OcctMfcSamples OFF CACHE BOOL "${BUILD_MODULE_OcctMfcSamples_DESCR}")
85bcc072 63endif()
64
9f33b387 65# whether use optional 3rdparty or not
66if (APPLE)
316d77d9 67 set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
03c69aec 68endif()
85bcc072 69
316d77d9 70set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
71set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
03c69aec 72
9f33b387 73if (NOT DEFINED ANDROID)
316d77d9 74 set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
75 set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
19286d7c 76 #set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
03c69aec 77endif()
78
9f33b387 79# include occt macros
19286d7c 80OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
03c69aec 81
9f33b387 82# include the patched or original list of modules
19286d7c 83# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
84# list <OCCT_MODULES> will contain all modules
85OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
03c69aec 86
316d77d9 87foreach (OCCT_MODULE ${OCCT_MODULES})
88 BUILD_MODULE (${OCCT_MODULE})
19286d7c 89endforeach()
90
adc33035 91# Overview
316d77d9 92set (BUILD_DOC_OcctOverview OFF CACHE BOOL "${BUILD_DOC_OcctOverview_DESCR}")
adc33035 93
19286d7c 94if (NOT USE_VTK)
95 list (REMOVE_ITEM Visualization_TOOLKITS TKIVtk)
96 list (REMOVE_ITEM Draw_TOOLKITS TKIVtkDraw)
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
9f33b387 130if (NOT DEFINED 3RDPARTY_DIR)
316d77d9 131 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
9f33b387 132endif()
03c69aec 133
9f33b387 134# search for 3rdparty dir
135if ("${3RDPARTY_DIR}" STREQUAL "")
136 if (DEFINED ENV{3RDPARTY_DIR})
316d77d9 137 set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
9f33b387 138 elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
139 # in version 6.7.0 and above, occt parent directory contains 3rdparties
9ccea0c6 140 get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
316d77d9 141 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
9f33b387 142 endif()
143endif()
234e52be 144
9f33b387 145# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
146OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
03c69aec 147
9f33b387 148if ("${USE_TCL}" STREQUAL ON)
149 message (STATUS "Info: tcl is used by OCCT")
19286d7c 150 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
9f33b387 151else()
9ccea0c6 152 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
153 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
9f33b387 154endif()
03c69aec 155
9f33b387 156# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
157OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
03c69aec 158
9f33b387 159if ("${USE_FREETYPE}" STREQUAL ON)
160 message (STATUS "Info: freetype is used by OCCT")
19286d7c 161 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
9f33b387 162else()
9ccea0c6 163 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 164 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
165 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
9f33b387 166endif()
03c69aec 167
09c597c9 168# VTK
169if (USE_VTK)
170 add_definitions (-DHAVE_VTK)
19286d7c 171 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
09c597c9 172endif()
173
174# GLX
175if (USE_GLX)
176 add_definitions (-DMACOSX_USE_GLX)
19286d7c 177 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
09c597c9 178endif()
179
03c69aec 180# FREEIMAGE
9f33b387 181if (USE_FREEIMAGE)
182 add_definitions (-DHAVE_FREEIMAGE)
19286d7c 183 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
184 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
9f33b387 185else()
186 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
187 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
188 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
189 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
190endif()
03c69aec 191
192# GL2PS
9f33b387 193if (USE_GL2PS)
194 add_definitions (-DHAVE_GL2PS)
19286d7c 195 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
9f33b387 196else()
197 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
198 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
199endif()
03c69aec 200
7c633a3e 201# OPENCL
19286d7c 202#if (USE_OPENCL)
203# add_definitions (-DHAVE_OPENCL)
204# OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/opencl")
205#else()
206# OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
207# OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
208# OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
209# OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
210#endif()
234e52be 211
9f33b387 212# TBB
213if (USE_TBB)
9ccea0c6 214 add_definitions (-DHAVE_TBB)
19286d7c 215 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
9f33b387 216else()
217 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
218 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
219 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
220endif()
234e52be 221
adc33035 222# Doxygen
316d77d9 223if (BUILD_DOC_OcctOverview)
224 if (NOT DEFINED INSTALL_DOC_OcctOverview)
225 set (INSTALL_DOC_OcctOverview OFF CACHE BOOL "${INSTALL_DOC_OcctOverview_DESCR}")
adc33035 226 endif()
227
316d77d9 228 if (INSTALL_DOC_OcctOverview)
adc33035 229 install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_DIR}/doc")
230 install (FILES "${CMAKE_SOURCE_DIR}/dox/resources/overview.html" DESTINATION "${INSTALL_DIR}")
231 endif()
232
233 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
234else()
316d77d9 235 OCCT_CHECK_AND_UNSET ("INSTALL_DOC_OcctOverview")
adc33035 236
237 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
238 OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_DOT_EXECUTABLE")
239endif()
240
316d77d9 241# bison
242if (REBUILD_PLATFORM_DEPENDENT_CODE)
243 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
244else()
245 OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
246endif()
247
248# flex
249if (REBUILD_PLATFORM_DEPENDENT_CODE)
250 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
251else()
252 OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
253endif()
254
9f33b387 255string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 256
9f33b387 257# check all 3rdparty paths
258if (3RDPARTY_NOT_INCLUDED)
259 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
260endif()
7c633a3e 261
9bb81d6c 262if (3RDPARTY_INCLUDE_DIRS)
263 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
264 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
265 message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
266 include_directories (${3RDPARTY_INCLUDE_DIRS})
267endif()
268
94829f84 269# include <cmake binary folder>/inc
270include_directories (${CMAKE_BINARY_DIR}/inc)
271
9bb81d6c 272if (3RDPARTY_LIBRARY_DIRS)
273 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
274 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
275 message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
276 link_directories (${3RDPARTY_LIBRARY_DIRS})
277endif()
234e52be 278
fa0cbe55 279# Get all used variables: OS_WITH_BIT, COMPILER
19286d7c 280OCCT_MAKE_OS_WITH_BITNESS()
281OCCT_MAKE_COMPILER_SHORT_NAME()
03c69aec 282
9f33b387 283# build directories
fa0cbe55 284set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
285set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
286set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
19286d7c 287
316d77d9 288set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
289set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
290set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
19286d7c 291
fa0cbe55 292set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
293set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
294set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 295
fa0cbe55 296if (WIN32)
297 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
298 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 299endif()
03c69aec 300
adc33035 301if ("${INSTALL_DIR}" STREQUAL "")
302 get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
303
316d77d9 304 set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
adc33035 305 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
306
307 message (STATUS "Info: INSTALL_DIR has been set as ${INSTALL_DIR}")
308endif()
309
94829f84 310message (STATUS "\nInfo: Collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
311
312# (!) patch is not taken into account COLLECT_AND_INSTALL_OCCT_HEADER_FILES
313# collect all the headers to <binary dir>/inc folder
316d77d9 314COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
94829f84 315# apply patched header files
316d77d9 316#if (NOT "${APPLY_OCCT_PATCH_DIR}" STREQUAL "")
317# COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${APPLY_OCCT_PATCH_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}")
94829f84 318#endif()
319
910970ab 320OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_DIR}")
321OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/samples")
03c69aec 322
316d77d9 323if (INSTALL_OCCT_SAMPLES)
910970ab 324 OCCT_INSTALL_FILE_OR_DIR ("samples" "${INSTALL_DIR}")
325endif()
03c69aec 326
316d77d9 327if (INSTALL_OCCT_TEST_CASES)
910970ab 328 OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_DIR}")
329endif()
03c69aec 330
910970ab 331if (WIN32)
332 set (SCRIPT_EXT bat)
333else()
334 set (SCRIPT_EXT sh)
335endif()
03c69aec 336
910970ab 337# DRAW.BAT or DRAW.SH
316d77d9 338if (NOT "${APPLY_OCCT_PATCH_DIR}" STREQUAL "" AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
339 install (FILES "${APPLY_OCCT_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
910970ab 340 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
341else()
342 install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
343 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
344endif()
345OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
9f33b387 346
316d77d9 347set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
9f33b387 348
910970ab 349if (WIN32)
316d77d9 350 set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %VCVER% %ARCH% %CASDEB% \n)")
910970ab 351else()
316d77d9 352 set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
910970ab 353endif()
32856b63 354
910970ab 355 # change custom.bat/sh
356if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
357 file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 358
910970ab 359 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 360
910970ab 361 file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
362else()
316d77d9 363 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
910970ab 364endif()
32856b63 365
316d77d9 366# write current custom.bat/sh (for install directory)
367set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
368OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR}")
03c69aec 369
316d77d9 370# write current custom.bat/sh (for build directory)
371OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
372
373if (BUILD_MODULE_OcctMfcSamples)
910970ab 374 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
375 OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
9f33b387 376endif()
377
316d77d9 378# env script for draw in building environment
910970ab 379OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
316d77d9 380
381# end script for draw in standalone environment
382# release version
383set (BUILD_LETTER "")
384OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.release.${SCRIPT_EXT}")
385install (FILES "${CMAKE_BINARY_DIR}/env.install.release.${SCRIPT_EXT}"
386 CONFIGURATIONS Release
387 DESTINATION "${INSTALL_DIR}"
388 RENAME "env.${SCRIPT_EXT}")
389
390# debug version
391set (BUILD_LETTER "d")
392OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.debug.${SCRIPT_EXT}")
393install (FILES "${CMAKE_BINARY_DIR}/env.install.debug.${SCRIPT_EXT}"
394 CONFIGURATIONS Debug
395 DESTINATION "${INSTALL_DIR}"
396 RENAME "env.${SCRIPT_EXT}")
397
398# release with debug info version
399set (BUILD_LETTER "i")
400OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.relwithdebinfo.${SCRIPT_EXT}")
401install (FILES "${CMAKE_BINARY_DIR}/env.install.relwithdebinfo.${SCRIPT_EXT}"
402 CONFIGURATIONS RelWithDebInfo
403 DESTINATION "${INSTALL_DIR}"
404 RENAME "env.${SCRIPT_EXT}")
405
406# copy DrawAppliInit from OCCT source to build directory
407if (EXISTS "${CMAKE_SOURCE_DIR}/DrawAppliInit" AND NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
408 file (COPY "${CMAKE_SOURCE_DIR}/DrawAppliInit" DESTINATION "${CMAKE_BINARY_DIR}")
409endif()
910970ab 410
9f33b387 411# RESOURCES
19286d7c 412FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
413foreach(RESOURCE ${RESOURCES})
414 get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
415 if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
416 get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
417 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/src/${RESOURCE_FOLDER}")
418 else()
419 OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/src")
420 endif()
421endforeach()
03c69aec 422
33839ae6 423# include patched toolkit projects or original ones
316d77d9 424foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS})
425 if (NOT "${APPLY_OCCT_PATCH_DIR}" STREQUAL "" AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${BUILD_TOOLKIT}")
426 add_subdirectory(${APPLY_OCCT_PATCH_DIR}/src/${BUILD_TOOLKIT})
427 elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${BUILD_TOOLKIT}")
428 add_subdirectory (${CMAKE_SOURCE_DIR}/src/${BUILD_TOOLKIT})
19286d7c 429 else()
316d77d9 430 message (STATUS "${BUILD_TOOLKIT} is not included")
19286d7c 431 endif()
432endforeach()
234e52be 433
316d77d9 434if (BUILD_DOC_OcctOverview)
adc33035 435 add_subdirectory (dox)
436endif()
437
94829f84 438# patch DRAWEXE
439if (MSVC AND 3RDPARTY_DLL_DIRS)
316d77d9 440 list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
94829f84 441 if (${DRAWEXE_INDEX} GREATER -1)
442 list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
443 set (3RDPARTY_DLL_DIRS_FOR_PATH "")
444
445 foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
446 set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
447 endforeach()
448
449 OCCT_MAKE_COMPILER_BITNESS()
450 set (X_COMPILER_BITNESS "x64")
451 if ("${COMPILER_BITNESS}" STREQUAL "32")
452 set (X_COMPILER_BITNESS "Win32")
453 endif()
454
455 configure_file (${CMAKE_SOURCE_DIR}/adm/templates/DRAWEXE.vcxproj.user.in ${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user @ONLY)
456 endif()
457endif()
458
33839ae6 459# samples do not support patch usage
316d77d9 460if (BUILD_MODULE_OcctMfcSamples)
19286d7c 461 set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
234e52be 462
19286d7c 463 set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
464 set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
234e52be 465
9f33b387 466 add_subdirectory(samples/mfc/standard/mfcsample)
467 add_subdirectory(samples/mfc/standard/01_Geometry)
468 add_subdirectory(samples/mfc/standard/02_Modeling)
469 add_subdirectory(samples/mfc/standard/03_Viewer2d)
470 add_subdirectory(samples/mfc/standard/04_Viewer3d)
471 add_subdirectory(samples/mfc/standard/05_ImportExport)
472 add_subdirectory(samples/mfc/standard/06_Ocaf)
473 add_subdirectory(samples/mfc/standard/07_Triangulation)
474 add_subdirectory(samples/mfc/standard/08_HLR)
475 add_subdirectory(samples/mfc/standard/09_Animation)
476 add_subdirectory(samples/mfc/standard/10_Convert)
19286d7c 477endif()