forked from InsightSoftwareConsortium/ITK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
325 lines (288 loc) · 9.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
###############################################################################
# the macros in charge of dispatching to the language specific macros
macro(itk_wrap_modules_all_generators)
#! if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
#! INIT_itk_wrap_module_java()
#! endif()
if(ITK_WRAP_PYTHON)
itk_wrap_modules_python()
endif()
if(ITK_WRAP_TCL)
itk_wrap_modules_tcl()
endif()
if(ITK_WRAP_JAVA)
itk_wrap_modules_java()
endif()
if(ITK_WRAP_RUBY)
itk_wrap_modules_ruby()
endif()
endmacro()
macro(itk_end_wrap_modules_all_generators)
if(ITK_WRAP_PYTHON)
itk_end_wrap_modules_python()
endif()
if(ITK_WRAP_TCL)
itk_end_wrap_modules_tcl()
endif()
if(ITK_WRAP_JAVA)
itk_end_wrap_modules_java()
endif()
if(ITK_WRAP_RUBY)
itk_end_wrap_modules_ruby()
endif()
endmacro()
macro(itk_wrap_module_all_generators library_name)
if(ITK_WRAP_EXPLICIT)
itk_wrap_module_explicit("${library_name}")
endif()
if(ITK_WRAP_CASTXML)
itk_wrap_module_castxml("${library_name}")
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_wrap_module_swig_interface("${library_name}")
endif()
if(ITK_WRAP_DOC)
itk_wrap_module_DOC("${library_name}")
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_module_python("${library_name}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_module_tcl("${library_name}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_module_ruby("${library_name}")
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_wrap_module_java("${library_name}")
endif()
endmacro()
macro(itk_end_wrap_module_all_generators)
if(ITK_WRAP_EXPLICIT)
itk_end_wrap_module_explicit()
endif()
if(ITK_WRAP_CASTXML)
itk_end_wrap_module_castxml()
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_end_wrap_module_swig_interface()
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_end_wrap_module_python()
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_end_wrap_module_tcl()
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_end_wrap_module_ruby()
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_end_wrap_module_java()
endif()
if(ITK_WRAP_DOC)
itk_end_wrap_module_DOC()
endif()
endmacro()
macro(itk_wrap_submodule_all_generators module)
if(ITK_WRAP_EXPLICIT)
itk_wrap_submodule_explicit("${module}")
endif()
if(ITK_WRAP_CASTXML)
itk_wrap_submodule_castxml("${module}")
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_wrap_submodule_swig_interface("${module}")
endif()
if(ITK_WRAP_DOC)
itk_wrap_submodule_DOC("${module}")
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_submodule_python("${module}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_submodule_tcl("${module}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_submodule_ruby("${module}")
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_wrap_submodule_java("${module}")
endif()
endmacro()
macro(itk_end_wrap_submodule_all_generators module)
if(ITK_WRAP_EXPLICIT)
itk_end_wrap_submodule_explicit("${module}")
endif()
if(ITK_WRAP_CASTXML)
itk_end_wrap_submodule_castxml("${module}")
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_end_wrap_submodule_swig_interface("${module}")
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_end_wrap_submodule_python("${module}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_end_wrap_submodule_tcl("${module}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_end_wrap_submodule_ruby("${module}")
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_end_wrap_submodule_java("${module}")
endif()
if(ITK_WRAP_DOC)
itk_end_wrap_submodule_DOC()
endif()
endmacro()
macro(itk_wrap_class_all_generators class)
endmacro()
macro(itk_wrap_named_class_all_generators class swig_name)
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_named_class_python("${class}" "${swig_name}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_named_class_tcl("${class}" "${swig_name}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_named_class_ruby("${class}" "${swig_name}")
endif()
if(ITK_WRAP_DOC)
itk_wrap_named_class_DOC("${class}" "${swig_name}")
endif()
endmacro()
macro(itk_end_wrap_class_all_generators)
endmacro()
macro(itk_wrap_simple_class_all_generators class)
endmacro()
macro(itk_wrap_named_simple_class_all_generators class)
endmacro()
macro(itk_wrap_include_all_generators inc)
if(ITK_WRAP_EXPLICIT)
itk_wrap_include_explicit("${inc}")
endif()
if(ITK_WRAP_CASTXML)
itk_wrap_include_castxml("${inc}")
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_wrap_include_swig_interface("${inc}")
endif()
endmacro()
macro(itk_wrap_template_all_generators name types)
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_template_python("${name}" "${types}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_template_tcl("${name}" "${types}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_template_ruby("${name}" "${types}")
endif()
endmacro()
macro(itk_wrap_one_type_all_generators wrap_method wrap_class swig_name template_params)
if(ITK_WRAP_EXPLICIT)
itk_wrap_one_type_explicit("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_CASTXML)
itk_wrap_one_type_castxml("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_SWIGINTERFACE)
itk_wrap_one_type_swig_interface("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_DOC)
itk_wrap_one_type_DOC("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_one_type_python("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_one_type_tcl("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_one_type_ruby("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_wrap_one_type_java("${wrap_method}" "${wrap_class}" "${swig_name}" "${template_params}")
endif()
endmacro()
macro(itk_wrap_simple_type_all_generators wrap_class swig_name)
if(ITK_WRAP_CASTXML)
itk_wrap_simple_type_castxml("${wrap_class}" "${swig_name}")
endif()
if(ITK_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_simple_type_python("${wrap_class}" "${swig_name}")
endif()
if(ITK_WRAP_TCL AND WRAPPER_LIBRARY_TCL)
itk_wrap_simple_type_tcl("${wrap_class}" "${swig_name}")
endif()
if(ITK_WRAP_RUBY AND WRAPPER_LIBRARY_RUBY)
itk_wrap_simple_type_ruby("${wrap_class}" "${swig_name}")
endif()
if(ITK_WRAP_JAVA AND WRAPPER_LIBRARY_JAVA)
itk_wrap_simple_type_java("${wrap_class}" "${swig_name}")
endif()
endmacro()
###############################################################################
# ccache management. This option is shared by most of generators, so put it here.
option(ITK_USE_CCACHE "Use ccache to cache swig/castxml/... output and speedup the rebuild." OFF)
mark_as_advanced(ITK_USE_CCACHE)
if(ITK_USE_CCACHE)
find_program(CCACHE_EXECUTABLE NAMES ccache-swig ccache DOC "ccache executable.")
endif()
###############################################################################
# build the generators list
if(EXTERNAL_WRAP_ITK_PROJECT)
# generators there have been turned on while building wrapitk
set(default ON)
else()
if(DEFINED ITK_WRAP_GCCXML)
# Keep ITK_WRAP_GCCXML for backward compatibility.
set(ITK_WRAP_CASTXML "${ITK_WRAP_GCCXML}" CACHE STRING "Build xml files.")
else()
set(ITK_WRAP_CASTXML ON CACHE STRING "Build xml files.")
endif()
option(ITK_WRAP_SWIGINTERFACE "Build swig interfaces." ON)
set(default OFF)
mark_as_advanced(ITK_WRAP_CASTXML ITK_WRAP_SWIGINTERFACE)
endif()
set(WRAP_ITK_GENERATORS CACHE INTERNAL "Internal generators list.")
set(WRAP_ITK_UNUSED_GENERATORS CACHE INTERNAL "Internal unused generators list.")
file(GLOB local_files *)
# filter and reorder the list
set(generators )
foreach(f ${local_files})
file(RELATIVE_PATH lang "${CMAKE_CURRENT_SOURCE_DIR}" "${f}")
if(IS_DIRECTORY "${f}")
if("${lang}" MATCHES "^CastXML$|^SwigInterface$|^Doc$")
# put those generators before the others
set(generators ${lang} ${generators})
else()
list(APPEND generators ${lang})
endif()
endif()
endforeach()
foreach(lang ${generators})
string(TOUPPER "${lang}" lang_upper)
# add the language to the options
option(ITK_WRAP_${lang_upper} "Build swig ${lang} wrapper support." ${default})
# add the language to the list, if the user have turn it on, and include
# the subdirectory
if(ITK_WRAP_${lang_upper})
set(WRAP_ITK_GENERATORS ${WRAP_ITK_GENERATORS} "${lang}")
add_subdirectory("${lang}")
else()
set(WRAP_ITK_UNUSED_GENERATORS ${WRAP_ITK_UNUSED_GENERATORS} "${lang}")
endif()
endforeach()
mark_as_advanced(ITK_WRAP_EXPLICIT ITK_WRAP_DOC)
set(WRAP_ITK_GENERATORS ${WRAP_ITK_GENERATORS} CACHE INTERNAL "Internal generators list.")
set(WRAP_ITK_UNUSED_GENERATORS ${WRAP_ITK_UNUSED_GENERATORS} CACHE INTERNAL "Internal unused generators list.")
# The include_directories are added here to be used by
# Wrapping/ConfigureWrapping.cmake
foreach(lang ${generators})
string(TOUPPER "${lang}" lang_upper)
if(ITK_WRAP_${lang_upper})
get_directory_property(inc DIRECTORY "${lang}" INCLUDE_DIRECTORIES)
include_directories(${inc})
endif()
endforeach()