0024002: Overall code and build procedure refactoring - samples
[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 # set type of OCCT libraries
8 if (NOT BUILD_LIBRARY_TYPE)
9   set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "The type of OCCT libraries" FORCE)
10   SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
11 endif()
12
13 if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
14   set (BUILD_SHARED_LIBS ON)
15 else()
16   unset (BUILD_SHARED_LIBS)
17 endif()
18
19 # the name of the project
20 project (OCCT)
21
22 # Solution folder property
23 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
24
25 # Generate documentation
26 # Overview and User Guides
27 set (DOC_GENERATE_OVERVIEW OFF CACHE BOOL "Generate Overview and User Guides")
28 if (NOT DOC_OVERVIEW_OUTPUT_FORMAT)
29   set (DOC_OVERVIEW_OUTPUT_FORMAT "html" CACHE STRING "Output format of Overview and User Guides" FORCE)
30   SET_PROPERTY (CACHE DOC_OVERVIEW_OUTPUT_FORMAT PROPERTY STRINGS html chm pdf)
31 endif()
32 # class Reference Manual
33 set (DOC_GENERATE_REFMAN OFF CACHE BOOL "Generate class Reference Manual")
34
35 # Tests
36 set (TESTS_RUN OFF CACHE BOOL "Run tests or not")
37 set (TESTS_INSTALL OFF CACHE BOOL "Copy tests to folder install")
38 set (TESTS_SHAPES_DIR "" CACHE PATH "Directory that will contain shapes for tests" )
39
40 # Find Bison and Flex executables to rebuild *.yacc and *.lex files if it is necessary (BUILD_BISON_FLEX_FILES is ON)
41 set (BUILD_BISON_FLEX_FILES OFF CACHE BOOL "Build *.yacc/*.lex files")
42 if (${BUILD_BISON_FLEX_FILES})
43   foreach (aTool BISON FLEX)
44     list (APPEND CMAKE_PROGRAM_PATH ${BUILD_BISON_FLEX_DIR})
45     find_package (${aTool})
46     if (NOT ${${aTool}_FOUND})
47       message ("Warning : set BUILD_BISON_FLEX_DIR directory")
48       set (BUILD_BISON_FLEX_DIR "" CACHE PATH "Filepath to BISON and FLEX executables")
49       set (BUILD_BISON_FLEX_FILES OFF)
50     endif()
51   endforeach()
52 endif()
53
54 # copy samples to install directory
55 set (INSTALL_SAMPLES OFF CACHE BOOL "Copy OCCT samples to install directory")
56
57 # install dir of the built project
58 set (INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
59 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
60
61 set (BUILD_PATCH_DIR "" CACHE PATH "directory with occt patch")
62
63 # the list of being built toolkits
64 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
65 separate_arguments (BUILD_TOOLKITS)
66
67 if (MSVC)
68   set (BUILD_MFC_SAMPLES OFF CACHE BOOL "OCCT samples building")
69 endif()
70
71 # whether use optional 3rdparty or not
72 if (APPLE)
73   set (USE_GLX OFF CACHE BOOL "Are X11 OpenGL used on OSX or not")
74 endif()
75
76 set (USE_FREEIMAGE OFF CACHE BOOL "Is freeimage used or not")
77 set (USE_VTK OFF CACHE BOOL "Is VTK used or not")
78
79 if (NOT DEFINED ANDROID)
80   set (USE_GL2PS OFF CACHE BOOL "Is gl2ps used or not")
81   set (USE_TBB OFF CACHE BOOL "Is tbb used or not")
82   #set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
83 endif()
84
85 # macro: include patched file if it exists
86 macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
87   if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
88     include (${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
89   else()
90     include (${BEING_INCLUDED_FILE}.cmake)
91   endif()
92 endmacro()
93
94 # include occt macros
95 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
96
97 # include the patched or original list of modules
98 # list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
99 # list <OCCT_MODULES> will contain all modules
100 OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
101
102 foreach (MODULE ${OCCT_MODULES})
103   set (BUILD_${MODULE} ON CACHE BOOL "include ${MODULE}")
104 endforeach()
105
106 if (NOT USE_VTK)
107   list (REMOVE_ITEM Visualization_TOOLKITS TKIVtk)
108   list (REMOVE_ITEM Draw_TOOLKITS TKIVtkDraw)
109 endif()
110
111 # accumulate used toolkits (first level) in USED_TOOLKITS variable
112 list (APPEND USED_TOOLKITS ${BUILD_TOOLKITS})
113
114 foreach (MODULE ${OCCT_MODULES})
115   if (BUILD_${MODULE})
116     list (APPEND USED_TOOLKITS ${${MODULE}_TOOLKITS})
117   endif()
118 endforeach()
119
120 # DRAWEXE excluded when library build is static
121 if (NOT BUILD_SHARED_LIBS)
122   list (REMOVE_ITEM USED_TOOLKITS DRAWEXE)
123   message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type")
124 endif()
125
126 # accumulate all used toolkits
127 list (REMOVE_DUPLICATES USED_TOOLKITS)
128 set (RAW_USED_TOOLKIT)
129 foreach(USED_TOOLKIT ${USED_TOOLKITS})
130   OCCT_TOOLKIT_FULL_DEP (${USED_TOOLKIT} TOOLKIT_FULL_DEPS)
131   list (APPEND RAW_USED_TOOLKIT ${USED_TOOLKIT} ${TOOLKIT_FULL_DEPS})
132 endforeach()
133
134 list (REMOVE_DUPLICATES RAW_USED_TOOLKIT)
135 set (USED_TOOLKITS ${RAW_USED_TOOLKIT})
136
137 # include the patched or original list of definitions and flags
138 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
139
140 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
141
142 set (3RDPARTY_DIR_LABEL "The directory containing required 3rdparty products")
143 if (NOT DEFINED 3RDPARTY_DIR)
144   set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_LABEL})
145 endif()
146
147 # search for 3rdparty dir
148 if ("${3RDPARTY_DIR}" STREQUAL "")
149   if (DEFINED ENV{3RDPARTY_DIR})
150     set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
151   elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
152     # in version 6.7.0 and above, occt parent directory contains 3rdparties
153     get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
154     set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
155   endif()
156 endif()
157
158 # search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
159 OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
160
161 if ("${USE_TCL}" STREQUAL ON)
162   message (STATUS "Info: tcl is used by OCCT")
163   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
164 else()
165   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
166   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
167 endif()
168
169 # search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
170 OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
171
172 if ("${USE_FREETYPE}" STREQUAL ON)
173   message (STATUS "Info: freetype is used by OCCT")
174   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
175 else()
176   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
177   OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
178   OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
179 endif()
180
181 # VTK
182 if (USE_VTK)
183   add_definitions (-DHAVE_VTK)
184   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
185 endif()
186
187 # GLX
188 if (USE_GLX)
189   add_definitions (-DMACOSX_USE_GLX)
190   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx")
191 endif()
192
193 # FREEIMAGE
194 if (USE_FREEIMAGE)
195   add_definitions (-DHAVE_FREEIMAGE)
196   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
197   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimageplus")
198 else()
199   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
200   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
201   OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
202   OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
203 endif()
204
205 # GL2PS
206 if (USE_GL2PS)
207   add_definitions (-DHAVE_GL2PS)
208   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
209 else()
210   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
211   OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
212 endif()
213
214 # OPENCL
215 #if (USE_OPENCL)
216 #  add_definitions (-DHAVE_OPENCL)
217 #  OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/opencl")
218 #else()
219 #  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
220 #  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
221 #  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
222 #  OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
223 #endif()
224
225 # TBB
226 if (USE_TBB)
227   add_definitions (-DHAVE_TBB)
228   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
229 else()
230   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
231   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
232   OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
233 endif()
234
235 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
236
237 # check all 3rdparty paths
238 if (3RDPARTY_NOT_INCLUDED)
239   message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
240 endif()
241
242 if (3RDPARTY_INCLUDE_DIRS)
243   list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
244   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
245   message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
246   include_directories (${3RDPARTY_INCLUDE_DIRS})
247 endif()
248
249 # include <cmake binary folder>/inc
250 include_directories (${CMAKE_BINARY_DIR}/inc)
251
252 if (3RDPARTY_LIBRARY_DIRS)
253   list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
254   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
255   message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
256   link_directories (${3RDPARTY_LIBRARY_DIRS})
257 endif()
258
259 # Get all used variables: OS_WITH_BIT, COMPILER
260 OCCT_MAKE_OS_WITH_BITNESS()
261 OCCT_MAKE_COMPILER_SHORT_NAME()
262
263 # build directories
264 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
265 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
266 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
267
268 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
269 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
270 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
271
272 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
273 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
274 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
275
276 if (WIN32) 
277   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
278   set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG   "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
279 endif()
280
281 message (STATUS "\nInfo: Collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
282
283 # (!) patch is not taken into account COLLECT_AND_INSTALL_OCCT_HEADER_FILES
284 # collect all the headers to <binary dir>/inc folder
285 COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}" "${USED_TOOLKITS}")
286 # apply patched header files
287 #if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
288 #  COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${BUILD_PATCH_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}")
289 #endif()
290
291 if ("${INSTALL_DIR}" STREQUAL "")
292   get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
293
294   set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "Directory that will contain install files of OCCT" FORCE)
295   set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
296
297   message (STATUS "INSTALL_DIR has been set as ${INSTALL_DIR}")
298 endif()
299
300 OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_DIR}")
301 OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/samples")
302
303 if (INSTALL_SAMPLES)
304   OCCT_INSTALL_FILE_OR_DIR ("samples" "${INSTALL_DIR}")
305 endif()
306
307 if (TESTS_INSTALL)
308   OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_DIR}")
309 endif()
310
311 if (WIN32)
312   set (SCRIPT_EXT bat)
313 else()
314   set (SCRIPT_EXT sh)
315 endif()
316
317 # Creation of "START_TESTS" project
318 if (TESTS_RUN AND TESTS_INSTALL)
319   #set(BUILD_TESTING ON)
320   #enable_testing ()
321   #add_test(NAME RUN_TESTS COMMAND ${INSTALL_DIR}/draw.${SCRIPT_EXT} -c testgrid -overwrite -outdir ${INSTALL_DIR}/TestResults)
322   add_custom_target(START_TESTS ${INSTALL_DIR}/draw.${SCRIPT_EXT} -c testgrid -overwrite -outdir ${INSTALL_DIR}/TestResults DEPENDS INSTALL)
323 endif()
324
325 # Creation of "GenerateDocumentation" project
326 if (DOC_GENERATE_OVERVIEW OR DOC_GENERATE_REFMAN)
327   OCCT_INCLUDE_CMAKE_FILE("adm/cmake/occt_gendoc")
328   if(DOC_GENERATE_OVERVIEW)
329     gendoc(-overview -${DOC_OVERVIEW_OUTPUT_FORMAT})
330   endif()
331   if(DOC_GENERATE_REFMAN)
332     gendoc(-refman -html)
333   endif()
334 endif()
335
336 # DRAW.BAT or DRAW.SH
337 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
338   install (FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS
339           OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
340 else()
341   install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS
342           OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
343 endif()
344 OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}")
345
346 set (SUB_CUSTOM "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}")
347
348 if (WIN32)
349   set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM}\" (\n  call \"%~dp0${SUB_CUSTOM}\" %VCVER% %ARCH% %CASDEB% \n)")
350 else()
351   set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM}\" ]; then\n  source \"\${aScriptPath}/${SUB_CUSTOM}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
352 endif()
353
354  # change custom.bat/sh
355 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
356   file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
357
358   set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
359
360   file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
361 else()
362   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
363 endif()
364
365 # write current custom.bat/sh
366 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
367
368 if (BUILD_MFC_SAMPLES)
369   OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
370   OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
371 endif()
372
373 OCCT_CONFIGURE ("adm/templates/env.build.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
374 OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.install.${SCRIPT_EXT}")
375 install (FILES "${CMAKE_BINARY_DIR}/env.install.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" RENAME "env.${SCRIPT_EXT}")
376
377 # RESOURCES
378 FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
379 foreach(RESOURCE ${RESOURCES})
380   get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY)
381   if(NOT "${RESOURCE_FOLDER}" STREQUAL "")
382     get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME)
383     OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/src/${RESOURCE_FOLDER}")
384   else()
385     OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR}/src")
386   endif()
387 endforeach()
388
389 # include patched toolkit projects or original ones
390 foreach (USED_TOOLKIT ${USED_TOOLKITS})
391   if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/src/${USED_TOOLKIT}")
392     add_subdirectory(${BUILD_PATCH_DIR}/src/${USED_TOOLKIT})
393   elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${USED_TOOLKIT}")
394     add_subdirectory (${CMAKE_SOURCE_DIR}/src/${USED_TOOLKIT})
395   else()
396     message (STATUS "${USED_TOOLKIT} is not included")
397   endif()
398 endforeach()
399
400 # patch DRAWEXE
401 if (MSVC AND 3RDPARTY_DLL_DIRS)
402   list (FIND USED_TOOLKITS DRAWEXE DRAWEXE_INDEX)
403   if (${DRAWEXE_INDEX} GREATER -1)
404     list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
405     set (3RDPARTY_DLL_DIRS_FOR_PATH "")
406
407     foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
408       set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
409     endforeach()
410
411     OCCT_MAKE_COMPILER_BITNESS()
412     set (X_COMPILER_BITNESS "x64")
413     if ("${COMPILER_BITNESS}" STREQUAL "32")
414       set (X_COMPILER_BITNESS "Win32")
415     endif()
416
417     configure_file (${CMAKE_SOURCE_DIR}/adm/templates/DRAWEXE.vcxproj.user.in ${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user @ONLY)
418   endif()
419 endif()
420
421 # samples do not support patch usage
422 if (BUILD_MFC_SAMPLES)
423   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
424
425   set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
426   set (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
427
428   add_subdirectory(samples/mfc/standard/mfcsample)
429   add_subdirectory(samples/mfc/standard/01_Geometry)
430   add_subdirectory(samples/mfc/standard/02_Modeling)
431   add_subdirectory(samples/mfc/standard/03_Viewer2d)
432   add_subdirectory(samples/mfc/standard/04_Viewer3d)
433   add_subdirectory(samples/mfc/standard/05_ImportExport)
434   add_subdirectory(samples/mfc/standard/06_Ocaf)
435   add_subdirectory(samples/mfc/standard/07_Triangulation)
436   add_subdirectory(samples/mfc/standard/08_HLR)
437   add_subdirectory(samples/mfc/standard/09_Animation)
438   add_subdirectory(samples/mfc/standard/10_Convert)
439 endif()