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