0026591: Header collecting in CMake configuration process does not consider 'patch...
[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 (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
10     include (${APPLY_OCCT_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
11   else()
12     include (${CMAKE_SOURCE_DIR}/${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 else()
173   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
174   OCCT_CHECK_AND_UNSET ("INSTALL_VTK")
175 endif()
176
177 # GLX
178 if (USE_GLX)
179   add_definitions (-DMACOSX_USE_GLX)
180   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
181 endif()
182
183 # FREEIMAGE
184 if (USE_FREEIMAGE)
185   add_definitions (-DHAVE_FREEIMAGE)
186   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
187   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
188 else()
189   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
190   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
191   OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
192   OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
193 endif()
194
195 # GL2PS
196 if (USE_GL2PS)
197   add_definitions (-DHAVE_GL2PS)
198   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
199 else()
200   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
201   OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
202 endif()
203
204 # OPENCL
205 #if (USE_OPENCL)
206 #  add_definitions (-DHAVE_OPENCL)
207 #  OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/opencl")
208 #else()
209 #  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
210 #  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
211 #  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
212 #  OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
213 #endif()
214
215 # TBB
216 if (USE_TBB)
217   add_definitions (-DHAVE_TBB)
218   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
219 else()
220   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
221   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
222   OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
223 endif()
224
225 # Doxygen
226 if (BUILD_DOC_OcctOverview)
227   if (NOT DEFINED INSTALL_DOC_OcctOverview)
228     set (INSTALL_DOC_OcctOverview OFF CACHE BOOL "${INSTALL_DOC_OcctOverview_DESCR}")
229   endif()
230
231   if (INSTALL_DOC_OcctOverview)
232     install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION  "${INSTALL_DIR}/doc")
233
234     OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR}")
235   endif()
236
237   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
238 else()
239   OCCT_CHECK_AND_UNSET ("INSTALL_DOC_OcctOverview")
240
241   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE")
242   OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_DOT_EXECUTABLE")
243 endif()
244
245 # bison 
246 if (REBUILD_PLATFORM_DEPENDENT_CODE)
247   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
248 else()
249   OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
250 endif()
251
252 # flex 
253 if (REBUILD_PLATFORM_DEPENDENT_CODE)
254   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
255 else()
256   OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE")
257 endif()
258
259 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
260
261 # check all 3rdparty paths
262 if (3RDPARTY_NOT_INCLUDED)
263   message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
264 endif()
265
266 if (3RDPARTY_INCLUDE_DIRS)
267   list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
268   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
269   message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
270   include_directories (${3RDPARTY_INCLUDE_DIRS})
271 endif()
272
273 # include <cmake binary folder>/inc
274 include_directories (${CMAKE_BINARY_DIR}/inc)
275
276 if (3RDPARTY_LIBRARY_DIRS)
277   list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
278   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
279   message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
280   link_directories (${3RDPARTY_LIBRARY_DIRS})
281 endif()
282
283 # Get all used variables: OS_WITH_BIT, COMPILER
284 OCCT_MAKE_OS_WITH_BITNESS()
285 OCCT_MAKE_COMPILER_SHORT_NAME()
286
287 # build directories
288 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
289 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
290 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
291
292 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
293 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
294 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi")
295
296 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
297 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
298 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
299
300 if (WIN32) 
301   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE        "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
302   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
303   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG          "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
304 endif()
305
306 if ("${INSTALL_DIR}" STREQUAL "")
307   get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
308
309   set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
310   set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
311
312   message (STATUS "Info: INSTALL_DIR has been set as ${INSTALL_DIR}")
313 endif()
314
315 message (STATUS "\nInfo: Collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
316
317 # collect all the headers to <binary dir>/inc folder
318 COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
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 (APPLY_OCCT_PATCH_DIR 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 (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit")
408   OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${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   OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}")
426 endforeach()
427
428 if (BUILD_DOC_OcctOverview)
429   OCCT_ADD_SUBDIRECTORY (dox)
430 endif()
431
432 # patch DRAWEXE
433 if (MSVC AND 3RDPARTY_DLL_DIRS)
434   list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX)
435   if (${DRAWEXE_INDEX} GREATER -1)
436     list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
437     set (3RDPARTY_DLL_DIRS_FOR_PATH "")
438
439     foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
440       set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
441     endforeach()
442
443     OCCT_MAKE_COMPILER_BITNESS()
444     set (X_COMPILER_BITNESS "x64")
445     if ("${COMPILER_BITNESS}" STREQUAL "32")
446       set (X_COMPILER_BITNESS "Win32")
447     endif()
448
449     OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user")
450   endif()
451 endif()
452
453 # samples do not support patch usage
454 if (BUILD_MODULE_OcctMfcSamples)
455   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
456
457   set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
458   set (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
459
460   add_subdirectory(samples/mfc/standard/mfcsample)
461   add_subdirectory(samples/mfc/standard/01_Geometry)
462   add_subdirectory(samples/mfc/standard/02_Modeling)
463   add_subdirectory(samples/mfc/standard/03_Viewer2d)
464   add_subdirectory(samples/mfc/standard/04_Viewer3d)
465   add_subdirectory(samples/mfc/standard/05_ImportExport)
466   add_subdirectory(samples/mfc/standard/06_Ocaf)
467   add_subdirectory(samples/mfc/standard/07_Triangulation)
468   add_subdirectory(samples/mfc/standard/08_HLR)
469   add_subdirectory(samples/mfc/standard/09_Animation)
470   add_subdirectory(samples/mfc/standard/10_Convert)
471 endif()