-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
309 lines (264 loc) · 10.2 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
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.13.4)
#-----------------------------------------------------------------------------
project(vtkAddon
LANGUAGES CXX C
DESCRIPTION "General-purpose features that may be integrated into VTK library in the future."
)
set(vtkAddon_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${vtkAddon_CMAKE_DIR} ${CMAKE_MODULE_PATH})
include(CMakeDependentOption)
include(vtkAddonFunctionAddExecutable)
# --------------------------------------------------------------------------
# Dependencies
# --------------------------------------------------------------------------
#
# VTK
#
find_package(VTK REQUIRED)
if(${VTK_VERSION} VERSION_LESS "8.90")
include(${VTK_USE_FILE})
endif()
set(vtkAddon_LIBS ${VTK_LIBRARIES})
# --------------------------------------------------------------------------
# Options
# --------------------------------------------------------------------------
if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build with shared libraries." ON)
endif()
if(NOT DEFINED BUILD_TESTING)
option(BUILD_TESTING "Test the project" OFF)
endif()
if(NOT DEFINED vtkAddon_USE_UTF8)
option(vtkAddon_USE_UTF8 "Make applications use UTF-8 as code page." OFF)
endif()
if(NOT DEFINED vtkAddon_WRAP_PYTHON)
cmake_dependent_option(vtkAddon_WRAP_PYTHON "Build python wrapping" OFF "VTK_WRAP_PYTHON" OFF)
endif()
if(NOT DEFINED vtkAddon_LAUNCH_COMMAND)
set(vtkAddon_LAUNCH_COMMAND "" CACHE STRING "Command for setting up environment and running executables")
endif()
# --------------------------------------------------------------------------
# Configure headers
# --------------------------------------------------------------------------
set(configure_header_file vtkAddonConfigure.h)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${configure_header_file}.in
${CMAKE_CURRENT_BINARY_DIR}/${configure_header_file}
)
# --------------------------------------------------------------------------
# Install headers
# --------------------------------------------------------------------------
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
set(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT ON)
endif()
if(NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_INCLUDE_DIR)
set(${PROJECT_NAME}_INSTALL_INCLUDE_DIR include/${PROJECT_NAME})
endif()
file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
install(
FILES ${headers} ${CMAKE_CURRENT_BINARY_DIR}/${configure_header_file}
DESTINATION ${${PROJECT_NAME}_INSTALL_INCLUDE_DIR} COMPONENT Development)
file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.txx")
install(
FILES ${headers} ${CMAKE_CURRENT_BINARY_DIR}/${configure_header_file}
DESTINATION ${${PROJECT_NAME}_INSTALL_INCLUDE_DIR} COMPONENT Development)
endif()
# --------------------------------------------------------------------------
# Sources
# --------------------------------------------------------------------------
set(vtkAddon_SRCS
vtkAddonMathUtilities.cxx
vtkAddonMathUtilities.h
vtkAddonSetGet.h
vtkAddonTestingUtilities.cxx
vtkAddonTestingUtilities.h
vtkAddonTestingUtilities.txx
vtkCurveGenerator.cxx
vtkCurveGenerator.h
vtkErrorSink.cxx
vtkErrorSink.h
vtkImageLabelDilate3D.cxx
vtkImageLabelDilate3D.h
vtkLinearSpline.cxx
vtkLinearSpline.h
vtkLoggingMacros.h
vtkOrientedBSplineTransform.cxx
vtkOrientedBSplineTransform.h
vtkOrientedGridTransform.cxx
vtkOrientedGridTransform.h
vtkParallelTransportFrame.cxx
vtkParallelTransportFrame.h
vtkParametricPolynomialApproximation.cxx
vtkParametricPolynomialApproximation.h
vtkPersonInformation.cxx
vtkPersonInformation.h
vtkRawRGBVolumeCodec.cxx
vtkRawRGBVolumeCodec.h
vtkSingleton.h
vtkSlicerDijkstraGraphGeodesicPath.cxx
vtkSlicerDijkstraGraphGeodesicPath.h
vtkStreamingVolumeCodec.cxx
vtkStreamingVolumeCodec.h
vtkStreamingVolumeCodecFactory.cxx
vtkStreamingVolumeCodecFactory.h
vtkStreamingVolumeFrame.cxx
vtkStreamingVolumeFrame.h
vtkTestingOutputWindow.cxx
vtkTestingOutputWindow.h
)
if(VTK_RENDERING_BACKEND STREQUAL "OpenGL2")
set(vtkAddon_SRCS
${vtkAddon_SRCS}
vtkOpenGLShaderComputation.cxx
vtkOpenGLShaderComputation.h
vtkOpenGLTextureImage.cxx
vtkOpenGLTextureImage.h
)
find_package(OpenGL)
set(vtkAddon_LIBS
${vtkAddon_LIBS}
${OPENGL_LIBRARIES}
)
endif()
# Abstract/pure virtual classes
#set_source_files_properties(
# ABSTRACT
# )
# Helper classes
set_source_files_properties(
vtkAddonSetGet.h
vtkAddonTestingUtilities.h
vtkLoggingMacros.h
WRAP_EXCLUDE
)
# --------------------------------------------------------------------------
# Include dirs
# --------------------------------------------------------------------------
set(include_dirs
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
include_directories(BEFORE ${include_dirs})
# --------------------------------------------------------------------------
# Build library
# --------------------------------------------------------------------------
set(lib_name ${PROJECT_NAME})
set(srcs ${vtkAddon_SRCS})
add_library(${lib_name} ${srcs})
target_link_libraries(${lib_name} ${vtkAddon_LIBS})
# --------------------------------------------------------------------------
# Folder
# --------------------------------------------------------------------------
if(NOT DEFINED ${PROJECT_NAME}_FOLDER)
set(${PROJECT_NAME}_FOLDER ${PROJECT_NAME})
endif()
if(NOT "${${PROJECT_NAME}_FOLDER}" STREQUAL "")
set_target_properties(${lib_name} PROPERTIES FOLDER ${${PROJECT_NAME}_FOLDER})
endif()
# --------------------------------------------------------------------------
# Export target
# --------------------------------------------------------------------------
# Export targets for a build tree
if(NOT DEFINED ${PROJECT_NAME}_EXPORT_FILE)
set(${PROJECT_NAME}_EXPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
endif()
export(TARGETS ${lib_name} APPEND FILE ${${PROJECT_NAME}_EXPORT_FILE})
# --------------------------------------------------------------------------
# Install library
# --------------------------------------------------------------------------
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_BIN_DIR)
set(${PROJECT_NAME}_INSTALL_BIN_DIR bin)
endif()
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_LIB_DIR)
set(${PROJECT_NAME}_INSTALL_LIB_DIR lib/${PROJECT_NAME})
endif()
install(TARGETS ${lib_name}
RUNTIME DESTINATION ${${PROJECT_NAME}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${PROJECT_NAME}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${PROJECT_NAME}_INSTALL_LIB_DIR} COMPONENT Development
)
# --------------------------------------------------------------------------
# Python Wrapping
# --------------------------------------------------------------------------
if(vtkAddon_WRAP_PYTHON)
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_PYTHON_MODULE_LIB_DIR)
set(${PROJECT_NAME}_INSTALL_PYTHON_MODULE_LIB_DIR ${${PROJECT_NAME}_INSTALL_LIB_DIR})
endif()
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_PYTHON_LIB_DIR)
set(${PROJECT_NAME}_INSTALL_PYTHON_LIB_DIR ${${PROJECT_NAME}_INSTALL_LIB_DIR})
endif()
include(vtkMacroKitPythonWrap)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${vtkAddon_SRCS}
KIT_INSTALL_BIN_DIR ${${PROJECT_NAME}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${PROJECT_NAME}_INSTALL_PYTHON_LIB_DIR}
KIT_MODULE_INSTALL_LIB_DIR ${${PROJECT_NAME}_INSTALL_PYTHON_MODULE_LIB_DIR}
)
# Export target
export(TARGETS ${lib_name}Python APPEND FILE ${${PROJECT_NAME}_EXPORT_FILE})
if(${VTK_VERSION} VERSION_LESS "8.90")
export(TARGETS ${lib_name}PythonD APPEND FILE ${${PROJECT_NAME}_EXPORT_FILE})
endif()
# Folder
if(NOT "${${PROJECT_NAME}_FOLDER}" STREQUAL "")
set_target_properties(${lib_name}Python PROPERTIES FOLDER ${${PROJECT_NAME}_FOLDER})
if(${VTK_VERSION} VERSION_LESS "8.90")
set_target_properties(${lib_name}PythonD PROPERTIES FOLDER ${${PROJECT_NAME}_FOLDER})
endif()
if(TARGET ${lib_name}Hierarchy)
set_target_properties(${lib_name}Hierarchy PROPERTIES FOLDER ${${PROJECT_NAME}_FOLDER})
endif()
endif()
endif()
# --------------------------------------------------------------------------
# Testing
# --------------------------------------------------------------------------
if(BUILD_TESTING)
include(CTest)
add_subdirectory(Testing)
endif()
# --------------------------------------------------------------------------
# Set INCLUDE_DIRS variable
# --------------------------------------------------------------------------
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "${PROJECT_NAME} include dirs" FORCE)
# --------------------------------------------------------------------------
# Configure support file
# --------------------------------------------------------------------------
# Configure 'vtkAddonConfig.cmake' for a build tree
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/vtkAddonConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/vtkAddonConfig.cmake
)
# Configuret vtkAddonConfig.cmake for an install tree
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/vtkAddonInstallConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/install/vtkAddonConfig.cmake
)
# --------------------------------------------------------------------------
# Install configuration files
# --------------------------------------------------------------------------
# Set vtkAddon_INSTALL_CMAKE_DIR
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_CMAKE_DIR)
set(${PROJECT_NAME}_INSTALL_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
endif()
# Install vtkAddonConfig.cmake
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/install/vtkAddonConfig.cmake
DESTINATION ${${PROJECT_NAME}_INSTALL_CMAKE_DIR}
)
# Install vtkAddon CMake files
install(
FILES
${CMAKE_SOURCE_DIR}/CMake/vtkAddonFunctionAddExecutable.cmake
${CMAKE_SOURCE_DIR}/CMake/vtkAddonFunctionAddExecutable.cmake
${CMAKE_SOURCE_DIR}/CMake/vtkMacroKitPythonWrap.cmake
${CMAKE_SOURCE_DIR}/CMake/vtkWrapHierarchy.cmake
${CMAKE_SOURCE_DIR}/CMake/vtkWrapperInit.data.in
${CMAKE_SOURCE_DIR}/CMake/vtkWrapPython.cmake
${CMAKE_SOURCE_DIR}/CMake/WindowsApplicationUseUtf8.manifest
DESTINATION ${${PROJECT_NAME}_INSTALL_CMAKE_DIR} COMPONENT Development
)