0024810: "Patch" feature should be introduced in OCC CMake building procedure
[occt.git] / CMakeLists.txt
CommitLineData
03c69aec 1cmake_minimum_required ( VERSION 2.6)
166d6cd7 2
ad211ad3 3if (NOT BUILD_CONFIGURATION)
4 set(BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
5 SET_PROPERTY(CACHE BUILD_CONFIGURATION PROPERTY STRINGS Release Debug RelWithDebInfo)
03c69aec 6endif()
166d6cd7 7
ad211ad3 8set(CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
03c69aec 9
10project(OCCT)
11
ad211ad3 12set_property(GLOBAL PROPERTY USE_FOLDERS ON)
03c69aec 13
14set(BUILD_SHARED_LIBS ON)
15
ad211ad3 16IF("${BUILD_CONFIGURATION}" STREQUAL "${CMAKE_BUILD_TYPE}")
03c69aec 17 SET(CHANGES_ARE_NEEDED OFF)
18ELSE()
19 SET(CHANGES_ARE_NEEDED ON)
20ENDIF()
21
11fca7c1 22MATH(EXPR COMPILER_BITNESS "32 + 32*(${CMAKE_SIZEOF_VOID_P}/8)")
03c69aec 23
33839ae6 24SET(CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
03c69aec 25
33839ae6 26SET(INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
27SET(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
28
29set(BUILD_PATCH_DIR "" CACHE PATH "directory with occt patch")
03c69aec 30
ad211ad3 31set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
03c69aec 32separate_arguments(BUILD_TOOLKITS)
33
234e52be 34IF(MSVC)
35 SET(BUILD_Samples OFF CACHE BOOL "OCCT samples building")
36ENDIF()
37
33839ae6 38# consider for patch existence
39SET (IS_PATCH_CURRENT "NO")
40SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
41IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
42 SET (IS_PATCH_CURRENT "YES")
43 SET (TK_ROOT_DIR ${BUILD_PATCH_DIR})
44ENDIF()
45
46# include the list of patch modules if the one exists
47# or include the list of original modules
48IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt")
49 MESSAGE(STATUS "Info: the list of patched modules is included")
50 include(${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt)
51ELSE()
52 include(adm/cmake/CMakeModules.txt)
53ENDIF()
03c69aec 54
55if (WIN32)
56 set(SCRIPT_EXT bat)
57else()
58 set(SCRIPT_EXT sh)
59endif()
60
ad211ad3 61if (MSVC)
62 add_definitions(/fp:precise)
63endif()
64
4d42a1a5 65# set compiler short name and choose SSE2 option for appropriate MSVC compilers
03c69aec 66if (DEFINED MSVC70)
67 SET(COMPILER vc7)
68elseif (DEFINED MSVC80)
69 SET(COMPILER vc8)
4d42a1a5 70 if (${COMPILER_BITNESS} STREQUAL 32)
71 add_definitions(/arch:SSE2)
72 endif()
03c69aec 73elseif (DEFINED MSVC90)
74 SET(COMPILER vc9)
4d42a1a5 75 if (${COMPILER_BITNESS} STREQUAL 32)
76 add_definitions(/arch:SSE2)
77 endif()
03c69aec 78elseif (DEFINED MSVC10)
79 SET(COMPILER vc10)
4d42a1a5 80 if (${COMPILER_BITNESS} STREQUAL 32)
81 add_definitions(/arch:SSE2)
82 endif()
03c69aec 83elseif (DEFINED MSVC11)
84 SET(COMPILER vc11)
85else()
86 SET(COMPILER ${CMAKE_GENERATOR})
87endif()
88
03c69aec 89add_definitions(-DCSFDB)
90if(WIN32)
91 add_definitions(/DWNT -wd4996)
92elseif(APPLE)
93 add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
94else()
95 add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
96endif()
97
4d42a1a5 98# enable structured exceptions for MSVC
03c69aec 99string(REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
100IF(ISFLAG)
101 STRING(REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
102ELSEIF(WIN32)
103 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
104ENDIF()
105
4d42a1a5 106# enable parallel compilation on MSVC 9 and above
03c69aec 107IF(WIN32)
108 IF(NOT DEFINED MSVC70 AND NOT DEFINED MSVC80)
109 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
110 ENDIF()
111ENDIF()
112
4d42a1a5 113# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
d5aedb2c 114IF(MSVC)
115 if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
116 string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
117 else()
118 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
119 endif()
120elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
121 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
122endif()
123
03c69aec 124SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
125SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
126
127SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
128SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
129
130set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
131set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
132set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)
133
134# RESOURCES
135install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/DrawResources" DESTINATION "${INSTALL_DIR}/src" )
136install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/StdResource" DESTINATION "${INSTALL_DIR}/src" )
137install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/SHMessage" DESTINATION "${INSTALL_DIR}/src" )
138install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Textures" DESTINATION "${INSTALL_DIR}/src" )
4058ef10 139install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Shaders" DESTINATION "${INSTALL_DIR}/src" )
03c69aec 140install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSMessage" DESTINATION "${INSTALL_DIR}/src" )
03c69aec 141install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSTEPResource" DESTINATION "${INSTALL_DIR}/src" )
142install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XmlOcafResource" DESTINATION "${INSTALL_DIR}/src" )
143
144install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Lexi_Expr.dat" DESTINATION "${INSTALL_DIR}/src/UnitsAPI" )
145install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Units.dat" DESTINATION "${INSTALL_DIR}/src/UnitsAPI" )
ad211ad3 146install(FILES "${CMAKE_SOURCE_DIR}/src/TObj/TObj.msg" DESTINATION "${INSTALL_DIR}/src/TObj" )
03c69aec 147
ad211ad3 148IF("${BUILD_CONFIGURATION}" STREQUAL "Release")
03c69aec 149 SET(BUILD_SUFFIX "")
150ELSE()
151 SET(BUILD_SUFFIX "") # debug == release
152ENDIF()
153
154FUNCTION(SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
155 file(GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
234e52be 156
03c69aec 157 foreach(ITEM ${SUB_ITEMS})
158 if(IS_DIRECTORY "${ITEM}")
159 GET_FILENAME_COMPONENT(ITEM_NAME "${ITEM}" NAME)
160 LIST(APPEND LOCAL_RESULT "${ITEM_NAME}")
161 endif()
162 endforeach()
163 set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
164ENDFUNCTION()
165
166FUNCTION(FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
167 string( TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME )
234e52be 168
11fca7c1 169 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${COMPILER_BITNESS}")
170 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}")
171 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER_BITNESS}")
03c69aec 172 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
173 LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
234e52be 174
03c69aec 175 SUBDIRECTORY_NAMES( "${ROOT_DIR}" SUBDIR_NAME_LIST)
234e52be 176
03c69aec 177 FOREACH( SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
178 IF(LOCAL_RESULT)
179 BREAK()
180 ENDIF()
234e52be 181
03c69aec 182 FOREACH(SUBDIR_NAME ${SUBDIR_NAME_LIST})
183 string( TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME )
234e52be 184
03c69aec 185 STRING(REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
186 IF(DUMMY_VAR)
187 LIST(APPEND LOCAL_RESULT ${SUBDIR_NAME})
188 ENDIF()
189 ENDFOREACH()
190 ENDFOREACH()
234e52be 191
03c69aec 192 IF(LOCAL_RESULT)
193 LIST(LENGTH "${LOCAL_RESULT}" LOC_LEN)
194 MATH(EXPR LAST_ELEMENT_INDEX "${LOC_LEN}-1")
195 LIST(GET LOCAL_RESULT ${LAST_ELEMENT_INDEX} DUMMY)
196 SET(${RESULT} ${DUMMY} PARENT_SCOPE)
234e52be 197 ENDIF()
03c69aec 198ENDFUNCTION()
199
200IF(WIN32)
201 SET(DLL_SO "dll")
202 SET(DLL_SO_FOLDER "bin")
203 SET(DLL_SO_PREFIX "")
204ELSEIF(APPLE)
205 SET(DLL_SO "dylib")
206 SET(DLL_SO_FOLDER "lib")
207 SET(DLL_SO_PREFIX "lib")
208ELSE()
209 SET(DLL_SO "so")
210 SET(DLL_SO_FOLDER "lib")
211 SET(DLL_SO_PREFIX "lib")
212ENDIF()
213
7c633a3e 214SET(3RDPARTY_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory contains required 3rdparty products")
03c69aec 215SET(3RDPARTY_INCLUDE_DIRS "")
216SET(3RDPARTY_NOT_INCLUDED)
217
218IF(APPLE)
ad211ad3 219 SET(USE_GLX OFF CACHE BOOL "whether use X11 OpenGL on OSX or not")
03c69aec 220ENDIF()
221
ad211ad3 222SET(USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
223SET(USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
224SET(USE_TBB OFF CACHE BOOL "whether use tbb product or not")
225SET(USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
03c69aec 226
227SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
228
a5deedd0 229MACRO (CHECK_AND_UNSET VARNAME)
230 IF(DEFINED ${VARNAME})
231 UNSET(${VARNAME} CACHE)
232 ENDIF()
233ENDMACRO()
234
235MACRO (CHECK_AND_UNSET_GROUP VARNAME)
236 CHECK_AND_UNSET ("${VARNAME}_DIR")
237 CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
238 CHECK_AND_UNSET ("${VARNAME}_DLL")
239 CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
240ENDMACRO()
241
03c69aec 242MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
243 IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
244 SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
245 ENDIF()
234e52be 246
03c69aec 247 IF(3RDPARTY_DIR AND ("${3RDPARTY_${PRODUCT_NAME}_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
248 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
249 IF("${${PRODUCT_NAME}_DIR_NAME}" STREQUAL "")
250 MESSAGE(STATUS "${PRODUCT_NAME} DON'T FIND")
251 ELSE()
252 SET(3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "Directory contains ${PRODUCT_NAME} product" FORCE)
253 ENDIF()
254 ENDIF()
234e52be 255
03c69aec 256 SET(INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} lib copy to install directory")
257
258 IF(3RDPARTY_${PRODUCT_NAME}_DIR)
259 IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
260 SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
261 FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
03c69aec 262 ENDIF()
234e52be 263
03c69aec 264 IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
ad211ad3 265 SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of the ${PRODUCT_NAME} product" FORCE)
03c69aec 266 FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
03c69aec 267 ENDIF()
234e52be 268
03c69aec 269 IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
ad211ad3 270 SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of the ${PRODUCT_NAME} product" FORCE)
03c69aec 271 FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
03c69aec 272 ENDIF()
234e52be 273
03c69aec 274 MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
7c633a3e 275 ELSE()
234e52be 276
7c633a3e 277 ENDIF()
234e52be 278
7c633a3e 279 # check default path (with additions) for header search
280 IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
281 SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
282 FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER})
283 ENDIF()
284
285 # check default path (with additions) for library search
286 IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
287 SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
288 FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB})
289 ENDIF()
290
291 # check default path (with additions) for DLL search
292 IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
293 SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
294 FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL})
03c69aec 295 ENDIF()
296
297 IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
298 SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
299 ELSE()
300 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
301 ENDIF()
302
303 IF(3RDPARTY_${PRODUCT_NAME}_LIBRARY)
304 GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
305 SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
306 ELSE()
307 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY)
308 ENDIF()
234e52be 309
03c69aec 310 IF(3RDPARTY_${PRODUCT_NAME}_DLL)
311 #
312 ELSE()
313 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL)
314 ENDIF()
315
316 IF(INSTALL_${PRODUCT_NAME})
317 INSTALL(FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
318 SET(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "")
319 ELSE()
320 GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
321 ENDIF()
322ENDMACRO()
323
324# TCL
ad211ad3 325INCLUDE(adm/templates/tcl.cmake)
03c69aec 326
ad211ad3 327#install tcltk
328IF(INSTALL_TCL)
a0726e55 329 SET(3RDPARTY_TCL_DLL_DIR "")
330 SET(3RDPARTY_TCL_LIB_DIR "")
331
332 GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR_INSIDE "${3RDPARTY_TCL_LIBRARY}" PATH)
333 GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR_INSIDE "${3RDPARTY_TCL_DLL}" PATH)
234e52be 334
ad211ad3 335 IF (IS_TCL_VERSION_FOUND)
336 SET (TCL_VERSION ${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION})
337 SET (TCL_FOLDER_VERSION ${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION})
338 ELSE()
339 SET (TCL_VERSION "")
03c69aec 340
ad211ad3 341 #TODO SEARCH tclX.X & tkX.X subdirs
342 SET (TCL_FOLDER_VERSION "")
343 ENDIF()
344
a0726e55 345 INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tcl${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
346 INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tk${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
03c69aec 347
ad211ad3 348 IF (IS_TCL_VERSION_FOUND)
a0726e55 349 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl8" DESTINATION "${INSTALL_DIR}/lib")
350 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
351 INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tk${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/lib")
ad211ad3 352 ELSE()
353 MESSAGE(STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
354 MESSAGE(STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
355 ENDIF()
a0726e55 356ELSE()
357 GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
358 GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
03c69aec 359ENDIF()
360
361# GLX
ad211ad3 362IF(USE_GLX)
03c69aec 363 ADD_DEFINITIONS(-DMACOSX_USE_GLX)
234e52be 364
03c69aec 365 IF(NOT DEFINED 3RDPARTY_GLX_DIR)
366 SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
367 ENDIF()
234e52be 368
03c69aec 369 IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
370 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
371 IF("${GLX_DIR_NAME}" STREQUAL "")
372 MESSAGE(STATUS "GLX DON'T FIND")
373 ELSE()
374 SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
375 ENDIF()
376 ENDIF()
234e52be 377
03c69aec 378 IF(3RDPARTY_GLX_DIR)
379 SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
380 SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib" CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
234e52be 381
03c69aec 382 SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
383 SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
234e52be 384
03c69aec 385 MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
386 ELSE()
387 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
388 LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
389 ENDIF()
390ENDIF()
391
392# FREETYPE
393THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${BUILD_SUFFIX}")
394
395IF("${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_FREETYPE_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
234e52be 396
03c69aec 397ELSEIF(EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2/")
398 SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_FREETYPE_INCLUDE_DIR}/freetype2")
399ENDIF()
400
401# FREEIMAGE
ad211ad3 402IF(USE_FREEIMAGE)
234e52be 403 ADD_DEFINITIONS(-DHAVE_FREEIMAGE)
03c69aec 404
405 THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${BUILD_SUFFIX}")
406 IF(WIN32)
407 IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
408 ELSE()
409 SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
410 ENDIF()
234e52be 411
03c69aec 412 THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${BUILD_SUFFIX}")
234e52be 413
03c69aec 414 ENDIF()
a5deedd0 415ELSE()
416 CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
417 CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
418 CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
419 CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
03c69aec 420ENDIF()
421
422# GL2PS
ad211ad3 423IF(USE_GL2PS)
03c69aec 424 ADD_DEFINITIONS(-DHAVE_GL2PS)
425 THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
a5deedd0 426ELSE()
427 CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
428 CHECK_AND_UNSET ("INSTALL_GL2PS")
03c69aec 429ENDIF()
430
7c633a3e 431# OPENCL
ad211ad3 432IF(USE_OPENCL)
234e52be 433 ADD_DEFINITIONS(-DHAVE_OPENCL)
434
7c633a3e 435 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
436 $ENV{INTELOCLSDKROOT}/include
437 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
438 $ENV{ATISTREAMSDKROOT}/include)
234e52be 439
440
7c633a3e 441 IF(${COMPILER_BITNESS} STREQUAL 32)
442 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
443 $ENV{INTELOCLSDKROOT}/lib/x86
444 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
445 $ENV{ATISTREAMSDKROOT}/lib/x86)
446 ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
447 SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
448 $ENV{INTELOCLSDKROOT}/lib/x64
449 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
450 $ENV{ATISTREAMSDKROOT}/lib/x86_64)
451 ENDIF()
234e52be 452
453
7c633a3e 454 THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${BUILD_SUFFIX}")
234e52be 455
456 # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
7c633a3e 457 # then try to find OpenCL/cl.h (all other variable won't be changed)
458 THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${BUILD_SUFFIX}")
a5deedd0 459ELSE()
460 CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
461 CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
462 CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
463 CHECK_AND_UNSET ("INSTALL_OPENCL")
7c633a3e 464ENDIF()
465
03c69aec 466# TBB
ad211ad3 467IF (USE_TBB)
03c69aec 468 ADD_DEFINITIONS(-DHAVE_TBB)
469
ad211ad3 470 INCLUDE(adm/templates/tbb.cmake)
234e52be 471
03c69aec 472 IF(INSTALL_TBB)
473 INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${DLL_SO_FOLDER}")
474
475 SET(3RDPARTY_TBB_DLL_DIR "")
476 SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
477 ELSE()
478 GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
479 GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
480 ENDIF()
a5deedd0 481ELSE()
482 CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
483 CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB_MALLOC")
484 CHECK_AND_UNSET ("3RDPARTY_TBB_DIR_NAME")
485 CHECK_AND_UNSET ("INSTALL_TBB")
03c69aec 486ENDIF()
487
488string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
489
490#CHECK ALL 3RDPARTY PATHS
491IF(3RDPARTY_NOT_INCLUDED)
492 MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
493ENDIF()
494
495list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
496string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
497MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
498include_directories( ${3RDPARTY_INCLUDE_DIRS} )
499
500list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
501string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
502MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
503link_directories( ${3RDPARTY_LIBRARY_DIRS} )
504
03c69aec 505IF("${INSTALL_DIR}" STREQUAL "")
506 MESSAGE(FATAL_ERROR "INSTALL_DIR is empty")
507ELSE()
508 # inc,data,tests DIRECTORY
33839ae6 509 install(DIRECTORY "${CMAKE_SOURCE_DIR}/inc" DESTINATION "${INSTALL_DIR}" )
510
03c69aec 511 install(DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${INSTALL_DIR}" )
512 IF(INSTALL_TESTS)
513 install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
514 ENDIF()
515
33839ae6 516 # install patch inc, data, tests folder
517 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
518 IF(EXISTS "${BUILD_PATCH_DIR}/inc")
519 install(DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION "${INSTALL_DIR}" )
520 ENDIF()
521
522 IF(EXISTS "${BUILD_PATCH_DIR}/data")
523 install(DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${INSTALL_DIR}" )
524 ENDIF()
525
526 IF(INSTALL_TESTS)
527 IF(EXISTS "${BUILD_PATCH_DIR}/tests")
528 install(DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
529 ENDIF()
530 ENDIF()
531 ENDIF()
532
03c69aec 533 # DRAW.BAT or DRAW.SH
33839ae6 534 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
535 install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
536 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
537 ELSE()
538 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" PERMISSIONS
539 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
540 ENDIF()
541
234e52be 542 IF (BUILD_Samples)
33839ae6 543 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/sample.bat")
544 install(FILES "${BUILD_PATCH_DIR}/adm/templates/sample.bat" DESTINATION "${INSTALL_DIR}")
545 ELSE()
546 install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/sample.bat" DESTINATION "${INSTALL_DIR}")
547 ENDIF()
234e52be 548 ENDIF()
03c69aec 549
33839ae6 550 IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in")
551 configure_file("${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
552 ELSE()
553 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
554 ENDIF()
03c69aec 555 install(FILES "${OCCT_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}" )
556ENDIF()
557
33839ae6 558# include patched toolkit projects or original ones
559SET (UNSUBDIRS "")
560IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt")
561 include(${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt)
562ELSE()
563 SET (IS_PATCH_CURRENT "NO")
564 SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
565 include(adm/cmake/CMakeToolKitsDeps.txt)
566ENDIF()
567
568# include some required original toolkit
569IF(NOT "${UNSUBDIRS}" STREQUAL "")
570 SET (IS_PATCH_CURRENT "NO")
571 SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
572 # add required subdirs
573 FOREACH(UNSUBDIR ${UNSUBDIRS})
574 MESSAGE(STATUS "${UNSUBDIR}")
575 subdirs(${TK_ROOT_DIR}/${UNSUBDIR})
576 ENDFOREACH()
577ENDIF()
234e52be 578
33839ae6 579# samples do not support patch usage
234e52be 580IF (BUILD_Samples)
581 SET (CMAKE_MFC_FLAG 2)
582 SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
583
584 SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
585 SET (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
586
587 subdirs(samples/mfc/standard/mfcsample)
588 subdirs(samples/mfc/standard/01_Geometry)
589 subdirs(samples/mfc/standard/02_Modeling)
590 subdirs(samples/mfc/standard/03_Viewer2d)
591 subdirs(samples/mfc/standard/04_Viewer3d)
592 subdirs(samples/mfc/standard/05_ImportExport)
593 subdirs(samples/mfc/standard/06_Ocaf)
594 subdirs(samples/mfc/standard/07_Triangulation)
595 subdirs(samples/mfc/standard/08_HLR)
596 subdirs(samples/mfc/standard/09_Animation)
597 subdirs(samples/mfc/standard/10_Convert)
598ENDIF()