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