0026610: Configuration - workaround vc12 compilation error in Select3D_SensitiveCircl...
[occt.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
2
3 set (CMAKE_SUPPRESS_REGENERATION TRUE)
4
5 set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
6
7 # macro: include patched file if it exists
8 macro (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()
14 endmacro()
15
16 # include variable description
17 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr")
18
19 # set type of OCCT libraries
20 if (NOT BUILD_LIBRARY_TYPE)
21   set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE)
22   SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
23 endif()
24
25 if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
26   set (BUILD_SHARED_LIBS ON)
27 else()
28   unset (BUILD_SHARED_LIBS)
29 endif()
30
31 # the name of the project
32 project (OCCT)
33
34 # Solution folder property
35 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
36
37 set (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
40 if (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)
42 endif()
43
44
45 # Rebuild *.yacc and *.lex files
46 set (REBUILD_PLATFORM_DEPENDENT_CODE OFF CACHE BOOL "${REBUILD_PLATFORM_DEPENDENT_CODE_DESCR}")
47
48 # copy samples to install directory
49 set (INSTALL_OCCT_SAMPLES OFF CACHE BOOL "${INSTALL_OCCT_SAMPLES_DESCR}")
50
51 # install dir of the built project
52 set (INSTALL_DIR "" CACHE PATH "${INSTALL_DIR_DESCR}" )
53 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
54
55 set (APPLY_OCCT_PATCH_DIR "" CACHE PATH "${APPLY_OCCT_PATCH_DIR_DESCR}")
56
57 # the list of being built toolkits
58 set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}")
59 separate_arguments (BUILD_ADDITIONAL_TOOLKITS)
60
61 if (MSVC)
62   set (BUILD_MODULE_OcctMfcSamples OFF CACHE BOOL "${BUILD_MODULE_OcctMfcSamples_DESCR}")
63 endif()
64
65 # whether use optional 3rdparty or not
66 if (APPLE)
67   set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
68 endif()
69
70 set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
71 set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}")
72
73 if (NOT DEFINED ANDROID)
74   set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}")
75   set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
76   #set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
77 endif()
78
79 # include occt macros
80 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
81
82 # include the patched or original list of modules
83 # list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
84 # list <OCCT_MODULES> will contain all modules
85 OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
86
87 foreach (OCCT_MODULE ${OCCT_MODULES})
88   BUILD_MODULE (${OCCT_MODULE})
89 endforeach()
90
91 # Overview
92 set (BUILD_DOC_OcctOverview OFF CACHE BOOL "${BUILD_DOC_OcctOverview_DESCR}")
93
94 if (NOT USE_VTK)
95   list (REMOVE_ITEM Visualization_TOOLKITS TKIVtk)
96   list (REMOVE_ITEM Draw_TOOLKITS TKIVtkDraw)
97 endif()
98
99 # accumulate used toolkits (first level) in BUILD_TOOLKITS variable
100 list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
101
102 foreach (OCCT_MODULE ${OCCT_MODULES})
103   if (BUILD_MODULE_${OCCT_MODULE})
104     list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS})
105   endif()
106 endforeach()
107
108 # DRAWEXE excluded when library build is static
109 if (NOT BUILD_SHARED_LIBS)
110   list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE)
111   message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
112 endif()
113
114 # accumulate all used toolkits
115 list (REMOVE_DUPLICATES BUILD_TOOLKITS)
116 set (RAW_BUILD_TOOLKITS)
117 foreach(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})
120 endforeach()
121
122 list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS)
123 set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS})
124
125 # include the patched or original list of definitions and flags
126 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
127
128 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
129
130 if (NOT DEFINED 3RDPARTY_DIR)
131   set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
132 endif()
133
134 # search for 3rdparty dir
135 if ("${3RDPARTY_DIR}" STREQUAL "")
136   if (DEFINED ENV{3RDPARTY_DIR})
137     set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
138   elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
139     # in version 6.7.0 and above, occt parent directory contains 3rdparties
140     get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
141     set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
142   endif()
143 endif()
144
145 # search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
146 OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
147
148 if ("${USE_TCL}" STREQUAL ON)
149   message (STATUS "Info: tcl is used by OCCT")
150   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
151 else()
152   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
153   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
154 endif()
155
156 # search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
157 OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
158
159 if ("${USE_FREETYPE}" STREQUAL ON)
160   message (STATUS "Info: freetype is used by OCCT")
161   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
162 else()
163   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
164   OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
165   OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
166 endif()
167
168 # VTK
169 if (USE_VTK)
170   add_definitions (-DHAVE_VTK)
171   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
172 endif()
173
174 # GLX
175 if (USE_GLX)
176   add_definitions (-DMACOSX_USE_GLX)
177   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
178 endif()
179
180 # FREEIMAGE
181 if (USE_FREEIMAGE)
182   add_definitions (-DHAVE_FREEIMAGE)
183   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
184   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
185 else()
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")
190 endif()
191
192 # GL2PS
193 if (USE_GL2PS)
194   add_definitions (-DHAVE_GL2PS)
195   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
196 else()
197   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
198   OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
199 endif()
200
201 # OPENCL
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()
211
212 # TBB
213 if (USE_TBB)
214   add_definitions (-DHAVE_TBB)
215   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
216 else()
217   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
218   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
219   OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
220 endif()
221
222 # Doxygen
223 if (BUILD_DOC_OcctOverview)
224   if (NOT DEFINED INSTALL_DOC_OcctOverview)
225     set (INSTALL_DOC_OcctOverview OFF CACHE BOOL "${INSTALL_DOC_OcctOverview_DESCR}")
226   endif()
227
228   if (INSTALL_DOC_OcctOverview)
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")
234 else()
235   OCCT_CHECK_AND_UNSET ("INSTALL_DOC_OcctOverview")
236
237   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
238   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_DOT_EXECUTABLE")
239 endif()
240
241 # bison 
242 if (REBUILD_PLATFORM_DEPENDENT_CODE)
243   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
244 else()
245   OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
246 endif()
247
248 # flex 
249 if (REBUILD_PLATFORM_DEPENDENT_CODE)
250   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
251 else()
252   OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
253 endif()
254
255 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
256
257 # check all 3rdparty paths
258 if (3RDPARTY_NOT_INCLUDED)
259   message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
260 endif()
261
262 if (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})
267 endif()
268
269 # include <cmake binary folder>/inc
270 include_directories (${CMAKE_BINARY_DIR}/inc)
271
272 if (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})
277 endif()
278
279 # Get all used variables: OS_WITH_BIT, COMPILER
280 OCCT_MAKE_OS_WITH_BITNESS()
281 OCCT_MAKE_COMPILER_SHORT_NAME()
282
283 # build directories
284 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
285 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
286 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
287
288 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
289 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
290 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
291
292 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
293 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
294 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
295
296 if (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")
299 endif()
300
301 if ("${INSTALL_DIR}" STREQUAL "")
302   get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
303
304   set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
305   set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
306
307   message (STATUS "Info: INSTALL_DIR has been set as ${INSTALL_DIR}")
308 endif()
309
310 message (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
314 COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
315 # apply patched header files
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}")
318 #endif()
319
320 OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_DIR}")
321 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/samples")
322
323 if (INSTALL_OCCT_SAMPLES)
324   OCCT_INSTALL_FILE_OR_DIR ("samples" "${INSTALL_DIR}")
325 endif()
326
327 if (INSTALL_OCCT_TEST_CASES)
328   OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_DIR}")
329 endif()
330
331 if (WIN32)
332   set (SCRIPT_EXT bat)
333 else()
334   set (SCRIPT_EXT sh)
335 endif()
336
337 # DRAW.BAT or DRAW.SH
338 if (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
340           OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
341 else()
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)
344 endif()
345 OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
346
347 set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
348
349 if (WIN32)
350   set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n  call \"%~dp0${SUB_CUSTOM_NAME}\" %VCVER% %ARCH% %CASDEB% \n)")
351 else()
352   set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n  source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
353 endif()
354
355  # change custom.bat/sh
356 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
357   file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
358
359   set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
360
361   file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
362 else()
363   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
364 endif()
365
366 # write current custom.bat/sh (for install directory)
367 set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
368 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR}")
369
370 # write current custom.bat/sh (for build directory)
371 OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
372
373 if (BUILD_MODULE_OcctMfcSamples)
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}")
376 endif()
377
378 # env script for draw in building environment
379 OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
380
381 # end script for draw in standalone environment
382 # release version
383 set (BUILD_LETTER "")
384 OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.release.${SCRIPT_EXT}")
385 install (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
391 set (BUILD_LETTER "d")
392 OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.debug.${SCRIPT_EXT}")
393 install (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
399 set (BUILD_LETTER "i")
400 OCCT_CONFIGURE ("adm/templates/env.install.${SCRIPT_EXT}.in" "env.install.relwithdebinfo.${SCRIPT_EXT}")
401 install (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
407 if (EXISTS "${CMAKE_SOURCE_DIR}/DrawAppliInit" AND NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
408   file (COPY "${CMAKE_SOURCE_DIR}/DrawAppliInit" DESTINATION "${CMAKE_BINARY_DIR}")
409 endif()
410
411 # RESOURCES
412 FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
413 foreach(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()
421 endforeach()
422
423 # include patched toolkit projects or original ones
424 foreach (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})
429   else()
430     message (STATUS "${BUILD_TOOLKIT} is not included")
431   endif()
432 endforeach()
433
434 if (BUILD_DOC_OcctOverview)
435   add_subdirectory (dox)
436 endif()
437
438 # patch DRAWEXE
439 if (MSVC AND 3RDPARTY_DLL_DIRS)
440   list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
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()
457 endif()
458
459 # samples do not support patch usage
460 if (BUILD_MODULE_OcctMfcSamples)
461   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
462
463   set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
464   set (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
465
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)
477 endif()