-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
325 lines (254 loc) · 10.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
cmake_minimum_required(VERSION 3.10)
project(VTKPythonPackage NONE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(VTKPythonPackage)
if(NOT DEFINED VTKPythonPackage_SUPERBUILD)
set(VTKPythonPackage_SUPERBUILD 1)
endif()
if(VTKPythonPackage_SUPERBUILD)
#-----------------------------------------------------------------------------
#------------------------------------------------------
#----------------------------------
# VTKPythonPackage_SUPERBUILD: ON
#----------------------------------
#------------------------------------------------------
#-----------------------------------------------------------------------------
set(ep_common_cmake_cache_args)
if(NOT CMAKE_CONFIGURATION_TYPES)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
)
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET})
endif()
if(CMAKE_OSX_ARCHITECTURES)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
endif()
if(CMAKE_MAKE_PROGRAM)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM})
endif()
# Avoid "Manually-specified variables were not used by the project" warnings.
vpp_unused_vars(${PYTHON_VERSION_STRING} ${SKBUILD})
#-----------------------------------------------------------------------------
# Options
# When building different "flavor" of VTK python packages on a given platform,
# explicitly setting the following options allow to speed up package generation by
# re-using existing resources.
#
# VTK_SOURCE_DIR: Path to an existing source directory
# VTK_Group_Web: Whether web package should be included
# VTK_OPENGL_HAS_OSMESA: Whether to use OSMesa for offscreen rendering
#
option(VTKPythonPackage_BUILD_PYTHON "Build VTK python module" ON)
mark_as_advanced(VTKPythonPackage_BUILD_PYTHON)
option(VTK_Group_Web "Build VTK web module" OFF)
mark_as_advanced(VTK_Group_Web)
option(VTK_OPENGL_HAS_EGL "Use EGL for offscreen rendering" OFF)
mark_as_advanced(VTK_OPENGL_HAS_EGL)
# This is a Linux only option and the valid values can be either
# "LEGACY" or "GLVND". More information here:
# https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
if(UNIX AND NOT APPLE)
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Set the preferred OpenGL library")
if(NOT OpenGL_GL_PREFERENCE MATCHES "^(LEGACY|GLVND)$")
message(FATAL_ERROR "Unknown value for OpenGL_GL_PREFERENCE. Valid values are LEGACY or GLVND")
endif()
# Set the possible values of build type for cmake-gui
set_property(CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS "LEGACY" "GLVND")
endif()
option(VTK_OPENGL_HAS_OSMESA "Use OSMesa for offscreen rendering" OFF)
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)
if(VTK_OPENGL_HAS_OSMESA OR APPLE OR WIN32)
set(VTK_USE_X OFF)
else()
set(VTK_USE_X ON)
endif()
if(UNIX AND NOT APPLE)
list(APPEND ep_common_cmake_cache_args
-DOpenGL_GL_PREFERENCE:STRING=${OpenGL_GL_PREFERENCE})
endif()
#-----------------------------------------------------------------------------
include(ExternalProject)
set(VTK_REPOSITORY "https://github.com/kitware/VTK.git")
# VTK nightly-master 2018-05-14
set(VTK_GIT_TAG "v8.1.2")
#-----------------------------------------------------------------------------
# A separate project is used to download VTK, so that it can reused
# when building different "flavor" of VTK python packages
message(STATUS "SuperBuild -")
message(STATUS "SuperBuild - VTK-source-download")
# Sanity checks
if(DEFINED VTK_SOURCE_DIR AND NOT EXISTS ${VTK_SOURCE_DIR})
message(FATAL_ERROR "VTK_SOURCE_DIR variable is defined but corresponds to nonexistent directory")
endif()
if(NOT DEFINED VTK_SOURCE_DIR)
set(VTK_SOURCE_DIR ${CMAKE_BINARY_DIR}/VTK-source)
ExternalProject_add(VTK-source-download
SOURCE_DIR ${VTK_SOURCE_DIR}
GIT_REPOSITORY ${VTK_REPOSITORY}
GIT_TAG ${VTK_GIT_TAG}
USES_TERMINAL_DOWNLOAD 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set(proj_status "")
else()
vpp_ExternalProject_Add_Empty(
VTK-source-download
""
)
set(proj_status " (REUSE)")
endif()
message(STATUS "SuperBuild - VTK_SOURCE_DIR: ${VTK_SOURCE_DIR}")
message(STATUS "SuperBuild - VTK-source-download[OK]${proj_status}")
#-----------------------------------------------------------------------------
if(NOT VTKPythonPackage_BUILD_PYTHON)
return()
endif()
#-----------------------------------------------------------------------------
# Search for python interpreter and libraries
message(STATUS "SuperBuild -")
message(STATUS "SuperBuild - Searching for python")
# Sanity checks
if(DEFINED PYTHON_INCLUDE_DIR AND NOT EXISTS ${PYTHON_INCLUDE_DIR})
message(FATAL_ERROR "PYTHON_INCLUDE_DIR variable is defined but corresponds to nonexistent directory")
endif()
if(DEFINED PYTHON_LIBRARY AND NOT EXISTS ${PYTHON_LIBRARY})
message(FATAL_ERROR "PYTHON_LIBRARY variable is defined but corresponds to nonexistent file")
endif()
if(DEFINED PYTHON_EXECUTABLE AND NOT EXISTS ${PYTHON_EXECUTABLE})
message(FATAL_ERROR "PYTHON_EXECUTABLE variable is defined but corresponds to nonexistent file")
endif()
if(NOT DEFINED PYTHON_INCLUDE_DIR
OR NOT DEFINED PYTHON_LIBRARY
OR NOT DEFINED PYTHON_EXECUTABLE)
find_package ( PythonLibs REQUIRED )
find_package ( PythonInterp REQUIRED )
endif()
message(STATUS "SuperBuild - PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}")
message(STATUS "SuperBuild - PYTHON_LIBRARY: ${PYTHON_LIBRARY}")
message(STATUS "SuperBuild - PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message(STATUS "SuperBuild - Searching for python[OK]")
#-----------------------------------------------------------------------------
# VTK: This project builds VTK and associated Python modules
set(VTK_BINARY_DIR "${CMAKE_BINARY_DIR}/VTK-build" CACHE PATH "VTK build directory")
message(STATUS "SuperBuild -")
message(STATUS "SuperBuild - VTK => Requires VTK-source-download")
message(STATUS "SuperBuild - VTK_BINARY_DIR: ${VTK_BINARY_DIR}")
set(_stamp "${CMAKE_BINARY_DIR}/VTK-prefix/src/VTK-stamp/VTK-configure")
if(EXISTS ${_stamp})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${_stamp})
message(STATUS "SuperBuild - Force re-configure removing ${_stamp}")
endif()
set(install_dir "vtk")
# Platform specific options
if(UNIX AND NOT APPLE)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_INSTALL_RPATH:STRING=$ORIGIN
)
elseif(APPLE)
list(APPEND ep_common_cmake_cache_args
-DCMAKE_INSTALL_NAME_DIR:STRING=@loader_path
-DCMAKE_INSTALL_RPATH:STRING=@loader_path
)
endif()
ExternalProject_add(VTK
DOWNLOAD_COMMAND ""
SOURCE_DIR ${VTK_SOURCE_DIR}
BINARY_DIR ${VTK_BINARY_DIR}
CMAKE_CACHE_ARGS
# General options
-DBUILD_TESTING:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DVTK_USE_PARALLEL:BOOL=ON
-DVTK_DEBUG_LEAKS:BOOL=OFF
-DVTK_LEGACY_REMOVE:BOOL=ON
-DVTK_ENABLE_KITS:BOOL=ON
# Python options
-DVTK_WRAP_TCL:BOOL=OFF
-DVTK_WRAP_PYTHON:BOOL=ON
-DVTK_ENABLE_VTKPYTHON:BOOL=OFF
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
# Install options
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DVTK_INSTALL_PYTHON_MODULE_DIR:STRING=${CMAKE_INSTALL_PREFIX}
-DVTK_INSTALL_RUNTIME_DIR:PATH=${install_dir}
-DVTK_INSTALL_LIBRARY_DIR:PATH=${install_dir}
-DVTK_INSTALL_ARCHIVE_DIR:PATH=${install_dir}
-DVTK_INSTALL_NO_DEVELOPMENT:BOOL=ON
# Rendering options
-DVTK_Group_Qt:BOOL=OFF # XXX Enabled this later
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_OPENGL_HAS_OSMESA:BOOL=${VTK_OPENGL_HAS_OSMESA}
-DVTK_OPENGL_HAS_EGL:BOOL=${VTK_OPENGL_HAS_EGL}
-DVTK_USE_X:BOOL=${VTK_USE_X}
# Module options
-DVTK_Group_Web:BOOL=${VTK_Group_Web}
${ep_common_cmake_cache_args}
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_UPDATE 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
INSTALL_COMMAND ""
)
set(proj_status "")
ExternalProject_Add_StepDependencies(VTK download VTK-source-download)
message(STATUS "SuperBuild - VTK[OK]${proj_status}")
#-----------------------------------------------------------------------------
# VTKPythonPackage: This project adds install rules for the "RuntimeLibraries"
# components associated with the VTK project.
message(STATUS "SuperBuild -")
message(STATUS "SuperBuild - ${PROJECT_NAME} => Requires VTK")
if(NOT DEFINED VTKPythonPackage_WHEEL_NAME)
set(VTKPythonPackage_WHEEL_NAME "vtk")
endif()
message(STATUS "SuperBuild - VTKPythonPackage_WHEEL_NAME:${VTKPythonPackage_WHEEL_NAME}")
ExternalProject_add(${PROJECT_NAME}
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-build
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
CMAKE_CACHE_ARGS
-DVTKPythonPackage_SUPERBUILD:BOOL=0
-DVTK_BINARY_DIR:PATH=${VTK_BINARY_DIR}
-DVTK_SOURCE_DIR:PATH=${VTK_SOURCE_DIR}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DVTKPythonPackage_WHEEL_NAME:STRING=${VTKPythonPackage_WHEEL_NAME}
${ep_common_cmake_cache_args}
USES_TERMINAL_CONFIGURE 1
INSTALL_COMMAND ""
DEPENDS VTK
)
install(SCRIPT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-build/cmake_install.cmake)
message(STATUS "SuperBuild - ${PROJECT_NAME}[OK]")
else()
#-----------------------------------------------------------------------------
#------------------------------------------------------
#----------------------------------
# VTKPythonPackage_SUPERBUILD: OFF
#----------------------------------
#------------------------------------------------------
#-----------------------------------------------------------------------------
set(components "RuntimeLibraries")
#-----------------------------------------------------------------------------
# Install VTK components
message(STATUS "Adding install rules for components:")
foreach(component IN LISTS components)
message(STATUS " ${component}")
install(CODE "
unset(CMAKE_INSTALL_COMPONENT)
set(COMPONENT \"${component}\")
set(CMAKE_INSTALL_DO_STRIP 1)
include\(\"${VTK_BINARY_DIR}/cmake_install.cmake\")
unset(CMAKE_INSTALL_COMPONENT)
")
endforeach()
endif()