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 # set type of OCCT libraries
14 if (NOT BUILD_LIBRARY_TYPE)
15 set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "The type of OCCT libraries" FORCE)
16 SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static)
19 if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
20 set (BUILD_SHARED_LIBS ON)
22 unset (BUILD_SHARED_LIBS)
25 # the name of the project
28 # Solution folder property
29 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
31 set (CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
33 # install dir of the built project
34 set (INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
35 set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
37 # whether install test bundle or not
38 set (INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
40 set (BUILD_PATCH_DIR "" CACHE PATH "directory with OCCT patch")
42 # the list of being built toolkits
43 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
44 separate_arguments (BUILD_TOOLKITS)
47 set (BUILD_MFC_SAMPLES OFF CACHE BOOL "OCCT samples building")
50 # whether use optional 3rdparty or not
52 set (USE_GLX OFF CACHE BOOL "Are X11 OpenGL used on OSX or not")
55 set (USE_FREEIMAGE OFF CACHE BOOL "Is freeimage used or not")
56 set (USE_VTK OFF CACHE BOOL "Is VTK used or not")
58 if (NOT DEFINED ANDROID)
59 set (USE_GL2PS OFF CACHE BOOL "Is gl2ps used or not")
60 set (USE_TBB OFF CACHE BOOL "Is tbb used or not")
61 set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
64 # macro: include patched file if it exists
65 macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
66 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
67 include(${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
69 include(${BEING_INCLUDED_FILE}.cmake)
74 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
76 # BUILD_POSTFIX variable is used by all toolkit cmakelists.txt projects
77 OCCT_MAKE_BUILD_POSTFIX()
79 # include the patched or original list of modules
80 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_modules")
82 # include the list of being used toolkits. USED_TOOLKITS variable
83 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_toolkits")
85 # include the patched or original list of definitions and flags
86 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_defs_flags")
88 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/3rdparty_macro")
90 set (3RDPARTY_DIR_LABEL "The directory containing required 3rdparty products")
91 if (NOT DEFINED 3RDPARTY_DIR)
92 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_LABEL})
95 # search for 3rdparty dir
96 if ("${3RDPARTY_DIR}" STREQUAL "")
97 if (DEFINED ENV{3RDPARTY_DIR})
98 set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
99 elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
100 # in version 6.7.0 and above, occt parent directory contains 3rdparties
101 get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
102 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
106 # search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
107 OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
109 if ("${USE_TCL}" STREQUAL ON)
110 message (STATUS "Info: tcl is used by OCCT")
111 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tcl")
113 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
114 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
117 # search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
118 OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
120 if ("${USE_FREETYPE}" STREQUAL ON)
121 message (STATUS "Info: freetype is used by OCCT")
122 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freetype")
124 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
125 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
126 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
131 add_definitions (-DHAVE_VTK)
132 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/vtk")
137 add_definitions (-DMACOSX_USE_GLX)
138 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/glx")
143 add_definitions (-DHAVE_FREEIMAGE)
144 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimage")
145 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimageplus")
147 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
148 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
149 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
150 OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
155 add_definitions (-DHAVE_GL2PS)
156 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/gl2ps")
158 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
159 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
164 add_definitions (-DHAVE_OPENCL)
165 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/opencl")
167 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
168 OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
169 OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
170 OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
175 add_definitions (-DHAVE_TBB)
176 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tbb")
178 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
179 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
180 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
183 string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
185 # check all 3rdparty paths
186 if (3RDPARTY_NOT_INCLUDED)
187 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
190 if (3RDPARTY_INCLUDE_DIRS)
191 list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
192 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
193 message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
194 include_directories (${3RDPARTY_INCLUDE_DIRS})
197 if (3RDPARTY_LIBRARY_DIRS)
198 list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
199 string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
200 message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
201 link_directories (${3RDPARTY_LIBRARY_DIRS})
204 OCCT_MAKE_BUILD_POSTFIX()
207 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
208 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
209 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin${BUILD_POSTFIX})
211 if ("${INSTALL_DIR}" STREQUAL "")
212 message (FATAL_ERROR "INSTALL_DIR variable is empty. It's required to define installation directory")
214 # inc,data,tests DIRECTORY
215 install (DIRECTORY "${CMAKE_SOURCE_DIR}/inc" DESTINATION "${INSTALL_DIR}")
216 install (DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${INSTALL_DIR}")
217 install (DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl" DESTINATION "${INSTALL_DIR}/samples")
219 install (DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
222 # install patch inc, data, tests folder
223 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
224 if (EXISTS "${BUILD_PATCH_DIR}/inc")
225 install (DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION "${INSTALL_DIR}" )
228 if (EXISTS "${BUILD_PATCH_DIR}/data")
229 install (DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${INSTALL_DIR}" )
233 if (EXISTS "${BUILD_PATCH_DIR}/tests")
234 install (DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
245 # DRAW.BAT or DRAW.SH
246 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
247 install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
248 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
250 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
251 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
254 # set compiler short name
255 OCCT_MAKE_COMPILER_SHORT_NAME()
257 OCCT_MAKE_COMPILER_BITNESS()
259 SET(SUB_CUSTOM "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_POSTFIX}.${SCRIPT_EXT}")
262 SET (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM}\" (\n call \"%~dp0${SUB_CUSTOM}\" %1 %2 %3 \n)")
264 SET (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
267 # change custom.bat/sh
268 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
269 file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
271 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
273 file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
275 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
278 # write current custom.bat/sh
279 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
281 if (BUILD_MFC_SAMPLES)
282 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
285 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}" "${INSTALL_DIR}")
289 OCCT_INSTALL_FILE_OR_DIR ("src/DrawResources" "${INSTALL_DIR}/src")
290 OCCT_INSTALL_FILE_OR_DIR ("src/StdResource" "${INSTALL_DIR}/src")
291 OCCT_INSTALL_FILE_OR_DIR ("src/SHMessage" "${INSTALL_DIR}/src")
292 OCCT_INSTALL_FILE_OR_DIR ("src/Textures" "${INSTALL_DIR}/src")
293 OCCT_INSTALL_FILE_OR_DIR ("src/Shaders" "${INSTALL_DIR}/src")
294 OCCT_INSTALL_FILE_OR_DIR ("src/XSMessage" "${INSTALL_DIR}/src")
295 OCCT_INSTALL_FILE_OR_DIR ("src/XSTEPResource" "${INSTALL_DIR}/src")
296 OCCT_INSTALL_FILE_OR_DIR ("src/XmlOcafResource" "${INSTALL_DIR}/src")
298 OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Lexi_Expr.dat" "${INSTALL_DIR}/src/UnitsAPI")
299 OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Units.dat" "${INSTALL_DIR}/src/UnitsAPI")
300 OCCT_INSTALL_FILE_OR_DIR ("src/TObj/TObj.msg" "${INSTALL_DIR}/src/TObj")
303 #Toolkits uses variables: INSTALL_DIR, OS_WITH_BIT, COMPILER, BUILD_POSTFIX
304 OCCT_MAKE_OS_WITH_BITNESS()
306 # consider for patch existence
307 set (IS_PATCH_CURRENT "NO")
308 set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
309 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
310 set (IS_PATCH_CURRENT "YES")
311 set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
314 # include patched toolkit projects or original ones
316 if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake")
317 set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
318 include (${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake)
320 set (IS_PATCH_CURRENT "NO")
321 set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
322 include (adm/cmake/occt_inc_toolkits.cmake)
325 # include some required original occt_inc_toolkits
326 if (NOT "${UNSUBDIRS}" STREQUAL "")
327 set (IS_PATCH_CURRENT "NO")
328 # add required subdirs
329 foreach (UNSUBDIR ${UNSUBDIRS})
330 add_subdirectory (${CMAKE_SOURCE_DIR}/${UNSUBDIR})
334 # samples do not support patch usage
335 IF (BUILD_MFC_SAMPLES)
336 SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
338 SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
339 SET (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
341 add_subdirectory(samples/mfc/standard/mfcsample)
342 add_subdirectory(samples/mfc/standard/01_Geometry)
343 add_subdirectory(samples/mfc/standard/02_Modeling)
344 add_subdirectory(samples/mfc/standard/03_Viewer2d)
345 add_subdirectory(samples/mfc/standard/04_Viewer3d)
346 add_subdirectory(samples/mfc/standard/05_ImportExport)
347 add_subdirectory(samples/mfc/standard/06_Ocaf)
348 add_subdirectory(samples/mfc/standard/07_Triangulation)
349 add_subdirectory(samples/mfc/standard/08_HLR)
350 add_subdirectory(samples/mfc/standard/09_Animation)
351 add_subdirectory(samples/mfc/standard/10_Convert)