0026460: Implicit cast to TopoDS_Shape compilation error due to ambiguous conversion
[occt.git] / adm / cmake / vtk.cmake
CommitLineData
09c597c9 1# vtk
2
3if (NOT DEFINED INSTALL_VTK)
4 set (INSTALL_VTK OFF CACHE BOOL "Is vtk required to be copied into install directory")
5endif()
6
7# vtk directory
8if (NOT DEFINED 3RDPARTY_VTK_DIR)
9 set (3RDPARTY_VTK_DIR "" CACHE PATH "The directory containing vtk")
10endif()
11
12# vtk include directory
13if (NOT DEFINED 3RDPARTY_VTK_INCLUDE_DIR)
14 set (3RDPARTY_VTK_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of vtk")
15endif()
16
17# vtk library directory
18if (NOT DEFINED 3RDPARTY_VTK_LIBRARY_DIR)
19 set (3RDPARTY_VTK_LIBRARY_DIR "" CACHE FILEPATH "The directory containing vtk library")
20endif()
21
22# vtk dll directory
23if (WIN32 AND NOT DEFINED 3RDPARTY_VTK_DLL_DIR)
24 set (3RDPARTY_VTK_DLL_DIR "" CACHE FILEPATH "The directory containing VTK dll")
25endif()
26
27# search for vtk in user defined directory
28if (NOT 3RDPARTY_VTK_DIR AND 3RDPARTY_DIR)
29 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" vtk VTK_DIR_NAME)
30 if (VTK_DIR_NAME)
31 set (3RDPARTY_VTK_DIR "${3RDPARTY_DIR}/${VTK_DIR_NAME}" CACHE PATH "The directory containing vtk product" FORCE)
32 endif()
33endif()
34
35# find installed vtk
36find_package(VTK QUIET)
37
38# find native vtk
39if (NOT VTK_FOUND)
40 find_package(VTK QUIET PATHS "${3RDPARTY_VTK_DIR}")
41endif()
42
43if (NOT VTK_FOUND AND NOT 3RDPARTY_VTK_DIR OR NOT EXISTS "${3RDPARTY_VTK_DIR}")
44 message(SEND_ERROR "VTK not found. Set the 3RDPARTY_VTK_DIR cmake cache entry to the directory containing VTK.")
45 set (3RDPARTY_VTK_DIR "3RDPARTY_VTK_DIR-NOTFOUND" CACHE PATH "The directory containing vtk product" FORCE)
46endif()
47
09c597c9 48set(VTK_VERSION "")
49if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
50 get_filename_component(3RDPARTY_VTK_DIR_NAME "${3RDPARTY_VTK_DIR}" NAME)
51 string(REGEX MATCH "^VTK-([0-9].[0-9])" VTK_VERSION "${3RDPARTY_VTK_DIR_NAME}")
52 set(VTK_VERSION "${CMAKE_MATCH_1}")
53 if (NOT 3RDPARTY_VTK_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
54 set (3RDPARTY_VTK_INCLUDE_DIR "${3RDPARTY_VTK_DIR}/include/vtk-${VTK_VERSION}" CACHE FILEPATH "The directory containing includes of VTK" FORCE)
55 endif()
56 if (NOT 3RDPARTY_VTK_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_VTK_LIBRARY_DIR}")
fa0cbe55 57 if(EXISTS "${3RDPARTY_VTK_DIR}/lib")
58 set (3RDPARTY_VTK_LIBRARY_DIR "${3RDPARTY_VTK_DIR}/lib" CACHE FILEPATH "The directory containing libs of VTK" FORCE)
59 elseif (EXISTS "${3RDPARTY_VTK_DIR}/lib")
60 set (3RDPARTY_VTK_LIBRARY_DIR "${3RDPARTY_VTK_DIR}/lib" CACHE FILEPATH "The directory containing libs of VTK" FORCE)
61 endif()
82b4c249 62 endif()
63 if(3RDPARTY_VTK_LIBRARY_DIR)
09c597c9 64 list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_VTK_LIBRARY_DIR}")
65 endif()
66endif()
67
68# vtk libraries
69# lib
19286d7c 70set (VTK_LIBRARY_NAMES vtkCommonCore-${VTK_VERSION}.lib vtkCommonDataModel-${VTK_VERSION}.lib vtkCommonExecutionModel-${VTK_VERSION}.lib
71 vtkCommonMath-${VTK_VERSION}.lib vtkCommonTransforms-${VTK_VERSION}.lib vtkRenderingCore-${VTK_VERSION}.lib
72 vtkRenderingOpenGL-${VTK_VERSION}.lib vtkFiltersGeneral-${VTK_VERSION}.lib vtkIOCore-${VTK_VERSION}.lib
09c597c9 73 vtkIOImage-${VTK_VERSION}.lib vtkImagingCore-${VTK_VERSION}.lib vtkInteractionStyle-${VTK_VERSION}.lib )
74
75#dll
76set (VTK_DLL_NAMES vtkCommonComputationalGeometry-${VTK_VERSION}.dll
77 vtkCommonCore-${VTK_VERSION}.dll
78 vtkCommonDataModel-${VTK_VERSION}.dll
79 vtkCommonExecutionModel-${VTK_VERSION}.dll
80 vtkCommonMath-${VTK_VERSION}.dll
81 vtkCommonMisc-${VTK_VERSION}.dll
82 vtkCommonSystem-${VTK_VERSION}.dll
83 vtkCommonTransforms-${VTK_VERSION}.dll
84 vtkDICOMParser-${VTK_VERSION}.dll
85 vtkFiltersCore-${VTK_VERSION}.dll
86 vtkFiltersExtraction-${VTK_VERSION}.dll
87 vtkFiltersGeneral-${VTK_VERSION}.dll
88 vtkFiltersGeometry-${VTK_VERSION}.dll
89 vtkFiltersSources-${VTK_VERSION}.dll
90 vtkFiltersStatistics-${VTK_VERSION}.dll
91 vtkIOCore-${VTK_VERSION}.dll
92 vtkIOImage-${VTK_VERSION}.dll
93 vtkImagingCore-${VTK_VERSION}.dll
94 vtkImagingFourier-${VTK_VERSION}.dll
95 vtkImagingHybrid-${VTK_VERSION}.dll
96 vtkInteractionStyle-${VTK_VERSION}.dll
97 vtkRenderingCore-${VTK_VERSION}.dll
98 vtkRenderingOpenGL-${VTK_VERSION}.dll
99 vtkalglib-${VTK_VERSION}.dll
100 vtkjpeg-${VTK_VERSION}.dll
101 vtkmetaio-${VTK_VERSION}.dll
102 vtkpng-${VTK_VERSION}.dll
103 vtksys-${VTK_VERSION}.dll
104 vtktiff-${VTK_VERSION}.dll
105 vtkzlib-${VTK_VERSION}.dll )
106
107# search for dll directory
108if (WIN32)
109 if (NOT 3RDPARTY_VTK_DLL_DIR OR NOT EXISTS "${3RDPARTY_VTK_DLL_DIR}")
fa0cbe55 110 if(EXISTS "${3RDPARTY_VTK_DIR}/bin")
111 set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bin" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
112 elseif (EXISTS "${3RDPARTY_VTK_DIR}/bind")
113 set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bind" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
94829f84 114 endif()
09c597c9 115 endif()
94829f84 116
117 if (3RDPARTY_VTK_DLL_DIR OR EXISTS "${3RDPARTY_VTK_DLL_DIR}")
118 list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_VTK_DLL_DIR}")
119 endif()
120endif()
09c597c9 121
122OCCT_CHECK_AND_UNSET(VTK_DIR)
123
124if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
125 list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_VTK_INCLUDE_DIR}")
126else()
127 list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_VTK_INCLUDE_DIR)
128endif()
129
130if (INSTALL_VTK)
131 OCCT_MAKE_OS_WITH_BITNESS()
132 OCCT_MAKE_COMPILER_SHORT_NAME()
133 if (WIN32)
134 if(3RDPARTY_VTK_DLL_DIR AND EXISTS "${3RDPARTY_VTK_DLL_DIR}")
135 set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
136 foreach(VTK_DLL_NAME ${VTK_DLL_NAMES})
137 set (3RDPARTY_VTK_DLL "3RDPARTY_VTK_DLL-NOTFOUND" CACHE FILEPATH "VTK shared library" FORCE)
138 find_library(3RDPARTY_VTK_DLL "${VTK_DLL_NAME}" PATHS "${3RDPARTY_VTK_DLL_DIR}" NO_DEFAULT_PATH)
139 if (NOT 3RDPARTY_VTK_DLL OR NOT EXISTS "${3RDPARTY_VTK_DLL}")
140 list (APPEND 3RDPARTY_NOT_INCLUDED "${3RDPARTY_VTK_DLL}")
141 else()
fa0cbe55 142 install (FILES ${3RDPARTY_VTK_DLL}
143 CONFIGURATIONS Release
144 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
145 install (FILES ${3RDPARTY_VTK_DLL}
146 CONFIGURATIONS RelWithDebInfo
147 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
148 install (FILES ${3RDPARTY_VTK_DLL}
149 CONFIGURATIONS Debug
150 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
09c597c9 151 endif()
152 endforeach()
153 OCCT_CHECK_AND_UNSET(3RDPARTY_VTK_DLL)
154 endif()
155 else ()
156 foreach(VTK_DLL_NAME ${VTK_DLL_NAMES})
157 string(REPLACE ".dll" ".so.1" VTK_DLL_NAME "${VTK_DLL_NAME}")
fa0cbe55 158 install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
159 CONFIGURATIONS Release
160 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
161 RENAME "lib${VTK_DLL_NAME}")
162 install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
163 CONFIGURATIONS RelWithDebInfo
164 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
165 RENAME "lib${VTK_DLL_NAME}")
166 install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
167 CONFIGURATIONS Debug
168 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
169 RENAME "lib${VTK_DLL_NAME}")
09c597c9 170 endforeach()
171 endif()
0a66e59d 172
173 set (USED_3RDPARTY_VTK_DIR "")
174else()
175 # the library directory for using by the executable
176 if (WIN32)
177 set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_DLL_DIR})
178 else()
179 set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_LIBRARY_DIR})
180 endif()
09c597c9 181endif()
182
183mark_as_advanced (VTK_INCLUDE_DIRS VTK_LIBRARY_DIRS VTK_DIR)