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