0031740: Configuration - recover support of Yacc and Lex generation
[occt.git] / adm / cmake / occt_toolkit.cmake
CommitLineData
316d77d9 1# script for each OCCT toolkit
2
1fa16152 3# filling some variables by default values(src) or using custom(tools, samples)
4set (RELATIVE_SOURCES_DIR "${RELATIVE_DIR}")
5if ("${RELATIVE_SOURCES_DIR}" STREQUAL "")
6 #if it is not defined, use default directory
7 set (RELATIVE_SOURCES_DIR "src")
8endif()
9
10set (OCC_MODULES_LIST "${MODULES_LIST}")
11if ("${OCC_MODULES_LIST}" STREQUAL "")
12 set (OCC_MODULES_LIST ${OCCT_MODULES})
13endif()
14
15set (OCC_TARGET_FOLDER "${TARGET_FOLDER}")
16if ("${OCC_TARGET_FOLDER}" STREQUAL "")
17 set (OCC_TARGET_FOLDER "Modules")
18endif()
19
20set (OCCT_TOOLKITS_NAME_SUFFIX "${TOOLKITS_NAME_SUFFIX}")
21if ("${OCCT_TOOLKITS_NAME_SUFFIX}" STREQUAL "")
22 set (OCCT_TOOLKITS_NAME_SUFFIX "TOOLKITS")
23endif()
24
fb3267c7 25# parce PACKAGES file
1fa16152 26FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
27if ("${USED_PACKAGES}" STREQUAL "")
28 set (USED_PACKAGES ${PROJECT_NAME})
fb3267c7 29endif()
30
1fa16152 31if (USE_QT)
32 # Qt dependencies
33 OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt_macro)
34 FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
35 include_directories("${PROJECT_INCLUDES}")
36endif(USE_QT)
37
fb3267c7 38set (PRECOMPILED_DEFS)
39
d5265175 40if (NOT BUILD_SHARED_LIBS)
41 list (APPEND PRECOMPILED_DEFS "-DOCCT_NO_PLUGINS")
77cd443b 42 if (WIN32)
68df8478 43 list (APPEND PRECOMPILED_DEFS "-DOCCT_STATIC_BUILD")
77cd443b 44 endif()
d5265175 45endif()
46
316d77d9 47# Get all used packages from toolkit
1fa16152 48UNSET(RESOURCE_FILES)
fb3267c7 49foreach (OCCT_PACKAGE ${USED_PACKAGES})
1fa16152 50
51 #remove part after "/" in the OCCT_PACKAGE variable if exists
52 string (FIND "${OCCT_PACKAGE}" "/" _index)
53 if (_index GREATER -1)
54 math (EXPR _index "${_index}")
55 string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME)
56 else()
57 set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}")
58 endif()
59
d6fbb2ab 60 if (WIN32)
61 list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE_NAME}_DLL")
62 endif()
e713baee 63
d6fbb2ab 64 set (SOURCE_FILES)
65 set (HEADER_FILES)
e713baee 66
d6fbb2ab 67 # Generate Flex and Bison files
68 if (${BUILD_YACCLEX})
69 # flex files
70 OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
71 list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
e713baee 72
d6fbb2ab 73 # bison files
74 OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
75 list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
e713baee 76
d6fbb2ab 77 if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
e713baee 78
d6fbb2ab 79 list (SORT SOURCE_FILES_FLEX)
80 list (SORT SOURCE_FILES_BISON)
e713baee 81
d6fbb2ab 82 math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
83 foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
e713baee 84
d6fbb2ab 85 list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
86 get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
e713baee 87
d6fbb2ab 88 list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
89 get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
e713baee 90
d6fbb2ab 91 string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
92
93 if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
94 set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
95 set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
fba34cf8 96 BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME} -l")
97 FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME} -L")
d6fbb2ab 98 ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
e713baee 99
d6fbb2ab 100 list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
101 endif()
102 endforeach()
e713baee 103 endif()
d6fbb2ab 104 endif()
316d77d9 105
d6fbb2ab 106 # header files
107 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES")
108 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
109 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
110 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
316d77d9 111
d6fbb2ab 112 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
f2e9c853 113 if(APPLE)
d6fbb2ab 114 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
f2e9c853 115 endif()
d6fbb2ab 116 else()
117 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
118 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
119 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
f2e9c853 120
d6fbb2ab 121 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
122 if(APPLE)
123 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
124 endif()
125 endif()
126
127 list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
128 list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
129 if(APPLE)
130 list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
316d77d9 131 endif()
d6fbb2ab 132
133 foreach(HEADER_FILE ${HEADER_FILES})
134 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
135 message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
136 list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
137 SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
138 else()
139 list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
140 SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
141 endif()
142 endforeach()
143
144 foreach(SOURCE_FILE ${SOURCE_FILES})
145 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
146 message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
147 list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
148 SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
149 else()
150 list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
151 SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
152 endif()
153 endforeach()
154
155 if (USE_QT)
156 FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES)
157 #message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}")
158 endif(USE_QT)
159
160 #message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}")
161 foreach(RESOURCE_FILE ${RESOURCE_FILES})
162 SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}")
163 endforeach()
316d77d9 164endforeach()
f2e9c853 165string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
166
dfadf641 167set (USED_RCFILE "")
168if (MSVC)
169 set (USED_RCFILE "${CMAKE_BINARY_DIR}/resources/${PROJECT_NAME}.rc")
170
171 if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in")
172 configure_file("${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
173 else()
174 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
175 endif()
176endif()
177
ada9ef40 178set (CURRENT_MODULE)
1fa16152 179foreach (OCCT_MODULE ${OCC_MODULES_LIST})
180 list (FIND ${OCCT_MODULE}_${OCCT_TOOLKITS_NAME_SUFFIX} ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
181
ada9ef40 182 if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1)
183 set (CURRENT_MODULE ${OCCT_MODULE})
184 endif()
185endforeach()
186
6acbb1c6 187if (MSVC)
ada9ef40 188 OCCT_INSERT_CODE_FOR_TARGET ()
189endif()
190
1fa16152 191if (USE_QT)
192 FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES")
193 #message("MOC files: ${${PROJECT_NAME}_MOC_FILES}")
194endif (USE_QT)
195
196if (EXECUTABLE_PROJECT)
197 add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
fb3267c7 198
ada9ef40 199 install (TARGETS ${PROJECT_NAME}
d26375e2 200 DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
fb3267c7 201else()
1fa16152 202 add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
fb3267c7 203
ada9ef40 204 if (MSVC)
956d6346 205 install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
206 CONFIGURATIONS Debug RelWithDebInfo
d26375e2 207 DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
fb3267c7 208 endif()
46bd680a 209
210 if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
211 set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX})
212 set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")
213 endif()
214
ada9ef40 215 install (TARGETS ${PROJECT_NAME}
216 EXPORT OpenCASCADE${CURRENT_MODULE}Targets
217 RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}"
218 ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}"
219 LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}")
46bd680a 220
221 if (NOT WIN32)
222 if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
223 set (LINK_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}")
224 set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
225 OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME})
226 endif()
227 endif()
fb3267c7 228endif()
229
fb3267c7 230if (CURRENT_MODULE)
1fa16152 231 set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "${OCC_TARGET_FOLDER}/${CURRENT_MODULE}")
ada9ef40 232 set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}")
09eca2b5 233 if (APPLE)
234 if (NOT "${INSTALL_NAME_DIR}" STREQUAL "")
235 set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}")
236 endif()
237 endif()
fb3267c7 238endif()
316d77d9 239
096ef695 240get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR)
241get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR)
242get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE)
243
41c012f0 244if (ANDROID)
245 # do not append version to the filename
246 set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
247else()
248 set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
249 SOVERSION "${OCC_VERSION_MAJOR}"
250 VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
251endif()
fb3267c7 252
253set (USED_TOOLKITS_BY_CURRENT_PROJECT)
254set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
255
256# parce EXTERNLIB file
1fa16152 257FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
fb3267c7 258foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
a6874708 259 string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
260 if (NOT COMMENT_FOUND)
261 string (REGEX MATCH "^TK" TK_FOUND ${USED_ITEM})
262 string (REGEX MATCH "^vtk" VTK_FOUND ${USED_ITEM})
263
8197951d 264 if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
a6874708 265 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
8197951d 266 if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK)
c22e576d 267 OCCT_INSTALL_VTK(${USED_ITEM})
268 endif()
a6874708 269 else()
270 string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
271 if ("${CSF_FOUND}" STREQUAL "")
272 message (STATUS "Info: ${USED_ITEM} from ${PROJECT_NAME} skipped due to it is empty")
273 else() # get CSF_ value
274 set (CURRENT_CSF ${${USED_ITEM}})
a20cce39 275 if (NOT "x${CURRENT_CSF}" STREQUAL "x")
4fecc365 276 set (LIBRARY_FROM_CACHE 0)
a6874708 277 separate_arguments (CURRENT_CSF)
4fecc365 278 foreach (CSF_LIBRARY ${CURRENT_CSF})
279 string (TOLOWER "${CSF_LIBRARY}" CSF_LIBRARY)
280 string (REPLACE "+" "[+]" CSF_LIBRARY "${CSF_LIBRARY}")
281 string (REPLACE "." "" CSF_LIBRARY "${CSF_LIBRARY}")
282 get_cmake_property(ALL_CACHE_VARIABLES CACHE_VARIABLES)
283 string (REGEX MATCHALL "(^|;)3RDPARTY_[^;]+_LIBRARY[^;]*" ALL_CACHE_VARIABLES "${ALL_CACHE_VARIABLES}")
284 foreach (CACHE_VARIABLE ${ALL_CACHE_VARIABLES})
285 set (CURRENT_CACHE_LIBRARY ${${CACHE_VARIABLE}})
286 string (TOLOWER "${CACHE_VARIABLE}" CACHE_VARIABLE)
287
288 if (EXISTS "${CURRENT_CACHE_LIBRARY}" AND NOT IS_DIRECTORY "${CURRENT_CACHE_LIBRARY}")
289 string (REGEX MATCH "_${CSF_LIBRARY}$" IS_ENDING "${CACHE_VARIABLE}")
290 string (REGEX MATCH "^([a-z]+)" CSF_WO_VERSION "${CSF_LIBRARY}")
291 string (REGEX MATCH "_${CSF_WO_VERSION}$" IS_ENDING_WO_VERSION "${CACHE_VARIABLE}")
292 if ("3rdparty_${CSF_LIBRARY}_library" STREQUAL "${CACHE_VARIABLE}" OR
293 "3rdparty_${CSF_WO_VERSION}_library" STREQUAL "${CACHE_VARIABLE}" OR
294 NOT "x${IS_ENDING}" STREQUAL "x" OR
295 NOT "x${IS_ENDING_WO_VERSION}" STREQUAL "x")
296 list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT "${CURRENT_CACHE_LIBRARY}")
297 set (LIBRARY_FROM_CACHE 1)
298 endif()
299 endif()
300 endforeach()
301 endforeach()
302
303 if (NOT ${LIBRARY_FROM_CACHE})
304 # prepare a list from a string with whitespaces
305 separate_arguments (CURRENT_CSF)
306 list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF})
307 endif()
a6874708 308 endif()
fb3267c7 309 endif()
316d77d9 310 endif()
311 endif()
fb3267c7 312endforeach()
316d77d9 313
e713baee 314if (APPLE)
315 list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND)
316 if (NOT ${IS_X11_FOUND} EQUAL -1)
317 find_package (X11 COMPONENTS X11 Xext Xmu Xi)
318 if (NOT X11_FOUND)
a6874708 319 message (STATUS "Warning: X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org")
e713baee 320 endif()
321 endif()
322endif()
323
88d533be 324# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
325# Add VTK_OPENGL2_BACKEND definition.
8e16477b 326if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2" OR IS_VTK_9XX)
88d533be 327 add_definitions(-DVTK_OPENGL2_BACKEND)
328 foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
8197951d 329 list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
88d533be 330 if (NOT ${IS_VTK_OPENGL_FOUND} EQUAL -1)
8197951d 331 list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT ${VTK_EXCLUDE_LIBRARY})
88d533be 332 if (${VTK_EXCLUDE_LIBRARY} STREQUAL vtkRenderingOpenGL)
8197951d 333 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingOpenGL2)
4f26118e 334 if(VTK_MAJOR_VERSION GREATER 6)
8197951d 335 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingGL2PSOpenGL2)
4f26118e 336 endif()
88d533be 337 endif()
338 endif()
339 endforeach()
4f26118e 340else()
341 if(VTK_MAJOR_VERSION EQUAL 6 AND VTK_MINOR_VERSION GREATER 2 OR VTK_MAJOR_VERSION GREATER 6)
8197951d 342 list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "vtkRenderingFreeTypeOpenGL" IS_VTK_RENDER_FREETYPE_FOUND)
4f26118e 343 if (NOT ${IS_VTK_RENDER_FREETYPE_FOUND} EQUAL -1)
8197951d 344 list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT "vtkRenderingFreeTypeOpenGL")
4f26118e 345 endif()
346 endif()
88d533be 347endif()
348
3321f684 349if (BUILD_SHARED_LIBS)
8e16477b 350 if(IS_VTK_9XX)
351 string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
352 endif()
8197951d 353 target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
3321f684 354endif()
896faa72 355
1fa16152 356if (USE_QT)
357 foreach (PROJECT_LIBRARY_DEBUG ${PROJECT_LIBRARIES_DEBUG})
358 target_link_libraries (${PROJECT_NAME} debug ${PROJECT_LIBRARY_DEBUG})
359 endforeach()
360 foreach (PROJECT_LIBRARY_RELEASE ${PROJECT_LIBRARIES_RELEASE})
361 target_link_libraries (${PROJECT_NAME} optimized ${PROJECT_LIBRARY_RELEASE})
362 endforeach()
363endif()
364
a131689d 365# suppress deprecation warnings inside OCCT itself for old gcc versions with unavailable Standard_DISABLE_DEPRECATION_WARNINGS
366if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
367 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6.0)
368 add_definitions("-DOCCT_NO_DEPRECATED")
369 message (STATUS "Warning: internal deprecation warnings by Standard_DEPRECATED have been disabled due to old gcc version being used")
370 endif()
371endif()
372
896faa72 373# use Cotire to accelerate build via usage of precompiled headers
374if (BUILD_USE_PCH)
375 if (WIN32)
376 # prevent definition of min and max macros through inclusion of Windows.h
377 # (for cotire builds)
378 add_definitions("-DNOMINMAX")
379 # avoid warnings on deprecated names from standard C library (see strsafe.h)
380 add_definitions("-DSTRSAFE_NO_DEPRECATE")
381 # avoid "std::Equal1" warning in QANCollection_Stl.cxx in debug mode
382 # suggesting using msvc "Checked Iterators"
383 add_definitions("-D_SCL_SECURE_NO_WARNINGS")
384 endif()
385
386 # Exclude system-provided glext.h.
387 # These macros are already defined within OpenGl_GlFunctions.hxx,
388 # however we have to duplicate them here for building TKOpenGl with PCH.
389 add_definitions("-DGL_GLEXT_LEGACY")
390 add_definitions("-DGLX_GLXEXT_LEGACY")
391
392 # workaround for old gcc
393 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
08f8a185 394 add_definitions("-D__STDC_CONSTANT_MACROS")
896faa72 395 add_definitions("-D__STDC_FORMAT_MACROS")
396 endif()
397
398 # unity builds are not used since they do not add speed but cause conflicts
399 # in TKV3d
400 set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
401
402 cotire(${PROJECT_NAME})
403endif()