0026342: No materials are read from STEP
[occt.git] / CMakeLists.txt
CommitLineData
9f33b387 1cmake_minimum_required (VERSION 2.8.10 FATAL_ERROR)
166d6cd7 2
576f8b11 3set (CMAKE_SUPPRESS_REGENERATION TRUE)
4
9f33b387 5# set build configurations list
ad211ad3 6if (NOT BUILD_CONFIGURATION)
9f33b387 7 set (BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
ad211ad3 8 SET_PROPERTY(CACHE BUILD_CONFIGURATION PROPERTY STRINGS Release Debug RelWithDebInfo)
03c69aec 9endif()
166d6cd7 10
9f33b387 11set (CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
03c69aec 12
c259930b 13# set type of OCCT libraries
14if (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)
17endif()
18
19if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
20 set (BUILD_SHARED_LIBS ON)
21else()
22 unset (BUILD_SHARED_LIBS)
23endif()
24
9f33b387 25# the name of the project
26project (OCCT)
03c69aec 27
9f33b387 28# Solution folder property
29set_property (GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 30
9f33b387 31set (CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
03c69aec 32
9f33b387 33# install dir of the built project
34set (INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
35set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
03c69aec 36
9f33b387 37# whether install test bundle or not
38set (INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
33839ae6 39
9f33b387 40set (BUILD_PATCH_DIR "" CACHE PATH "directory with OCCT patch")
03c69aec 41
9f33b387 42# the list of being built toolkits
ad211ad3 43set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
9f33b387 44separate_arguments (BUILD_TOOLKITS)
03c69aec 45
ad211ad3 46if (MSVC)
9f33b387 47 set (BUILD_MFC_SAMPLES OFF CACHE BOOL "OCCT samples building")
85bcc072 48endif()
49
9f33b387 50# whether use optional 3rdparty or not
51if (APPLE)
52 set (USE_GLX OFF CACHE BOOL "Are X11 OpenGL used on OSX or not")
03c69aec 53endif()
85bcc072 54
9f33b387 55set (USE_FREEIMAGE OFF CACHE BOOL "Is freeimage used or not")
09c597c9 56set (USE_VTK OFF CACHE BOOL "Is VTK used or not")
03c69aec 57
9f33b387 58if (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")
03c69aec 62endif()
63
9f33b387 64# macro: include patched file if it exists
65macro (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)
d5aedb2c 68 else()
9f33b387 69 include(${BEING_INCLUDED_FILE}.cmake)
d5aedb2c 70 endif()
9f33b387 71endmacro()
03c69aec 72
9f33b387 73# include occt macros
74OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
03c69aec 75
9f33b387 76# BUILD_POSTFIX variable is used by all toolkit cmakelists.txt projects
77OCCT_MAKE_BUILD_POSTFIX()
03c69aec 78
9f33b387 79# include the patched or original list of modules
80OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_modules")
03c69aec 81
9f33b387 82# include the list of being used toolkits. USED_TOOLKITS variable
83OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_toolkits")
03c69aec 84
9f33b387 85# include the patched or original list of definitions and flags
86OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_defs_flags")
03c69aec 87
9f33b387 88OCCT_INCLUDE_CMAKE_FILE ("adm/templates/3rdparty_macro")
03c69aec 89
9f33b387 90set (3RDPARTY_DIR_LABEL "The directory containing required 3rdparty products")
91if (NOT DEFINED 3RDPARTY_DIR)
92 set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_LABEL})
93endif()
03c69aec 94
9f33b387 95# search for 3rdparty dir
96if ("${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
9ccea0c6 101 get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
102 set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} FORCE)
9f33b387 103 endif()
104endif()
234e52be 105
9f33b387 106# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
107OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
03c69aec 108
9f33b387 109if ("${USE_TCL}" STREQUAL ON)
110 message (STATUS "Info: tcl is used by OCCT")
111 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tcl")
112else()
9ccea0c6 113 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
114 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
9f33b387 115endif()
03c69aec 116
9f33b387 117# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
118OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
03c69aec 119
9f33b387 120if ("${USE_FREETYPE}" STREQUAL ON)
121 message (STATUS "Info: freetype is used by OCCT")
122 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freetype")
123else()
9ccea0c6 124 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
9f33b387 125 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
126 OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
9f33b387 127endif()
03c69aec 128
09c597c9 129# VTK
130if (USE_VTK)
131 add_definitions (-DHAVE_VTK)
132 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/vtk")
133endif()
134
135# GLX
136if (USE_GLX)
137 add_definitions (-DMACOSX_USE_GLX)
138 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/glx")
139endif()
140
03c69aec 141# FREEIMAGE
9f33b387 142if (USE_FREEIMAGE)
143 add_definitions (-DHAVE_FREEIMAGE)
9f33b387 144 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimage")
145 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimageplus")
146else()
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")
151endif()
03c69aec 152
153# GL2PS
9f33b387 154if (USE_GL2PS)
155 add_definitions (-DHAVE_GL2PS)
9f33b387 156 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/gl2ps")
157else()
158 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
159 OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
160endif()
03c69aec 161
7c633a3e 162# OPENCL
9f33b387 163if (USE_OPENCL)
164 add_definitions (-DHAVE_OPENCL)
9f33b387 165 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/opencl")
166else()
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")
171endif()
234e52be 172
9f33b387 173# TBB
174if (USE_TBB)
9ccea0c6 175 add_definitions (-DHAVE_TBB)
9f33b387 176 OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tbb")
177else()
178 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
179 OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
180 OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
181endif()
234e52be 182
9f33b387 183string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
234e52be 184
9f33b387 185# check all 3rdparty paths
186if (3RDPARTY_NOT_INCLUDED)
187 message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
188endif()
7c633a3e 189
9bb81d6c 190if (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})
195endif()
196
197if (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})
202endif()
234e52be 203
9f33b387 204OCCT_MAKE_BUILD_POSTFIX()
03c69aec 205
9f33b387 206# build directories
207set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
208set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
209set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin${BUILD_POSTFIX})
03c69aec 210
9f33b387 211if ("${INSTALL_DIR}" STREQUAL "")
212 message (FATAL_ERROR "INSTALL_DIR variable is empty. It's required to define installation directory")
213else()
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")
218 if (INSTALL_TESTS)
219 install (DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
220 endif()
03c69aec 221
9f33b387 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}" )
226 endif()
03c69aec 227
9f33b387 228 if (EXISTS "${BUILD_PATCH_DIR}/data")
229 install (DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${INSTALL_DIR}" )
230 endif()
03c69aec 231
9f33b387 232 if (INSTALL_TESTS)
233 if (EXISTS "${BUILD_PATCH_DIR}/tests")
234 install (DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
235 endif()
236 endif()
237 endif()
03c69aec 238
9f33b387 239 if (WIN32)
240 set (SCRIPT_EXT bat)
241 else()
242 set (SCRIPT_EXT sh)
243 endif()
03c69aec 244
245 # DRAW.BAT or DRAW.SH
33839ae6 246 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
9f33b387 247 install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
33839ae6 248 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
249 ELSE()
9f33b387 250 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
33839ae6 251 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
252 ENDIF()
9f33b387 253
254 # set compiler short name
255 OCCT_MAKE_COMPILER_SHORT_NAME()
256
257 OCCT_MAKE_COMPILER_BITNESS()
258
259 SET(SUB_CUSTOM "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_POSTFIX}.${SCRIPT_EXT}")
260
32856b63 261 if (WIN32)
9f33b387 262 SET (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM}\" (\n call \"%~dp0${SUB_CUSTOM}\" %1 %2 %3 \n)")
32856b63 263 else()
9f33b387 264 SET (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
32856b63 265 endif()
9f33b387 266
32856b63 267 # change custom.bat/sh
268 if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
9f33b387 269 file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
32856b63 270
9f33b387 271 set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
32856b63 272
9f33b387 273 file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
32856b63 274 else()
9f33b387 275 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
32856b63 276 endif()
277
278 # write current custom.bat/sh
9f33b387 279 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
32856b63 280
9f33b387 281 if (BUILD_MFC_SAMPLES)
282 OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
283 endif()
03c69aec 284
9f33b387 285 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}" "${INSTALL_DIR}")
286endif()
287
288# RESOURCES
289OCCT_INSTALL_FILE_OR_DIR ("src/DrawResources" "${INSTALL_DIR}/src")
290OCCT_INSTALL_FILE_OR_DIR ("src/StdResource" "${INSTALL_DIR}/src")
291OCCT_INSTALL_FILE_OR_DIR ("src/SHMessage" "${INSTALL_DIR}/src")
292OCCT_INSTALL_FILE_OR_DIR ("src/Textures" "${INSTALL_DIR}/src")
293OCCT_INSTALL_FILE_OR_DIR ("src/Shaders" "${INSTALL_DIR}/src")
294OCCT_INSTALL_FILE_OR_DIR ("src/XSMessage" "${INSTALL_DIR}/src")
295OCCT_INSTALL_FILE_OR_DIR ("src/XSTEPResource" "${INSTALL_DIR}/src")
296OCCT_INSTALL_FILE_OR_DIR ("src/XmlOcafResource" "${INSTALL_DIR}/src")
297
298OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Lexi_Expr.dat" "${INSTALL_DIR}/src/UnitsAPI")
299OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Units.dat" "${INSTALL_DIR}/src/UnitsAPI")
300OCCT_INSTALL_FILE_OR_DIR ("src/TObj/TObj.msg" "${INSTALL_DIR}/src/TObj")
301
302
303#Toolkits uses variables: INSTALL_DIR, OS_WITH_BIT, COMPILER, BUILD_POSTFIX
304OCCT_MAKE_OS_WITH_BITNESS()
305
306# consider for patch existence
307set (IS_PATCH_CURRENT "NO")
308set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
309if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
310 set (IS_PATCH_CURRENT "YES")
311 set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
312endif()
03c69aec 313
33839ae6 314# include patched toolkit projects or original ones
9f33b387 315set (UNSUBDIRS "")
316if (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)
319else()
320 set (IS_PATCH_CURRENT "NO")
321 set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
322 include (adm/cmake/occt_inc_toolkits.cmake)
323endif()
33839ae6 324
9f33b387 325# include some required original occt_inc_toolkits
326if (NOT "${UNSUBDIRS}" STREQUAL "")
327 set (IS_PATCH_CURRENT "NO")
33839ae6 328 # add required subdirs
9f33b387 329 foreach (UNSUBDIR ${UNSUBDIRS})
330 add_subdirectory (${CMAKE_SOURCE_DIR}/${UNSUBDIR})
331 endforeach()
332endif()
234e52be 333
33839ae6 334# samples do not support patch usage
9f33b387 335IF (BUILD_MFC_SAMPLES)
234e52be 336 SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
337
338 SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
339 SET (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
340
9f33b387 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)
234e52be 352ENDIF()