1 cmake_minimum_required (VERSION 2.8.10 FATAL_ERROR)
3 set (CMAKE_SUPPRESS_REGENERATION TRUE)
5 # set build configurations list
6 if (NOT BUILD_CONFIGURATION)
7 set (BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
8 SET_PROPERTY(CACHE BUILD_CONFIGURATION PROPERTY STRINGS Release Debug RelWithDebInfo)
11 set (CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
13 # the name of the project
16 # Solution folder property
17 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
19 set (CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
21 # install dir of the built project
22 set (INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
23 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
25 # whether install test bundle or not
26 set (INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
28 set (BUILD_PATCH_DIR "" CACHE PATH "directory with OCCT patch")
30 # the list of being built toolkits
31 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
32 separate_arguments (BUILD_TOOLKITS)
35 set (BUILD_MFC_SAMPLES OFF CACHE BOOL "OCCT samples building")
38 # whether use optional 3rdparty or not
40 set (USE_GLX OFF CACHE BOOL "Are X11 OpenGL used on OSX or not")
43 set (USE_FREEIMAGE OFF CACHE BOOL "Is freeimage used or not")
44 set (USE_VTK OFF CACHE BOOL "Is VTK used or not")
46 if (NOT DEFINED ANDROID)
47 set (USE_GL2PS OFF CACHE BOOL "Is gl2ps used or not")
48 set (USE_TBB OFF CACHE BOOL "Is tbb used or not")
49 set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
52 # macro: include patched file if it exists
53 macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
54 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
55 include(${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
57 include(${BEING_INCLUDED_FILE}.cmake)
62 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
64 # BUILD_POSTFIX variable is used by all toolkit cmakelists.txt projects
65 OCCT_MAKE_BUILD_POSTFIX()
67 # include the patched or original list of modules
68 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_modules")
70 # include the list of being used toolkits. USED_TOOLKITS variable
71 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_toolkits")
73 # include the patched or original list of definitions and flags
74 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_defs_flags")
76 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/3rdparty_macro")
78 set (3RDPARTY_DIR_LABEL "The directory containing required 3rdparty products")
79 if (NOT DEFINED 3RDPARTY_DIR)
80 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_LABEL})
83 # search for 3rdparty dir
84 if ("${3RDPARTY_DIR}" STREQUAL "")
85 if (DEFINED ENV{3RDPARTY_DIR})
86 set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
87 elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
88 # in version 6.7.0 and above, occt parent directory contains 3rdparties
89 get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
90 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
94 # search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
95 OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
97 if ("${USE_TCL}" STREQUAL ON)
98 message (STATUS "Info: tcl is used by OCCT")
99 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tcl")
101 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
102 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
105 # search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
106 OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
108 if ("${USE_FREETYPE}" STREQUAL ON)
109 message (STATUS "Info: freetype is used by OCCT")
110 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freetype")
112 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
113 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
114 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
119 add_definitions (-DHAVE_VTK)
120 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/vtk")
125 add_definitions (-DMACOSX_USE_GLX)
126 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/glx")
131 add_definitions (-DHAVE_FREEIMAGE)
132 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimage")
133 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimageplus")
135 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
136 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
137 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
138 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
143 add_definitions (-DHAVE_GL2PS)
144 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/gl2ps")
146 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
147 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
152 add_definitions (-DHAVE_OPENCL)
153 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/opencl")
155 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
156 OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
157 OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
158 OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
163 add_definitions (-DHAVE_TBB)
164 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tbb")
166 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
167 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
168 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
171 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
173 # check all 3rdparty paths
174 if (3RDPARTY_NOT_INCLUDED)
175 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
178 if (3RDPARTY_INCLUDE_DIRS)
179 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
180 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
181 message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
182 include_directories (${3RDPARTY_INCLUDE_DIRS})
185 if (3RDPARTY_LIBRARY_DIRS)
186 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
187 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
188 message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
189 link_directories (${3RDPARTY_LIBRARY_DIRS})
192 OCCT_MAKE_BUILD_POSTFIX()
195 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
196 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
197 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin${BUILD_POSTFIX})
199 if ("${INSTALL_DIR}" STREQUAL "")
200 message (FATAL_ERROR "INSTALL_DIR variable is empty. It's required to define installation directory")
202 # inc,data,tests DIRECTORY
203 install (DIRECTORY "${CMAKE_SOURCE_DIR}/inc" DESTINATION "${INSTALL_DIR}")
204 install (DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${INSTALL_DIR}")
205 install (DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl" DESTINATION "${INSTALL_DIR}/samples")
207 install (DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
210 # install patch inc, data, tests folder
211 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
212 if (EXISTS "${BUILD_PATCH_DIR}/inc")
213 install (DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION "${INSTALL_DIR}" )
216 if (EXISTS "${BUILD_PATCH_DIR}/data")
217 install (DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${INSTALL_DIR}" )
221 if (EXISTS "${BUILD_PATCH_DIR}/tests")
222 install (DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
233 # DRAW.BAT or DRAW.SH
234 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
235 install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
236 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
238 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
239 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
242 # set compiler short name
243 OCCT_MAKE_COMPILER_SHORT_NAME()
245 OCCT_MAKE_COMPILER_BITNESS()
247 SET(SUB_CUSTOM "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_POSTFIX}.${SCRIPT_EXT}")
250 SET (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM}\" (\n call \"%~dp0${SUB_CUSTOM}\" %1 %2 %3 \n)")
252 SET (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
255 # change custom.bat/sh
256 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
257 file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
259 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
261 file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
263 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
266 # write current custom.bat/sh
267 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
269 if (BUILD_MFC_SAMPLES)
270 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
273 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}" "${INSTALL_DIR}")
277 OCCT_INSTALL_FILE_OR_DIR ("src/DrawResources" "${INSTALL_DIR}/src")
278 OCCT_INSTALL_FILE_OR_DIR ("src/StdResource" "${INSTALL_DIR}/src")
279 OCCT_INSTALL_FILE_OR_DIR ("src/SHMessage" "${INSTALL_DIR}/src")
280 OCCT_INSTALL_FILE_OR_DIR ("src/Textures" "${INSTALL_DIR}/src")
281 OCCT_INSTALL_FILE_OR_DIR ("src/Shaders" "${INSTALL_DIR}/src")
282 OCCT_INSTALL_FILE_OR_DIR ("src/XSMessage" "${INSTALL_DIR}/src")
283 OCCT_INSTALL_FILE_OR_DIR ("src/XSTEPResource" "${INSTALL_DIR}/src")
284 OCCT_INSTALL_FILE_OR_DIR ("src/XmlOcafResource" "${INSTALL_DIR}/src")
286 OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Lexi_Expr.dat" "${INSTALL_DIR}/src/UnitsAPI")
287 OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Units.dat" "${INSTALL_DIR}/src/UnitsAPI")
288 OCCT_INSTALL_FILE_OR_DIR ("src/TObj/TObj.msg" "${INSTALL_DIR}/src/TObj")
291 #Toolkits uses variables: INSTALL_DIR, OS_WITH_BIT, COMPILER, BUILD_POSTFIX
292 OCCT_MAKE_OS_WITH_BITNESS()
294 # consider for patch existence
295 set (IS_PATCH_CURRENT "NO")
296 set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
297 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
298 set (IS_PATCH_CURRENT "YES")
299 set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
302 # include patched toolkit projects or original ones
304 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake")
305 set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
306 include (${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake)
308 set (IS_PATCH_CURRENT "NO")
309 set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
310 include (adm/cmake/occt_inc_toolkits.cmake)
313 # include some required original occt_inc_toolkits
314 if (NOT "${UNSUBDIRS}" STREQUAL "")
315 set (IS_PATCH_CURRENT "NO")
316 # add required subdirs
317 foreach (UNSUBDIR ${UNSUBDIRS})
318 add_subdirectory (${CMAKE_SOURCE_DIR}/${UNSUBDIR})
322 # samples do not support patch usage
323 IF (BUILD_MFC_SAMPLES)
324 SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
326 SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
327 SET (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
329 add_subdirectory(samples/mfc/standard/mfcsample)
330 add_subdirectory(samples/mfc/standard/01_Geometry)
331 add_subdirectory(samples/mfc/standard/02_Modeling)
332 add_subdirectory(samples/mfc/standard/03_Viewer2d)
333 add_subdirectory(samples/mfc/standard/04_Viewer3d)
334 add_subdirectory(samples/mfc/standard/05_ImportExport)
335 add_subdirectory(samples/mfc/standard/06_Ocaf)
336 add_subdirectory(samples/mfc/standard/07_Triangulation)
337 add_subdirectory(samples/mfc/standard/08_HLR)
338 add_subdirectory(samples/mfc/standard/09_Animation)
339 add_subdirectory(samples/mfc/standard/10_Convert)