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