0031875: Draw Harness, ViewerTest - command vaspects -mostContinuity lacks g1 and...
[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})
68922bcc 94
95 # Note: files are generated in original source directory (not in patch!)
96 set (FLEX_BISON_TARGET_DIR "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}")
97
98 # choose apropriate extension for generated files: "cxx" if source file contains
99 # instruction to generate C++ code, "c" otherwise
100 set (BISON_OUTPUT_FILE_EXT "c")
101 set (FLEX_OUTPUT_FILE_EXT "c")
102 file (STRINGS "${CURRENT_BISON_FILE}" FILE_BISON_CONTENT)
103 foreach (FILE_BISON_CONTENT_LINE ${FILE_BISON_CONTENT})
104 string (REGEX MATCH "%language \"C\\+\\+\"" CXX_BISON_LANGUAGE_FOUND ${FILE_BISON_CONTENT_LINE})
105 if (CXX_BISON_LANGUAGE_FOUND)
106 set (BISON_OUTPUT_FILE_EXT "cxx")
107 endif()
108 endforeach()
109 file (STRINGS "${CURRENT_FLEX_FILE}" FILE_FLEX_CONTENT)
110 foreach (FILE_FLEX_CONTENT_LINE ${FILE_FLEX_CONTENT})
111 string (REGEX MATCH "%option c\\+\\+" CXX_FLEX_LANGUAGE_FOUND ${FILE_FLEX_CONTENT_LINE})
112 if (CXX_FLEX_LANGUAGE_FOUND)
113 set (FLEX_OUTPUT_FILE_EXT "cxx")
114
115 # install copy of FlexLexer.h locally to allow further building without flex
116 if (FLEX_INCLUDE_DIR AND EXISTS "${FLEX_INCLUDE_DIR}/FlexLexer.h")
117 configure_file("${FLEX_INCLUDE_DIR}/FlexLexer.h" "${FLEX_BISON_TARGET_DIR}/FlexLexer.h" @ONLY NEWLINE_STYLE LF)
118 endif()
119 endif()
120 endforeach()
121 set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT})
122 set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.${FLEX_OUTPUT_FILE_EXT})
123
124 BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} "${FLEX_BISON_TARGET_DIR}/${BISON_OUTPUT_FILE}"
125 COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME} -l -M ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/=")
126 FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} "${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE}"
127 COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME} -L")
d6fbb2ab 128 ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
e713baee 129
d6fbb2ab 130 list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
131 endif()
132 endforeach()
e713baee 133 endif()
d6fbb2ab 134 endif()
316d77d9 135
d6fbb2ab 136 # header files
137 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES")
138 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
139 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
140 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
316d77d9 141
d6fbb2ab 142 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
f2e9c853 143 if(APPLE)
d6fbb2ab 144 file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
f2e9c853 145 endif()
d6fbb2ab 146 else()
147 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
148 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
149 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
f2e9c853 150
d6fbb2ab 151 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
152 if(APPLE)
153 file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
154 endif()
155 endif()
156
157 list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
158 list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
159 if(APPLE)
160 list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
316d77d9 161 endif()
d6fbb2ab 162
163 foreach(HEADER_FILE ${HEADER_FILES})
164 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
165 message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
166 list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
167 SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
168 else()
169 list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
170 SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
171 endif()
172 endforeach()
173
174 foreach(SOURCE_FILE ${SOURCE_FILES})
175 if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
176 message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
177 list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
178 SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
179 else()
180 list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
181 SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
182 endif()
183 endforeach()
184
185 if (USE_QT)
186 FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES)
187 #message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}")
188 endif(USE_QT)
189
190 #message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}")
191 foreach(RESOURCE_FILE ${RESOURCE_FILES})
192 SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}")
193 endforeach()
316d77d9 194endforeach()
f2e9c853 195string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
196
dfadf641 197set (USED_RCFILE "")
198if (MSVC)
199 set (USED_RCFILE "${CMAKE_BINARY_DIR}/resources/${PROJECT_NAME}.rc")
200
201 if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in")
202 configure_file("${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
203 else()
204 configure_file("${CMAKE_SOURCE_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
205 endif()
206endif()
207
ada9ef40 208set (CURRENT_MODULE)
1fa16152 209foreach (OCCT_MODULE ${OCC_MODULES_LIST})
210 list (FIND ${OCCT_MODULE}_${OCCT_TOOLKITS_NAME_SUFFIX} ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
211
ada9ef40 212 if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1)
213 set (CURRENT_MODULE ${OCCT_MODULE})
214 endif()
215endforeach()
216
6acbb1c6 217if (MSVC)
ada9ef40 218 OCCT_INSERT_CODE_FOR_TARGET ()
219endif()
220
1fa16152 221if (USE_QT)
222 FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES")
223 #message("MOC files: ${${PROJECT_NAME}_MOC_FILES}")
224endif (USE_QT)
225
226if (EXECUTABLE_PROJECT)
227 add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
fb3267c7 228
ada9ef40 229 install (TARGETS ${PROJECT_NAME}
d26375e2 230 DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
fb3267c7 231else()
1fa16152 232 add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
fb3267c7 233
ada9ef40 234 if (MSVC)
956d6346 235 install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
236 CONFIGURATIONS Debug RelWithDebInfo
d26375e2 237 DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
fb3267c7 238 endif()
46bd680a 239
240 if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
241 set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX})
242 set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")
243 endif()
244
ada9ef40 245 install (TARGETS ${PROJECT_NAME}
246 EXPORT OpenCASCADE${CURRENT_MODULE}Targets
247 RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}"
248 ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}"
249 LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}")
46bd680a 250
251 if (NOT WIN32)
252 if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
253 set (LINK_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}")
254 set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
255 OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME})
256 endif()
257 endif()
fb3267c7 258endif()
259
fb3267c7 260if (CURRENT_MODULE)
1fa16152 261 set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "${OCC_TARGET_FOLDER}/${CURRENT_MODULE}")
ada9ef40 262 set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}")
09eca2b5 263 if (APPLE)
264 if (NOT "${INSTALL_NAME_DIR}" STREQUAL "")
265 set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}")
266 endif()
267 endif()
fb3267c7 268endif()
316d77d9 269
096ef695 270get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR)
271get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR)
272get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE)
273
41c012f0 274if (ANDROID)
275 # do not append version to the filename
276 set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
277else()
278 set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
279 SOVERSION "${OCC_VERSION_MAJOR}"
280 VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
281endif()
fb3267c7 282
283set (USED_TOOLKITS_BY_CURRENT_PROJECT)
284set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
285
286# parce EXTERNLIB file
1fa16152 287FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
fb3267c7 288foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
a6874708 289 string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
290 if (NOT COMMENT_FOUND)
291 string (REGEX MATCH "^TK" TK_FOUND ${USED_ITEM})
292 string (REGEX MATCH "^vtk" VTK_FOUND ${USED_ITEM})
293
8197951d 294 if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
a6874708 295 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
8197951d 296 if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK)
c22e576d 297 OCCT_INSTALL_VTK(${USED_ITEM})
298 endif()
a6874708 299 else()
300 string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
301 if ("${CSF_FOUND}" STREQUAL "")
302 message (STATUS "Info: ${USED_ITEM} from ${PROJECT_NAME} skipped due to it is empty")
303 else() # get CSF_ value
304 set (CURRENT_CSF ${${USED_ITEM}})
a20cce39 305 if (NOT "x${CURRENT_CSF}" STREQUAL "x")
4fecc365 306 set (LIBRARY_FROM_CACHE 0)
a6874708 307 separate_arguments (CURRENT_CSF)
4fecc365 308 foreach (CSF_LIBRARY ${CURRENT_CSF})
309 string (TOLOWER "${CSF_LIBRARY}" CSF_LIBRARY)
310 string (REPLACE "+" "[+]" CSF_LIBRARY "${CSF_LIBRARY}")
311 string (REPLACE "." "" CSF_LIBRARY "${CSF_LIBRARY}")
312 get_cmake_property(ALL_CACHE_VARIABLES CACHE_VARIABLES)
313 string (REGEX MATCHALL "(^|;)3RDPARTY_[^;]+_LIBRARY[^;]*" ALL_CACHE_VARIABLES "${ALL_CACHE_VARIABLES}")
314 foreach (CACHE_VARIABLE ${ALL_CACHE_VARIABLES})
315 set (CURRENT_CACHE_LIBRARY ${${CACHE_VARIABLE}})
316 string (TOLOWER "${CACHE_VARIABLE}" CACHE_VARIABLE)
317
318 if (EXISTS "${CURRENT_CACHE_LIBRARY}" AND NOT IS_DIRECTORY "${CURRENT_CACHE_LIBRARY}")
319 string (REGEX MATCH "_${CSF_LIBRARY}$" IS_ENDING "${CACHE_VARIABLE}")
320 string (REGEX MATCH "^([a-z]+)" CSF_WO_VERSION "${CSF_LIBRARY}")
321 string (REGEX MATCH "_${CSF_WO_VERSION}$" IS_ENDING_WO_VERSION "${CACHE_VARIABLE}")
322 if ("3rdparty_${CSF_LIBRARY}_library" STREQUAL "${CACHE_VARIABLE}" OR
323 "3rdparty_${CSF_WO_VERSION}_library" STREQUAL "${CACHE_VARIABLE}" OR
324 NOT "x${IS_ENDING}" STREQUAL "x" OR
325 NOT "x${IS_ENDING_WO_VERSION}" STREQUAL "x")
326 list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT "${CURRENT_CACHE_LIBRARY}")
327 set (LIBRARY_FROM_CACHE 1)
328 endif()
329 endif()
330 endforeach()
331 endforeach()
332
333 if (NOT ${LIBRARY_FROM_CACHE})
334 # prepare a list from a string with whitespaces
335 separate_arguments (CURRENT_CSF)
336 list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF})
337 endif()
a6874708 338 endif()
fb3267c7 339 endif()
316d77d9 340 endif()
341 endif()
fb3267c7 342endforeach()
316d77d9 343
e713baee 344if (APPLE)
345 list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND)
346 if (NOT ${IS_X11_FOUND} EQUAL -1)
347 find_package (X11 COMPONENTS X11 Xext Xmu Xi)
348 if (NOT X11_FOUND)
a6874708 349 message (STATUS "Warning: X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org")
e713baee 350 endif()
351 endif()
352endif()
353
88d533be 354# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
355# Add VTK_OPENGL2_BACKEND definition.
8e16477b 356if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2" OR IS_VTK_9XX)
88d533be 357 add_definitions(-DVTK_OPENGL2_BACKEND)
358 foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
8197951d 359 list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
88d533be 360 if (NOT ${IS_VTK_OPENGL_FOUND} EQUAL -1)
8197951d 361 list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT ${VTK_EXCLUDE_LIBRARY})
88d533be 362 if (${VTK_EXCLUDE_LIBRARY} STREQUAL vtkRenderingOpenGL)
8197951d 363 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingOpenGL2)
4f26118e 364 if(VTK_MAJOR_VERSION GREATER 6)
8197951d 365 list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingGL2PSOpenGL2)
4f26118e 366 endif()
88d533be 367 endif()
368 endif()
369 endforeach()
4f26118e 370else()
371 if(VTK_MAJOR_VERSION EQUAL 6 AND VTK_MINOR_VERSION GREATER 2 OR VTK_MAJOR_VERSION GREATER 6)
8197951d 372 list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "vtkRenderingFreeTypeOpenGL" IS_VTK_RENDER_FREETYPE_FOUND)
4f26118e 373 if (NOT ${IS_VTK_RENDER_FREETYPE_FOUND} EQUAL -1)
8197951d 374 list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT "vtkRenderingFreeTypeOpenGL")
4f26118e 375 endif()
376 endif()
88d533be 377endif()
378
3321f684 379if (BUILD_SHARED_LIBS)
8e16477b 380 if(IS_VTK_9XX)
381 string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
382 endif()
8197951d 383 target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
3321f684 384endif()
896faa72 385
1fa16152 386if (USE_QT)
387 foreach (PROJECT_LIBRARY_DEBUG ${PROJECT_LIBRARIES_DEBUG})
388 target_link_libraries (${PROJECT_NAME} debug ${PROJECT_LIBRARY_DEBUG})
389 endforeach()
390 foreach (PROJECT_LIBRARY_RELEASE ${PROJECT_LIBRARIES_RELEASE})
391 target_link_libraries (${PROJECT_NAME} optimized ${PROJECT_LIBRARY_RELEASE})
392 endforeach()
393endif()
394
a131689d 395# suppress deprecation warnings inside OCCT itself for old gcc versions with unavailable Standard_DISABLE_DEPRECATION_WARNINGS
396if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
397 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6.0)
398 add_definitions("-DOCCT_NO_DEPRECATED")
399 message (STATUS "Warning: internal deprecation warnings by Standard_DEPRECATED have been disabled due to old gcc version being used")
400 endif()
401endif()
402
896faa72 403# use Cotire to accelerate build via usage of precompiled headers
404if (BUILD_USE_PCH)
405 if (WIN32)
406 # prevent definition of min and max macros through inclusion of Windows.h
407 # (for cotire builds)
408 add_definitions("-DNOMINMAX")
409 # avoid warnings on deprecated names from standard C library (see strsafe.h)
410 add_definitions("-DSTRSAFE_NO_DEPRECATE")
411 # avoid "std::Equal1" warning in QANCollection_Stl.cxx in debug mode
412 # suggesting using msvc "Checked Iterators"
413 add_definitions("-D_SCL_SECURE_NO_WARNINGS")
414 endif()
415
416 # Exclude system-provided glext.h.
417 # These macros are already defined within OpenGl_GlFunctions.hxx,
418 # however we have to duplicate them here for building TKOpenGl with PCH.
419 add_definitions("-DGL_GLEXT_LEGACY")
420 add_definitions("-DGLX_GLXEXT_LEGACY")
421
422 # workaround for old gcc
423 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
08f8a185 424 add_definitions("-D__STDC_CONSTANT_MACROS")
896faa72 425 add_definitions("-D__STDC_FORMAT_MACROS")
426 endif()
427
428 # unity builds are not used since they do not add speed but cause conflicts
429 # in TKV3d
430 set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
431
432 cotire(${PROJECT_NAME})
433endif()