VTK  9.0.1
vtkModule.cmake
Go to the documentation of this file.
1 #[==[
2 @defgroup module Module CMake APIs
3 @defgroup module-internal Module Internal CMake APIs
4 @defgroup module-impl Module Implementation CMake APIs
5 @defgroup module-support Module Support CMake APIs
6 #]==]
7 
8 #[==[
9 @ingroup module
10 @page module-api-overview Module API
11 
12 This module includes functions to find and build VTK modules. A module is a set
13 of related functionality. These are then compiled together into libraries at
14 the "kit" level. Each module may be enabled or disabled individually and its
15 dependencies will be built as needed.
16 
17 All functions strictly check their arguments. Any unrecognized or invalid
18 values for a function cause errors to be raised.
19 #]==]
20 
21 #[==[
22 @ingroup module-internal
23 @page module-internal-api Internal API
24 
25 The VTK module system provides some API functions for use by other code which
26 consumes VTK modules (primarily language wrappers). This file documents these
27 APIs. They may start with `_vtk_module`, but they are intended for use in cases
28 of language wrappers or dealing with trickier third party packages.
29 #]==]
30 
31 #[==[
32 @ingroup module-impl
33 @page module-impl-api Implementation API
34 
35 These functions are purely internal implementation details. No guarantees are
36 made for them and they may change at any time (including wrapping code calls).
37 Note that these functions are usually very lax in their argument parsing.
38 #]==]
39 
40 #[==[
41 @ingroup module-internal
42 @brief Conditionally output debug statements
43 
44 The @ref _vtk_module_debug function is provided to assist in debugging. It is
45 controlled by the `_vtk_module_log` variable which contains a list of "domains"
46 to debug.
47 
48 ~~~
49 _vtk_module_debug(<domain> <format>)
50 ~~~
51 
52 If the `domain` is enabled for debugging, the `format` argument is configured
53 and printed. It should contain `@` variable expansions to replace rather than
54 it being done outside. This helps to avoid the cost of generating large strings
55 when debugging is disabled.
56 #]==]
57 function (_vtk_module_debug domain format)
58  if (NOT _vtk_module_log STREQUAL "ALL" AND
59  NOT domain IN_LIST _vtk_module_log)
60  return ()
61  endif ()
62 
63  string(CONFIGURE "${format}" _vtk_module_debug_msg)
64  if (_vtk_module_debug_msg)
65  message(STATUS
66  "VTK module debug ${domain}: ${_vtk_module_debug_msg}")
67  endif ()
68 endfunction ()
69 
70 # TODO: Support finding `vtk.module` and `vtk.kit` contents in the
71 # `CMakeLists.txt` files for the module via a comment header.
72 
73 #[==[
74 @ingroup module
75 @brief Find `vtk.kit` files in a set of directories
76 
77 ~~~
78 vtk_module_find_kits(<output> [<directory>...])
79 ~~~
80 
81 This scans the given directories recursively for `vtk.kit` files and put the
82 paths into the output variable.
83 #]==]
84 function (vtk_module_find_kits output)
85  set(_vtk_find_kits_all)
86  foreach (_vtk_find_kits_directory IN LISTS ARGN)
87  file(GLOB_RECURSE _vtk_find_kits_kits
88  "${_vtk_find_kits_directory}/vtk.kit")
89  list(APPEND _vtk_find_kits_all
90  ${_vtk_find_kits_kits})
91  endforeach ()
92  set("${output}" ${_vtk_find_kits_all} PARENT_SCOPE)
93 endfunction ()
94 
95 #[==[
96 @ingroup module
97 @brief Find `vtk.module` files in a set of directories
98 
99 ~~~
100 vtk_module_find_modules(<output> [<directory>...])
101 ~~~
102 
103 This scans the given directories recursively for `vtk.module` files and put the
104 paths into the output variable. Note that module files are assumed to live next
105 to the `CMakeLists.txt` file which will build the module.
106 #]==]
107 function (vtk_module_find_modules output)
108  set(_vtk_find_modules_all)
109  foreach (_vtk_find_modules_directory IN LISTS ARGN)
110  file(GLOB_RECURSE _vtk_find_modules_modules
111  "${_vtk_find_modules_directory}/vtk.module")
112  list(APPEND _vtk_find_modules_all
113  ${_vtk_find_modules_modules})
114  endforeach ()
115  set("${output}" ${_vtk_find_modules_all} PARENT_SCOPE)
116 endfunction ()
117 
118 #[==[
119 @ingroup module-internal
120 @brief Split a module name into a namespace and target component
121 
122 Module names may include a namespace. This function splits the name into a
123 namespace and target name part.
124 
125 ~~~
126 _vtk_module_split_module_name(<name> <prefix>)
127 ~~~
128 
129 The `<prefix>_NAMESPACE` and `<prefix>_TARGET_NAME` variables will be set in
130 the calling scope.
131 #]==]
132 function (_vtk_module_split_module_name name prefix)
133  string(FIND "${name}" "::" namespace_pos)
134  if (namespace_pos EQUAL -1)
135  set(namespace "")
136  set(target_name "${name}")
137  else ()
138  string(SUBSTRING "${name}" 0 "${namespace_pos}" namespace)
139  math(EXPR name_pos "${namespace_pos} + 2")
140  string(SUBSTRING "${name}" "${name_pos}" -1 target_name)
141  endif ()
142 
143  set("${prefix}_NAMESPACE"
144  "${namespace}"
145  PARENT_SCOPE)
146  set("${prefix}_TARGET_NAME"
147  "${target_name}"
148  PARENT_SCOPE)
149 endfunction ()
150 
151 #[==[
152 @ingroup module
153 @page module-overview Module overview
154 
155 @section module-parse-module vtk.module file contents
156 
157 The `vtk.module` file is parsed and used as arguments to a CMake function which
158 stores information about the module for use when building it. Note that no
159 variable expansion is allowed and it is not CMake code, so no control flow is
160 allowed. Comments are supported and any content after a `#` on a line is
161 treated as a comment. Due to the breakdown of the content, quotes are not
162 meaningful within the files.
163 
164 Example:
165 
166 ~~~
167 NAME
168  VTK::CommonCore
169 LIBRARY_NAME
170  vtkCommonCore
171 DESCRIPTION
172  The base VTK library.
173 GROUPS
174  StandAlone
175 DEPENDS
176  VTK::kwiml
177 PRIVATE_DEPENDS
178  VTK::vtksys
179  VTK::utf8
180 ~~~
181 
182 All values are optional unless otherwise noted. The following arguments are
183 supported:
184 
185  * `NAME`: (Required) The name of the module.
186  * `LIBRARY_NAME`: The base name of the library file. It defaults to the
187  module name, but any namespaces are removed. For example, a `NS::Foo`
188  module will have a default `LIBRARY_NAME` of `Foo`.
189  * `DESCRIPTION`: (Recommended) Short text describing what the module is for.
190  * `KIT`: The name of the kit the module belongs to (see `Kits files` for more
191  information).
192  * `IMPLEMENTABLE`: If present, the module contains logic which supports the
193  autoinit functionality.
194  * `GROUPS`: Modules may belong to "groups" which is exposed as a build
195  option. This allows for enabling a set of modules with a single build
196  option.
197  * `CONDITION`: Arguments to CMake's `if` command which may be used to hide
198  the module for certain platforms or other reasons. If the expression is
199  false, the module is completely ignored.
200  * `DEPENDS`: A list of modules which are required by this module and modules
201  using this module.
202  * `PRIVATE_DEPENDS`: A list of modules which are required by this module, but
203  not by those using this module.
204  * `OPTIONAL_DEPENDS`: A list of modules which are used by this module if
205  enabled; these are treated as `PRIVATE_DEPENDS` if they exist.
206  * `ORDER_DEPENDS`: Dependencies which only matter for ordering. This does not
207  mean that the module will be enabled, just guaranteed to build before this
208  module.
209  * `IMPLEMENTS`: A list of modules for which this module needs to register
210  with.
211  * `TEST_DEPENDS`: Modules required by the test suite for this module.
212  * `TEST_OPTIONAL_DEPENDS`: Modules used by the test suite for this module if
213  available.
214  * `TEST_LABELS`: Labels to apply to the tests of this module. By default, the
215  module name is applied as a label.
216  * `EXCLUDE_WRAP`: If present, this module should not be wrapped in any
217  language.
218  * `THIRD_PARTY`: If present, this module is a third party module.
219 #]==]
220 
221 #[==[
222 @ingroup module-impl
223 @brief Parse `vtk.module` file contents
224 
225 This macro places all `vtk.module` keyword "arguments" into the caller's scope
226 prefixed with the value of `name_output` which is set to the `NAME` of the
227 module.
228 
229 ~~~
230 _vtk_module_parse_module_args(name_output <vtk.module args...>)
231 ~~~
232 
233 For example, this `vtk.module` file:
234 
235 ~~~
236 NAME
237  Namespace::Target
238 LIBRARY_NAME
239  nsTarget
240 ~~~
241 
242 called with `_vtk_module_parse_module_args(name ...)` will set the following
243 variables in the calling scope:
244 
245  - `name`: `Namespace::Target`
246  - `Namespace::Target_LIBRARY_NAME`: `nsTarget`
247 
248 With namespace support for module names, the variable should instead be
249 referenced via `${${name}_LIBRARY_NAME}` instead.
250 #]==]
251 macro (_vtk_module_parse_module_args name_output)
252  cmake_parse_arguments("_name"
253  ""
254  "NAME"
255  ""
256  ${ARGN})
257 
258  if (NOT _name_NAME)
259  message(FATAL_ERROR
260  "A VTK module requires a name (from ${_vtk_scan_module_file}).")
261  endif ()
262  set("${name_output}" "${_name_NAME}")
263 
264  cmake_parse_arguments("${_name_NAME}"
265  "IMPLEMENTABLE;EXCLUDE_WRAP;THIRD_PARTY"
266  "LIBRARY_NAME;NAME;KIT"
267  "GROUPS;DEPENDS;PRIVATE_DEPENDS;OPTIONAL_DEPENDS;ORDER_DEPENDS;TEST_DEPENDS;TEST_OPTIONAL_DEPENDS;TEST_LABELS;DESCRIPTION;CONDITION;IMPLEMENTS"
268  ${ARGN})
269 
270  if (${_name_NAME}_UNPARSED_ARGUMENTS)
271  message(FATAL_ERROR
272  "Unparsed arguments for ${_name_NAME}: "
273  "${${_name_NAME}_UNPARSED_ARGUMENTS}")
274  endif ()
275 
276  if (NOT ${_name_NAME}_DESCRIPTION AND _vtk_module_warnings)
277  message(WARNING "The ${_name_NAME} module should have a description")
278  endif ()
279  string(REPLACE ";" " " "${_name_NAME}_DESCRIPTION" "${${_name_NAME}_DESCRIPTION}")
280 
281  _vtk_module_split_module_name("${_name_NAME}" "${_name_NAME}")
282 
283  if (NOT DEFINED "${_name_NAME}_LIBRARY_NAME")
284  set("${_name_NAME}_LIBRARY_NAME" "${${_name_NAME}_TARGET_NAME}")
285  endif ()
286 
287  if (NOT ${_name_NAME}_LIBRARY_NAME)
288  message(FATAL_ERROR "The ${_name_NAME} module must have a non-empty `LIBRARY_NAME`.")
289  endif ()
290 
291  list(APPEND "${_name_NAME}_TEST_LABELS"
292  "${${_name_NAME}_NAME}"
293  "${${_name_NAME}_LIBRARY_NAME}")
294 endmacro ()
295 
296 #[==[
297 @page module-overview
298 
299 @section module-parse-kit vtk.kit file contents
300 
301 The `vtk.kit` file is parsed similarly to `vtk.module` files. Kits are intended
302 to bring together related modules into a single library in order to reduce the
303 number of objects that linkers need to deal with.
304 
305 Example:
306 
307 ~~~
308 NAME
309  VTK::Common
310 LIBRARY_NAME
311  vtkCommon
312 DESCRIPTION
313  Core utilities for VTK.
314 ~~~
315 
316 All values are optional unless otherwise noted. The following arguments are
317 supported:
318 
319  * `NAME`: (Required) The name of the kit.
320  * `LIBRARY_NAME`: The base name of the library file. It defaults to the
321  module name, but any namespaces are removed. For example, a `NS::Foo`
322  module will have a default `LIBRARY_NAME` of `Foo`.
323  * `DESCRIPTION`: (Recommended) Short text describing what the kit contains.
324 #]==]
325 
326 #[==[
327 @ingroup module-impl
328 @brief Parse `vtk.kit` file contents
329 
330 Just like @ref _vtk_module_parse_module_args, but for kits.
331 #]==]
332 macro (_vtk_module_parse_kit_args name_output)
333  cmake_parse_arguments("_name"
334  ""
335  "NAME"
336  ""
337  ${ARGN})
338 
339  if (NOT _name_NAME)
340  message(FATAL_ERROR
341  "A VTK kit requires a name (from ${_vtk_scan_kit_file}).")
342  endif ()
343  set("${name_output}" "${_name_NAME}")
344 
345  cmake_parse_arguments("${_name_NAME}"
346  ""
347  "NAME;LIBRARY_NAME"
348  "DESCRIPTION"
349  ${ARGN})
350 
351  if (${_name_NAME}_UNPARSED_ARGUMENTS)
352  message(FATAL_ERROR
353  "Unparsed arguments for ${_name_NAME}: "
354  "${${_name_NAME}_UNPARSED_ARGUMENTS}")
355  endif ()
356 
357  _vtk_module_split_module_name("${_name_NAME}" "${_name_NAME}")
358 
359  if (NOT DEFINED "${_name_NAME}_LIBRARY_NAME")
360  set("${_name_NAME}_LIBRARY_NAME" "${${_name_NAME}_TARGET_NAME}")
361  endif ()
362 
363  if (NOT ${_name_NAME}_LIBRARY_NAME)
364  message(FATAL_ERROR "The ${_name_NAME} module must have a non-empty `LIBRARY_NAME`.")
365  endif ()
366 
367  if (NOT ${_name_NAME}_DESCRIPTION AND _vtk_module_warnings)
368  message(WARNING "The ${_name_NAME} kit should have a description")
369  endif ()
370  string(REPLACE ";" " " "${_name_NAME}_DESCRIPTION" "${${_name_NAME}_DESCRIPTION}")
371 endmacro ()
372 
373 #[==[
374 @page module-overview
375 
376 @ingroup module
377 @section module-enable-status Enable status values
378 
379 Modules and groups are enable and disable preferences are specified using a
380 5-way flag setting:
381 
382  - `YES`: The module or group must be built.
383  - `NO`: The module or group must not be built.
384  - `WANT`: The module or group should be built if possible.
385  - `DONT_WANT`: The module or group should only be built if required (e.g.,
386  via a dependency).
387  - `DEFAULT`: Acts as either `WANT` or `DONT_WANT` based on the group settings
388  for the module or `WANT_BY_DEFAULT` option to @ref vtk_module_scan if no
389  other preference is specified. This is usually handled via another setting
390  in the main project.
391 
392 If a `YES` module preference requires a module with a `NO` preference, an error
393 is raised.
394 
395 A module with a setting of `DEFAULT` will look for its first non-`DEFAULT`
396 group setting and only if all of those are set to `DEFAULT` is the
397 `WANT_BY_DEFAULT` setting used.
398 #]==]
399 
400 #[==[
401 @ingroup module-impl
402 @brief Verify enable values
403 
404 Verifies that the variable named as the first parameter is a valid `enable
405 status` value.
406 
407 ~~~
408 _vtk_module_verify_enable_value(var)
409 ~~~
410 #]==]
411 function (_vtk_module_verify_enable_value var)
412  if (NOT (${var} STREQUAL "YES" OR
413  ${var} STREQUAL "WANT" OR
414  ${var} STREQUAL "DONT_WANT" OR
415  ${var} STREQUAL "NO" OR
416  ${var} STREQUAL "DEFAULT"))
417  message(FATAL_ERROR
418  "The `${var}` variable must be one of `YES`, `WANT`, `DONT_WANT`, `NO`, "
419  "or `DEFAULT`. Found `${${var}}`.")
420  endif ()
421 endfunction ()
422 
423 include("${CMAKE_CURRENT_LIST_DIR}/vtkTopologicalSort.cmake")
424 
425 #[==[
426 @ingroup module
427 @brief Scan modules and kits
428 
429 Once all of the modules and kits files have been found, they are "scanned" to
430 determine what modules are enabled or required.
431 
432 ~~~
433 vtk_module_scan(
434  MODULE_FILES <file>...
435  [KIT_FILES <file>...]
436  PROVIDES_MODULES <variable>
437  [PROVIDES_KITS <variable>]
438  [REQUIRES_MODULES <variable>]
439  [REQUEST_MODULES <module>...]
440  [REJECT_MODULES <module>...]
441  [UNRECOGNIZED_MODULES <variable>]
442  [WANT_BY_DEFAULT <ON|OFF>]
443  [HIDE_MODULES_FROM_CACHE <ON|OFF>]
444  [ENABLE_TESTS <ON|OFF|WANT|DEFAULT>])
445 ~~~
446 
447 The `MODULE_FILES` and `PROVIDES_MODULES` arguments are required. Modules which
448 refer to kits must be scanned at the same time as their kits. This is so that
449 modules may not add themselves to kits declared prior. The arguments are as follows:
450 
451  * `MODULE_FILES`: (Required) The list of module files to scan.
452  * `KIT_FILES`: The list of kit files to scan.
453  * `PROVIDES_MODULES`: (Required) This variable will contain the list of
454  modules which are enabled due to this scan.
455  * `PROVIDES_KITS`: (Required if `KIT_FILES` are provided) This variable will
456  contain the list of kits which are enabled due to this scan.
457  * `REQUIRES_MODULES`: This variable will contain the list of modules required
458  by the enabled modules that were not scanned.
459  * `REQUEST_MODULES`: The list of modules required by previous scans.
460  * `REJECT_MODULES`: The list of modules to exclude from the scan. If any of
461  these modules are required, an error will be raised.
462  * `UNRECOGNIZED_MODULES`: This variable will contain the list of requested
463  modules that were not scanned.
464  * `WANT_BY_DEFAULT`: (Defaults to `OFF`) Whether modules should default to
465  being built or not.
466  * `HIDE_MODULES_FROM_CACHE`: (Defaults to `OFF`) Whether or not to hide the
467  control variables from the cache or not. If enabled, modules will not be
468  built unless they are required elsewhere.
469  * `ENABLE_TESTS`: (Defaults to `WANT`) Whether or not modules required by
470  the tests for the scanned modules should be enabled or not.
471  - `ON`: Modules listed as `TEST_DEPENDS` will be required.
472  - `OFF`: Test modules will not be considered.
473  - `WANT`: Test dependencies will enable modules if possible.
474  - `DEFAULT`: Test modules will be enabled if their required dependencies
475  are satisfied and skipped otherwise.
476 
477 @section module-scanning-multiple Scanning multiple groups of modules
478 
479 When scanning complicated projects, multiple scans may be required to get
480 defaults set properly. The `REQUIRES_MODULES`, `REQUEST_MODULES`, and
481 `UNRECOGNIZED_MODULES` arguments are meant to deal with this case. As an
482 example, imagine a project with its source code, third party dependencies, as
483 well as some utility modules which should only be built as necessary. Here, the
484 project would perform three scans, one for each "grouping" of modules:
485 
486 ~~~{.cmake}
487 # Scan our modules first because we need to know what of the other groups we
488 # need.
489 vtk_module_find_modules(our_modules "${CMAKE_CURRENT_SOURCE_DIR}/src")
490 vtk_module_scan(
491  MODULE_FILES ${our_modules}
492  PROVIDES_MODULES our_enabled_modules
493  REQUIRES_MODULES required_modules)
494 
495 # Scan the third party modules, requesting only those that are necessary, but
496 # allowing them to be toggled during the build.
497 vtk_module_find_modules(third_party_modules "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
498 vtk_module_scan(
499  MODULE_FILES ${third_party_modules}
500  PROVIDES_MODULES third_party_enabled_modules
501  # These modules were requested by an earlier scan.
502  REQUEST_MODULES ${required_modules}
503  REQUIRES_MODULES required_modules
504  UNRECOGNIZED_MODULES unrecognized_modules)
505 
506 # These modules are internal and should only be built if necessary. There is no
507 # need to support them being enabled independently, so hide them from the
508 # cache.
509 vtk_module_find_modules(utility_modules "${CMAKE_CURRENT_SOURCE_DIR}/utilities")
510 vtk_module_scan(
511  MODULE_FILES ${utility_modules}
512  PROVIDES_MODULES utility_enabled_modules
513  # These modules were either requested or unrecognized by an earlier scan.
514  REQUEST_MODULES ${required_modules}
515  ${unrecognized_modules}
516  REQUIRES_MODULES required_modules
517  UNRECOGNIZED_MODULES unrecognized_modules
518  HIDE_MODULES_FROM_CACHE ON)
519 
520 if (required_modules OR unrecognized_modules)
521  # Not all of the modules we required were found. This should probably error out.
522 endif ()
523 ~~~
524 #]==]
525 function (vtk_module_scan)
526  cmake_parse_arguments(_vtk_scan
527  ""
528  "WANT_BY_DEFAULT;HIDE_MODULES_FROM_CACHE;PROVIDES_MODULES;REQUIRES_MODULES;UNRECOGNIZED_MODULES;ENABLE_TESTS;PROVIDES_KITS"
529  "MODULE_FILES;KIT_FILES;REQUEST_MODULES;REJECT_MODULES"
530  ${ARGN})
531 
532  if (_vtk_scan_UNPARSED_ARGUMENTS)
533  message(FATAL_ERROR
534  "Unparsed arguments for vtk_module_scan: "
535  "${_vtk_scan_UNPARSED_ARGUMENTS}")
536  endif ()
537 
538  if (NOT DEFINED _vtk_scan_WANT_BY_DEFAULT)
539  set(_vtk_scan_WANT_BY_DEFAULT OFF)
540  endif ()
541 
542  if (NOT DEFINED _vtk_scan_HIDE_MODULES_FROM_CACHE)
543  set(_vtk_scan_HIDE_MODULES_FROM_CACHE OFF)
544  endif ()
545 
546  if (NOT DEFINED _vtk_scan_PROVIDES_MODULES)
547  message(FATAL_ERROR
548  "The `PROVIDES_MODULES` argument is required.")
549  endif ()
550 
551  if (NOT DEFINED _vtk_scan_PROVIDES_KITS AND _vtk_scan_KIT_FILES)
552  message(FATAL_ERROR
553  "The `PROVIDES_KITS` argument is required.")
554  endif ()
555 
556  if (NOT DEFINED _vtk_scan_ENABLE_TESTS)
557  set(_vtk_scan_ENABLE_TESTS "WANT")
558  endif ()
559 
560  if (NOT (_vtk_scan_ENABLE_TESTS STREQUAL "ON" OR
561  _vtk_scan_ENABLE_TESTS STREQUAL "OFF" OR
562  _vtk_scan_ENABLE_TESTS STREQUAL "WANT" OR
563  _vtk_scan_ENABLE_TESTS STREQUAL "DEFAULT"))
564  message(FATAL_ERROR
565  "The `ENABLE_TESTS` argument must be one of `ON`, `OFF`, `WANT`, or "
566  "`DEFAULT`. " "Received `${_vtk_scan_ENABLE_TESTS}`.")
567  endif ()
568 
569  if (NOT _vtk_scan_MODULE_FILES)
570  message(FATAL_ERROR
571  "No module files given to scan.")
572  endif ()
573 
574  set(_vtk_scan_option_default_type STRING)
575  if (_vtk_scan_HIDE_MODULES_FROM_CACHE)
576  set(_vtk_scan_option_default_type INTERNAL)
577  endif ()
578 
579  set(_vtk_scan_all_kits)
580 
581  foreach (_vtk_scan_kit_file IN LISTS _vtk_scan_KIT_FILES)
582  if (NOT IS_ABSOLUTE "${_vtk_scan_kit_file}")
583  set(_vtk_scan_kit_file "${CMAKE_CURRENT_SOURCE_DIR}/${_vtk_scan_kit_file}")
584  endif ()
585  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND
586  PROPERTY
587  CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_kit_file}")
588 
589  file(READ "${_vtk_scan_kit_file}" _vtk_scan_kit_args)
590  # Replace comments.
591  string(REGEX REPLACE "#[^\n]*\n" "\n" _vtk_scan_kit_args "${_vtk_scan_kit_args}")
592  # Use argument splitting.
593  string(REGEX REPLACE "( |\n)+" ";" _vtk_scan_kit_args "${_vtk_scan_kit_args}")
594  _vtk_module_parse_kit_args(_vtk_scan_kit_name ${_vtk_scan_kit_args})
595  _vtk_module_debug(kit "@_vtk_scan_kit_name@ declared by @_vtk_scan_kit_file@")
596 
597  list(APPEND _vtk_scan_all_kits
598  "${_vtk_scan_kit_name}")
599 
600  # Set properties for building.
601  set_property(GLOBAL
602  PROPERTY
603  "_vtk_kit_${_vtk_scan_kit_name}_namespace" "${${_vtk_scan_kit_name}_NAMESPACE}")
604  set_property(GLOBAL
605  PROPERTY
606  "_vtk_kit_${_vtk_scan_kit_name}_target_name" "${${_vtk_scan_kit_name}_TARGET_NAME}")
607  set_property(GLOBAL
608  PROPERTY
609  "_vtk_kit_${_vtk_scan_kit_name}_library_name" "${${_vtk_scan_kit_name}_LIBRARY_NAME}")
610  endforeach ()
611 
612  set(_vtk_scan_all_modules)
613  set(_vtk_scan_all_groups)
614  set(_vtk_scan_rejected_modules)
615 
616  # Read all of the module files passed in.
617  foreach (_vtk_scan_module_file IN LISTS _vtk_scan_MODULE_FILES)
618  if (NOT IS_ABSOLUTE "${_vtk_scan_module_file}")
619  set(_vtk_scan_module_file "${CMAKE_CURRENT_SOURCE_DIR}/${_vtk_scan_module_file}")
620  endif ()
621  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND
622  PROPERTY
623  CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_module_file}")
624 
625  file(READ "${_vtk_scan_module_file}" _vtk_scan_module_args)
626  # Replace comments.
627  string(REGEX REPLACE "#[^\n]*\n" "\n" _vtk_scan_module_args "${_vtk_scan_module_args}")
628  # Use argument splitting.
629  string(REGEX REPLACE "( |\n)+" ";" _vtk_scan_module_args "${_vtk_scan_module_args}")
630  _vtk_module_parse_module_args(_vtk_scan_module_name ${_vtk_scan_module_args})
631  _vtk_module_debug(module "@_vtk_scan_module_name@ declared by @_vtk_scan_module_file@")
632  string(REPLACE "::" "_" _vtk_scan_module_name_safe "${_vtk_scan_module_name}")
633 
634  if (${_vtk_scan_module_name}_THIRD_PARTY)
635  if (_vtk_module_warnings)
636  if (${_vtk_scan_module_name}_EXCLUDE_WRAP)
637  message(WARNING
638  "The third party ${_vtk_scan_module_name} module does not need to "
639  "declare `EXCLUDE_WRAP` also.")
640  endif ()
641  endif ()
642  if (${_vtk_scan_module_name}_IMPLEMENTABLE)
643  message(FATAL_ERROR
644  "The third party ${_vtk_scan_module_name} module may not be "
645  "`IMPLEMENTABLE`.")
646  endif ()
647  if (${_vtk_scan_module_name}_IMPLEMENTS)
648  message(FATAL_ERROR
649  "The third party ${_vtk_scan_module_name} module may not "
650  "`IMPLEMENTS` another module.")
651  endif ()
652  if (${_vtk_scan_module_name}_KIT)
653  message(FATAL_ERROR
654  "The third party ${_vtk_scan_module_name} module may not be part of "
655  "a kit (${${_vtk_scan_module_name}_KIT}).")
656  endif ()
657  endif ()
658 
659  if (${_vtk_scan_module_name}_KIT)
660  if (NOT ${_vtk_scan_module_name}_KIT IN_LIST _vtk_scan_all_kits)
661  message(FATAL_ERROR
662  "The ${_vtk_scan_module_name} belongs to the "
663  "${${_vtk_scan_module_name}_KIT} kit, but it has not been scanned.")
664  endif ()
665  endif ()
666 
667  # Check if the module is visible. Modules which have a failing condition
668  # are basically invisible.
669  if (DEFINED ${_vtk_scan_module_name}_CONDITION)
670  if (NOT (${${_vtk_scan_module_name}_CONDITION}))
671  if (DEFINED "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}")
672  set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}"
673  PROPERTY
674  TYPE INTERNAL)
675  endif ()
676  _vtk_module_debug(module "@_vtk_scan_module_name@ hidden by its `CONDITION`")
677  continue ()
678  endif ()
679  endif ()
680 
681  # Determine whether we should provide a user-visible option for this
682  # module.
683  set(_vtk_build_use_option 1)
684  if (DEFINED _vtk_scan_REQUEST_MODULE)
685  if (_vtk_scan_module_name IN_LIST _vtk_scan_REQUEST_MODULE)
686  set("_vtk_scan_enable_${_vtk_scan_module_name}" YES)
687  set(_vtk_build_use_option 0)
688  endif ()
689  endif ()
690  if (DEFINED _vtk_scan_REJECT_MODULES)
691  if (_vtk_scan_module_name IN_LIST _vtk_scan_REJECT_MODULES)
692  if (NOT _vtk_build_use_option)
693  message(FATAL_ERROR
694  "The ${_vtk_scan_module_name} module has been requested and rejected.")
695  endif ()
696  # Rejected modules should not have a build option.
697  set(_vtk_build_use_option 0)
698  list(APPEND _vtk_scan_rejected_modules
699  "${_vtk_scan_module_name}")
700  endif ()
701  endif ()
702 
703  # Handle cache entries and determine the enabled state of the module from
704  # the relevant cache variables.
705  if (_vtk_build_use_option)
706  set("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}" "DEFAULT"
707  CACHE STRING "Enable the ${_vtk_scan_module_name} module. ${${_vtk_scan_module_name}_DESCRIPTION}")
708  mark_as_advanced("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}")
709  set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}"
710  PROPERTY
711  STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT")
712  _vtk_module_verify_enable_value("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}")
713 
714  if (NOT VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT")
715  set("_vtk_scan_enable_${_vtk_scan_module_name}" "${VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}}")
716  _vtk_module_debug(enable "@_vtk_scan_module_name@ is `${_vtk_scan_enable_${_vtk_scan_module_name}}` by cache value")
717  endif ()
718 
719  # Check the state of any groups the module belongs to.
720  foreach (_vtk_scan_group IN LISTS "${_vtk_scan_module_name}_GROUPS")
721  if (NOT DEFINED "VTK_GROUP_ENABLE_${_vtk_scan_group}")
722  set(_vtk_scan_group_default "DEFAULT")
723  if (DEFINED "_vtk_module_group_default_${_vtk_scan_group}")
724  set(_vtk_scan_group_default "${_vtk_module_group_default_${_vtk_scan_group}}")
725  endif ()
726  set("VTK_GROUP_ENABLE_${_vtk_scan_group}" "${_vtk_scan_group_default}"
727  CACHE STRING "Enable the ${_vtk_scan_group} group modules.")
728  set_property(CACHE "VTK_GROUP_ENABLE_${_vtk_scan_group}"
729  PROPERTY
730  STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT")
731  set_property(CACHE "VTK_GROUP_ENABLE_${_vtk_scan_group}"
732  PROPERTY
733  TYPE "${_vtk_scan_option_default_type}")
734  endif ()
735  _vtk_module_verify_enable_value("VTK_GROUP_ENABLE_${_vtk_scan_group}")
736 
737  if (NOT VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT")
738  continue ()
739  endif ()
740 
741  # Determine the state of the group.
742  set(_vtk_scan_group_enable "${VTK_GROUP_ENABLE_${_vtk_scan_group}}")
743  if (NOT _vtk_scan_group_enable STREQUAL "DEFAULT")
744  set("_vtk_scan_enable_${_vtk_scan_module_name}" "${_vtk_scan_group_enable}")
745  _vtk_module_debug(enable "@_vtk_scan_module_name@ is DEFAULT, using group `@_vtk_scan_group@` setting: @_vtk_scan_group_enable@")
746  endif ()
747  endforeach ()
748 
749  set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}"
750  PROPERTY
751  TYPE "${_vtk_scan_option_default_type}")
752  endif ()
753 
754  if (NOT DEFINED "_vtk_scan_enable_${_vtk_scan_module_name}" AND
755  VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT")
756  if (_vtk_scan_WANT_BY_DEFAULT)
757  set("_vtk_scan_enable_${_vtk_scan_module_name}" "WANT")
758  else ()
759  set("_vtk_scan_enable_${_vtk_scan_module_name}" "DONT_WANT")
760  endif ()
761  _vtk_module_debug(enable "@_vtk_scan_module_name@ is DEFAULT, using `WANT_BY_DEFAULT`: ${_vtk_scan_enable_${_vtk_scan_module_name}}")
762  endif ()
763 
764  list(APPEND _vtk_scan_all_modules
765  "${_vtk_scan_module_name}")
766  set("_vtk_scan_${_vtk_scan_module_name}_all_depends"
767  ${${_vtk_scan_module_name}_DEPENDS}
768  ${${_vtk_scan_module_name}_PRIVATE_DEPENDS})
769 
770  if (${_vtk_scan_module_name}_THIRD_PARTY)
771  set("${_vtk_scan_module_name}_EXCLUDE_WRAP" TRUE)
772  set("${_vtk_scan_module_name}_IMPLEMENTABLE" FALSE)
773  set("${_vtk_scan_module_name}_IMPLEMENTS")
774  endif ()
775 
776  if (${_vtk_scan_module_name}_KIT)
777  _vtk_module_debug(kit "@_vtk_scan_module_name@ belongs to the ${${_vtk_scan_module_name}_KIT} kit")
778  endif ()
779 
780  # Set properties for building.
781  set_property(GLOBAL
782  PROPERTY
783  "_vtk_module_${_vtk_scan_module_name}_file" "${_vtk_scan_module_file}")
784  set_property(GLOBAL
785  PROPERTY
786  "_vtk_module_${_vtk_scan_module_name}_namespace" "${${_vtk_scan_module_name}_NAMESPACE}")
787  set_property(GLOBAL
788  PROPERTY
789  "_vtk_module_${_vtk_scan_module_name}_target_name" "${${_vtk_scan_module_name}_TARGET_NAME}")
790  set_property(GLOBAL
791  PROPERTY
792  "_vtk_module_${_vtk_scan_module_name}_library_name" "${${_vtk_scan_module_name}_LIBRARY_NAME}")
793  set_property(GLOBAL
794  PROPERTY
795  "_vtk_module_${_vtk_scan_module_name}_third_party" "${${_vtk_scan_module_name}_THIRD_PARTY}")
796  set_property(GLOBAL
797  PROPERTY
798  "_vtk_module_${_vtk_scan_module_name}_exclude_wrap" "${${_vtk_scan_module_name}_EXCLUDE_WRAP}")
799  set_property(GLOBAL
800  PROPERTY
801  "_vtk_module_${_vtk_scan_module_name}_kit" "${${_vtk_scan_module_name}_KIT}")
802  set_property(GLOBAL
803  PROPERTY
804  "_vtk_module_${_vtk_scan_module_name}_depends" "${${_vtk_scan_module_name}_DEPENDS}")
805  set_property(GLOBAL
806  PROPERTY
807  "_vtk_module_${_vtk_scan_module_name}_order_depends" "${${_vtk_scan_module_name}_ORDER_DEPENDS}")
808  set_property(GLOBAL
809  PROPERTY
810  "_vtk_module_${_vtk_scan_module_name}_private_depends" "${${_vtk_scan_module_name}_PRIVATE_DEPENDS}")
811  set_property(GLOBAL
812  PROPERTY
813  "_vtk_module_${_vtk_scan_module_name}_optional_depends" "${${_vtk_scan_module_name}_OPTIONAL_DEPENDS}")
814  set_property(GLOBAL
815  PROPERTY
816  "_vtk_module_${_vtk_scan_module_name}_test_depends" "${${_vtk_scan_module_name}_TEST_DEPENDS}")
817  set_property(GLOBAL
818  PROPERTY
819  "_vtk_module_${_vtk_scan_module_name}_test_optional_depends" "${${_vtk_scan_module_name}_TEST_OPTIONAL_DEPENDS}")
820  set_property(GLOBAL
821  PROPERTY
822  "_vtk_module_${_vtk_scan_module_name}_test_labels" "${${_vtk_scan_module_name}_TEST_LABELS}")
823  set_property(GLOBAL
824  PROPERTY
825  "_vtk_module_${_vtk_scan_module_name}_implements" "${${_vtk_scan_module_name}_IMPLEMENTS}")
826  set_property(GLOBAL
827  PROPERTY
828  "_vtk_module_${_vtk_scan_module_name}_implementable" "${${_vtk_scan_module_name}_IMPLEMENTABLE}")
829  endforeach ()
830 
831  set(_vtk_scan_current_modules "${_vtk_scan_all_modules}")
832  vtk_topological_sort(_vtk_scan_all_modules "_vtk_scan_" "_all_depends")
833 
834  set(_vtk_scan_provided_modules)
835  set(_vtk_scan_required_modules)
836  set(_vtk_scan_disabled_modules)
837 
838  # Seed the `_vtk_scan_provide_` variables with modules requested and rejected
839  # as arguments.
840  foreach (_vtk_scan_request_module IN LISTS _vtk_scan_REQUEST_MODULES)
841  set("_vtk_scan_provide_${_vtk_scan_request_module}" ON)
842  _vtk_module_debug(provide "@_vtk_scan_request_module@ is provided via `REQUEST_MODULES`")
843  endforeach ()
844  foreach (_vtk_scan_reject_module IN LISTS _vtk_scan_REJECT_MODULES)
845  set("_vtk_scan_provide_${_vtk_scan_reject_module}" OFF)
846  _vtk_module_debug(provide "@_vtk_scan_reject_module@ is not provided via `REJECT_MODULES`")
847  endforeach ()
848 
849  # Traverse the graph classifying the quad-state for enabling modules into a
850  # boolean stored in the `_vtk_scan_provide_` variables.
851  foreach (_vtk_scan_module IN LISTS _vtk_scan_all_modules)
852  if (NOT _vtk_scan_module IN_LIST _vtk_scan_current_modules)
853  _vtk_module_debug(provide "@_vtk_scan_module@ is ignored because it is not in the current scan set")
854  continue ()
855  endif ()
856 
857  if (DEFINED "_vtk_scan_provide_${_vtk_scan_module}")
858  # Already done.
859  elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "YES")
860  # Mark enabled modules as to-be-provided. Any errors with requiring a
861  # disabled module will be dealt with later.
862  set("_vtk_scan_provide_${_vtk_scan_module}" ON)
863  _vtk_module_debug(provide "@_vtk_scan_module@ is provided due to `YES` setting")
864  elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "WANT")
865  # Check to see if we can provide this module by checking of any of its
866  # dependencies have been disabled.
867  set(_vtk_scan_test_depends)
868  if (NOT ${_vtk_scan_module}_THIRD_PARTY AND _vtk_scan_ENABLE_TESTS STREQUAL "ON")
869  # If the tests have to be on, we also need the test dependencies.
870  set(_vtk_scan_test_depends "${${_vtk_scan_module}_TEST_DEPENDS}")
871  endif ()
872 
873  set("_vtk_scan_provide_${_vtk_scan_module}" ON)
874  _vtk_module_debug(provide "@_vtk_scan_module@ is provided due to `WANT` setting")
875  foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS" "${_vtk_scan_module}_PRIVATE_DEPENDS" _vtk_scan_test_depends)
876  if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}" AND NOT _vtk_scan_provide_${_vtk_scan_module_depend})
877  set("_vtk_scan_provide_${_vtk_scan_module}" OFF)
878  _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to not provided dependency @_vtk_scan_module_depend@")
879  break ()
880  endif ()
881  endforeach ()
882  elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "DONT_WANT")
883  # Check for disabled dependencies and disable if so.
884  foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS" "${_vtk_scan_module}_PRIVATE_DEPENDS" _vtk_scan_test_depends)
885  if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}" AND NOT _vtk_scan_provide_${_vtk_scan_module_depend})
886  set("_vtk_scan_provide_${_vtk_scan_module}" OFF)
887  _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to not provided dependency @_vtk_scan_module_depend@")
888  break ()
889  endif ()
890  endforeach ()
891  elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "NO")
892  # Disable the module.
893  set("_vtk_scan_provide_${_vtk_scan_module}" OFF)
894  _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to `NO` setting")
895  endif ()
896 
897  # Collect disabled modules into a list.
898  if (DEFINED "_vtk_scan_provide_${_vtk_scan_module}" AND NOT _vtk_scan_provide_${_vtk_scan_module})
899  list(APPEND _vtk_scan_disabled_modules
900  "${_vtk_scan_module}")
901  endif ()
902 
903  if (NOT DEFINED "_vtk_scan_provide_${_vtk_scan_module}")
904  _vtk_module_debug(provide "@_vtk_scan_module@ is indeterminite (${_vtk_scan_enable_${_vtk_scan_module}})")
905  endif ()
906  endforeach ()
907 
908  # Scan all modules from the top of tree to the bottom.
909  list(REVERSE _vtk_scan_all_modules)
910  foreach (_vtk_scan_module IN LISTS _vtk_scan_all_modules)
911  if (NOT _vtk_scan_module IN_LIST _vtk_scan_current_modules)
912  continue ()
913  endif ()
914 
915  # If we're providing this module...
916  if (_vtk_scan_provide_${_vtk_scan_module})
917  list(APPEND _vtk_scan_provided_modules
918  "${_vtk_scan_module}")
919 
920  # Grab any test dependencies that are required.
921  set(_vtk_scan_test_depends)
922  set(_vtk_scan_test_wants)
923  if (NOT ${_vtk_scan_module}_THIRD_PARTY)
924  if (_vtk_scan_ENABLE_TESTS STREQUAL "ON")
925  set_property(GLOBAL APPEND
926  PROPERTY
927  "_vtk_module_test_modules" "${_vtk_scan_module}")
928  set(_vtk_scan_test_depends "${${_vtk_scan_module}_TEST_DEPENDS}")
929  elseif (_vtk_scan_ENABLE_TESTS STREQUAL "WANT")
930  set_property(GLOBAL APPEND
931  PROPERTY
932  "_vtk_module_test_modules" "${_vtk_scan_module}")
933  set(_vtk_scan_test_wants _vtk_scan_wants_marker ${${_vtk_scan_module}_TEST_DEPENDS})
934  elseif (_vtk_scan_ENABLE_TESTS STREQUAL "DEFAULT")
935  set_property(GLOBAL APPEND
936  PROPERTY
937  "_vtk_module_test_modules" "${_vtk_scan_module}")
938  elseif (_vtk_scan_ENABLE_TESTS STREQUAL "OFF")
939  # Nothing to do.
940  else ()
941  message(FATAL_ERROR
942  "Unrecognized option for ENABLE_TESTS: ${_vtk_module_ENABLE_TESTS}.")
943  endif ()
944  endif ()
945 
946  # Add all dependent modules to the list of required or provided modules.
947  set(_vtk_scan_is_wanting 0)
948  foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS" "${_vtk_scan_module}_PRIVATE_DEPENDS" _vtk_scan_test_depends _vtk_scan_test_wants)
949  if (_vtk_scan_module_depend STREQUAL "_vtk_scan_wants_marker")
950  set(_vtk_scan_is_wanting 1)
951  continue ()
952  endif ()
953  # Though we need to error if this would cause a disabled module to be
954  # provided.
955  if (_vtk_scan_module_depend IN_LIST _vtk_scan_disabled_modules)
956  if (_vtk_scan_is_wanting)
957  continue ()
958  else ()
959  message(FATAL_ERROR
960  "The ${_vtk_scan_module} module requires the disabled module ${_vtk_scan_module_depend}.")
961  endif ()
962  endif ()
963 
964  if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}")
965  if (NOT _vtk_scan_provide_${_vtk_scan_module_depend})
966  message(FATAL_ERROR
967  "The `${_vtk_scan_module_depend} should be provided, but is disabled.")
968  endif ()
969  continue ()
970  endif ()
971  set("_vtk_scan_provide_${_vtk_scan_module_depend}" ON)
972 
973  if (NOT _vtk_scan_module_depend IN_LIST _vtk_scan_current_modules)
974  if (NOT TARGET "${_vtk_scan_module_depend}")
975  _vtk_module_debug(provide "@_vtk_scan_module_depend@ is external and required due to dependency from @_vtk_scan_module@")
976  endif ()
977  list(APPEND _vtk_scan_required_modules
978  "${_vtk_scan_module_depend}")
979  else ()
980  _vtk_module_debug(provide "@_vtk_scan_module_depend@ is provided due to dependency from @_vtk_scan_module@")
981  list(APPEND _vtk_scan_provided_modules
982  "${_vtk_scan_module_depend}")
983  endif ()
984  endforeach ()
985  endif ()
986  endforeach ()
987 
988  if (_vtk_scan_provided_modules)
989  list(REMOVE_DUPLICATES _vtk_scan_provided_modules)
990  endif ()
991 
992  set(_vtk_scan_provided_kits)
993 
994  # Build a list of kits which contain the provided modules.
995  foreach (_vtk_scan_provided_module IN LISTS _vtk_scan_provided_modules)
996  if (${_vtk_scan_provided_module}_KIT)
997  list(APPEND _vtk_scan_provided_kits
998  "${${_vtk_scan_provided_module}_KIT}")
999  set_property(GLOBAL APPEND
1000  PROPERTY
1001  "_vtk_kit_${${_vtk_scan_provided_module}_KIT}_kit_modules" "${_vtk_scan_provided_module}")
1002  endif ()
1003  endforeach ()
1004 
1005  if (_vtk_scan_provided_kits)
1006  list(REMOVE_DUPLICATES _vtk_scan_provided_kits)
1007  endif ()
1008 
1009  if (_vtk_scan_required_modules)
1010  list(REMOVE_DUPLICATES _vtk_scan_required_modules)
1011  endif ()
1012 
1013  set(_vtk_scan_unrecognized_modules
1014  ${_vtk_scan_REQUEST_MODULES}
1015  ${_vtk_scan_REJECT_MODULES})
1016 
1017  if (_vtk_scan_unrecognized_modules AND (_vtk_scan_provided_modules OR _vtk_scan_rejected_modules))
1018  list(REMOVE_ITEM _vtk_scan_unrecognized_modules
1019  ${_vtk_scan_provided_modules}
1020  ${_vtk_scan_rejected_modules})
1021  endif ()
1022 
1023  set("${_vtk_scan_PROVIDES_MODULES}"
1024  ${_vtk_scan_provided_modules}
1025  PARENT_SCOPE)
1026 
1027  if (DEFINED _vtk_scan_REQUIRES_MODULES)
1028  set("${_vtk_scan_REQUIRES_MODULES}"
1029  ${_vtk_scan_required_modules}
1030  PARENT_SCOPE)
1031  endif ()
1032 
1033  if (DEFINED _vtk_scan_UNRECOGNIZED_MODULES)
1034  set("${_vtk_scan_UNRECOGNIZED_MODULES}"
1035  ${_vtk_scan_unrecognized_modules}
1036  PARENT_SCOPE)
1037  endif ()
1038 
1039  if (DEFINED _vtk_scan_PROVIDES_KITS)
1040  set("${_vtk_scan_PROVIDES_KITS}"
1041  ${_vtk_scan_provided_kits}
1042  PARENT_SCOPE)
1043  endif ()
1044 endfunction ()
1045 
1046 #[==[
1047 @page module-overview
1048 
1049 @section module-target-functions Module-as-target functions
1050 
1051 Due to the nature of VTK modules supporting being built as kits, the module
1052 name might not be usable as a target to CMake's `target_` family of commands.
1053 Instead, there are various wrappers around them which take the module name as
1054 an argument. These handle the forwarding of relevant information to the kit
1055 library as well where necessary.
1056 
1057  - @ref vtk_module_set_properties
1058  - @ref vtk_module_set_property
1059  - @ref vtk_module_get_property
1060  - @ref vtk_module_depend
1061  - @ref vtk_module_include
1062  - @ref vtk_module_definitions
1063  - @ref vtk_module_compile_options
1064  - @ref vtk_module_compile_features
1065  - @ref vtk_module_link
1066  - @ref vtk_module_link_options
1067 #]==]
1068 
1069 #[==[
1070 @page module-internal-api
1071 
1072 @section module-target-internals Module target internals
1073 
1074 When manipulating modules as targets, there are a few functions provided for
1075 use in wrapping code to more easily access them.
1076 
1077  - @ref _vtk_module_real_target
1078  - @ref _vtk_module_real_target_kit
1079 #]==]
1080 
1081 #[==[
1082 @ingroup module-internal
1083 @brief The real target for a module
1084 
1085 ~~~
1086 _vtk_module_real_target(<var> <module>)
1087 ~~~
1088 
1089 Sometimes the actual, core target for a module is required (e.g., setting
1090 CMake-level target properties or install rules). This function returns the real
1091 target for a module.
1092 #]==]
1093 function (_vtk_module_real_target var module)
1094  if (ARGN)
1095  message(FATAL_ERROR
1096  "Unparsed arguments for _vtk_module_real_target: ${ARGN}.")
1097  endif ()
1098 
1099  set(_vtk_real_target_res "")
1100  if (TARGET "${module}")
1101  get_property(_vtk_real_target_imported
1102  TARGET "${module}"
1103  PROPERTY IMPORTED)
1104  if (_vtk_real_target_imported)
1105  set(_vtk_real_target_res "${module}")
1106  endif ()
1107  endif ()
1108 
1109  if (NOT _vtk_real_target_res)
1110  get_property(_vtk_real_target_res GLOBAL
1111  PROPERTY "_vtk_module_${module}_target_name")
1112  # Querying during the build.
1113  if (DEFINED _vtk_build_BUILD_WITH_KITS AND _vtk_build_BUILD_WITH_KITS)
1114  get_property(_vtk_real_target_kit GLOBAL
1115  PROPERTY "_vtk_module_${module}_kit")
1116  if (_vtk_real_target_kit)
1117  set(_vtk_real_target_res "${_vtk_real_target_res}-objects")
1118  endif ()
1119  # A query for after the module is built.
1120  elseif (TARGET "${_vtk_real_target_res}-objects")
1121  set(_vtk_real_target_res "${_vtk_real_target_res}-objects")
1122  endif ()
1123  endif ()
1124 
1125  if (NOT _vtk_real_target_res)
1126  set(_vtk_real_target_msg "")
1127  if (NOT TARGET "${module}")
1128  if (DEFINED _vtk_build_module)
1129  set(_vtk_real_target_msg
1130  " Is a module dependency missing?")
1131  else ()
1132  set(_vtk_real_target_msg
1133  " Is a `find_package` missing a required component?")
1134  endif ()
1135  endif ()
1136  message(FATAL_ERROR
1137  "Failed to determine the real target for the `${module}` "
1138  "module.${_vtk_real_target_msg}")
1139  endif ()
1140 
1141  set("${var}"
1142  "${_vtk_real_target_res}"
1143  PARENT_SCOPE)
1144 endfunction ()
1145 
1146 #[==[
1147 @ingroup module-internal
1148 @brief The real target for a kit
1149 
1150 ~~~
1151 _vtk_module_real_target_kit(<var> <kit>)
1152 ~~~
1153 
1154 Sometimes the actual, core target for a module is required (e.g., setting
1155 CMake-level target properties or install rules). This function returns the real
1156 target for a kit.
1157 #]==]
1158 function (_vtk_module_real_target_kit var kit)
1159  if (ARGN)
1160  message(FATAL_ERROR
1161  "Unparsed arguments for _vtk_module_real_target_kit: ${ARGN}.")
1162  endif ()
1163 
1164  set(_vtk_real_target_res "")
1165  if (TARGET "${kit}")
1166  get_property(_vtk_real_target_imported
1167  TARGET "${kit}"
1168  PROPERTY IMPORTED)
1169  if (_vtk_real_target_imported)
1170  set(_vtk_real_target_res "${kit}")
1171  endif ()
1172  endif ()
1173 
1174  if (NOT _vtk_real_target_res)
1175  get_property(_vtk_real_target_res GLOBAL
1176  PROPERTY "_vtk_kit_${kit}_target_name")
1177  endif ()
1178 
1179  if (NOT _vtk_real_target_res)
1180  message(FATAL_ERROR
1181  "Failed to determine the real target for the `${kit}` kit.")
1182  endif ()
1183 
1184  set("${var}"
1185  "${_vtk_real_target_res}"
1186  PARENT_SCOPE)
1187 endfunction ()
1188 
1189 #[==[
1190 @ingroup module
1191 @brief Set multiple properties on a module
1192 
1193 A wrapper around `set_target_properties` that works for modules.
1194 
1195 ~~~
1196 vtk_module_set_properties(<module>
1197  [<property> <value>]...)
1198 ~~~
1199 #]==]
1200 function (vtk_module_set_properties module)
1201  _vtk_module_real_target(_vtk_set_properties_target "${module}")
1202 
1203  set_target_properties("${_vtk_set_properties_target}"
1204  PROPERTIES
1205  ${ARGN})
1206 endfunction ()
1207 
1208 #[==[
1209 @ingroup module
1210 @brief Set a property on a module
1211 
1212 A wrapper around `set_property(TARGET)` that works for modules.
1213 
1214 ~~~
1215 vtk_module_set_property(<module>
1216  [APPEND] [APPEND_STRING]
1217  PROPERTY <property>
1218  VALUE <value>...)
1219 ~~~
1220 #]==]
1221 function (vtk_module_set_property module)
1222  cmake_parse_arguments(_vtk_property
1223  "APPEND;APPEND_STRING"
1224  "PROPERTY"
1225  "VALUE"
1226  ${ARGN})
1227 
1228  if (_vtk_property_UNPARSED_ARGUMENTS)
1229  message(FATAL_ERROR
1230  "Unparsed arguments for vtk_module_set_property: "
1231  "${_vtk_property_UNPARSED_ARGUMENTS}.")
1232  endif ()
1233 
1234  if (NOT DEFINED _vtk_property_PROPERTY)
1235  message(FATAL_ERROR
1236  "The `PROPERTY` argument is required.")
1237  endif ()
1238 
1239  if (NOT DEFINED _vtk_property_VALUE)
1240  message(FATAL_ERROR
1241  "The `VALUE` argument is required.")
1242  endif ()
1243 
1244  if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1245  message(FATAL_ERROR
1246  "`APPEND` and `APPEND_STRING` may not be used at the same time.")
1247  endif ()
1248 
1249  set(_vtk_property_args)
1250  if (_vtk_property_APPEND)
1251  list(APPEND _vtk_property_args
1252  APPEND)
1253  endif ()
1254  if (_vtk_property_APPEND_STRING)
1255  list(APPEND _vtk_property_args
1256  APPEND_STRING)
1257  endif ()
1258 
1259  _vtk_module_real_target(_vtk_property_target "${module}")
1260 
1261  set_property(TARGET "${_vtk_property_target}"
1262  ${_vtk_property_args}
1263  PROPERTY
1264  "${_vtk_property_PROPERTY}" "${_vtk_property_VALUE}")
1265 endfunction ()
1266 
1267 #[==[
1268 @ingroup module
1269 @brief Get a property from a module
1270 
1271 A wrapper around `get_property(TARGET)` that works for modules.
1272 
1273 ~~~
1274 vtk_module_get_property(<module>
1275  PROPERTY <property>
1276  VARIABLE <variable>)
1277 ~~~
1278 
1279 The variable name passed to the `VARIABLE` argument will be unset if the
1280 property is not set (rather than the empty string).
1281 #]==]
1282 function (vtk_module_get_property module)
1283  cmake_parse_arguments(_vtk_property
1284  ""
1285  "PROPERTY;VARIABLE"
1286  ""
1287  ${ARGN})
1288 
1289  if (_vtk_property_UNPARSED_ARGUMENTS)
1290  message(FATAL_ERROR
1291  "Unparsed arguments for vtk_module_get_property: "
1292  "${_vtk_property_UNPARSED_ARGUMENTS}.")
1293  endif ()
1294 
1295  if (NOT DEFINED _vtk_property_PROPERTY)
1296  message(FATAL_ERROR
1297  "The `PROPERTY` argument is required.")
1298  endif ()
1299 
1300  if (NOT DEFINED _vtk_property_VARIABLE)
1301  message(FATAL_ERROR
1302  "The `VARIABLE` argument is required.")
1303  endif ()
1304 
1305  _vtk_module_real_target(_vtk_property_target "${module}")
1306 
1307  get_property(_vtk_property_is_set
1308  TARGET "${_vtk_property_target}"
1309  PROPERTY "${_vtk_property_PROPERTY}"
1310  SET)
1311  if (_vtk_property_is_set)
1312  get_property(_vtk_property_value
1313  TARGET "${_vtk_property_target}"
1314  PROPERTY "${_vtk_property_PROPERTY}")
1315 
1316  set("${_vtk_property_VARIABLE}"
1317  "${_vtk_property_value}"
1318  PARENT_SCOPE)
1319  else ()
1320  unset("${_vtk_property_VARIABLE}"
1321  PARENT_SCOPE)
1322  endif ()
1323 endfunction ()
1324 
1325 #[==[
1326 @ingroup module-impl
1327 @brief Generate arguments for target function wrappers
1328 
1329 Create the `INTERFACE`, `PUBLIC`, and `PRIVATE` arguments for a function
1330 wrapping CMake's `target_` functions to call the wrapped function.
1331 
1332 This is necessary because not all of the functions support empty lists given a
1333 keyword.
1334 #]==]
1335 function (_vtk_module_target_function prefix)
1336  foreach (visibility IN ITEMS INTERFACE PUBLIC PRIVATE)
1337  if (${prefix}_${visibility})
1338  set("${prefix}_${visibility}_args"
1339  "${visibility}"
1340  ${${prefix}_${visibility}}
1341  PARENT_SCOPE)
1342  endif ()
1343  endforeach ()
1344 endfunction ()
1345 
1346 #[==[
1347 @ingroup module
1348 @brief Add dependencies to a module
1349 
1350 A wrapper around `add_dependencies` that works for modules.
1351 
1352 ~~~
1353 vtk_module_depend(<module> <depend>...)
1354 ~~~
1355 #]==]
1356 function (vtk_module_depend module)
1357  _vtk_module_real_target(_vtk_depend_target "${module}")
1358 
1359  add_dependencies("${_vtk_depend_target}"
1360  ${ARGN})
1361 endfunction ()
1362 
1363 #[==[
1364 @ingroup module
1365 @brief Add include directories to a module
1366 
1367 A wrapper around `add_dependencies` that works for modules.
1368 
1369 ~~~
1370 vtk_module_include(<module>
1371  [SYSTEM]
1372  [PUBLIC <directory>...]
1373  [PRIVATE <directory>...]
1374  [INTERFACE <directory>...])
1375 ~~~
1376 #]==]
1377 function (vtk_module_include module)
1378  cmake_parse_arguments(_vtk_include
1379  "SYSTEM"
1380  ""
1381  "INTERFACE;PUBLIC;PRIVATE"
1382  ${ARGN})
1383 
1384  if (_vtk_include_UNPARSED_ARGUMENTS)
1385  message(FATAL_ERROR
1386  "Unparsed arguments for vtk_module_include: "
1387  "${_vtk_include_UNPARSED_ARGUMENTS}.")
1388  endif ()
1389 
1390  _vtk_module_real_target(_vtk_include_target "${module}")
1391  _vtk_module_target_function(_vtk_include)
1392 
1393  set(_vtk_include_system_arg)
1394  if (_vtk_include_SYSTEM)
1395  set(_vtk_include_system_arg SYSTEM)
1396  endif ()
1397 
1398  target_include_directories("${_vtk_include_target}"
1399  ${_vtk_include_system_arg}
1400  ${_vtk_include_INTERFACE_args}
1401  ${_vtk_include_PUBLIC_args}
1402  ${_vtk_include_PRIVATE_args})
1403 endfunction ()
1404 
1405 #[==[
1406 @ingroup module
1407 @brief Add compile definitions to a module
1408 
1409 A wrapper around `target_compile_definitions` that works for modules.
1410 
1411 ~~~
1412 vtk_module_definitions(<module>
1413  [PUBLIC <directory>...]
1414  [PRIVATE <directory>...]
1415  [INTERFACE <directory>...])
1416 ~~~
1417 #]==]
1418 function (vtk_module_definitions module)
1419  cmake_parse_arguments(_vtk_definitions
1420  ""
1421  ""
1422  "INTERFACE;PUBLIC;PRIVATE"
1423  ${ARGN})
1424 
1425  if (_vtk_definitions_UNPARSED_ARGUMENTS)
1426  message(FATAL_ERROR
1427  "Unparsed arguments for vtk_module_definitions: "
1428  "${_vtk_definitions_UNPARSED_ARGUMENTS}.")
1429  endif ()
1430 
1431  _vtk_module_real_target(_vtk_definitions_target "${module}")
1432  _vtk_module_target_function(_vtk_definitions)
1433 
1434  target_compile_definitions("${_vtk_definitions_target}"
1435  ${_vtk_definitions_INTERFACE_args}
1436  ${_vtk_definitions_PUBLIC_args}
1437  ${_vtk_definitions_PRIVATE_args})
1438 endfunction ()
1439 
1440 #[==[
1441 @ingroup module
1442 @brief Add compile options to a module
1443 
1444 A wrapper around `target_compile_options` that works for modules.
1445 
1446 ~~~
1447 vtk_module_compile_options(<module>
1448  [PUBLIC <directory>...]
1449  [PRIVATE <directory>...]
1450  [INTERFACE <directory>...])
1451 ~~~
1452 #]==]
1453 function (vtk_module_compile_options module)
1454  cmake_parse_arguments(_vtk_compile_options
1455  ""
1456  ""
1457  "INTERFACE;PUBLIC;PRIVATE"
1458  ${ARGN})
1459 
1460  if (_vtk_compile_options_UNPARSED_ARGUMENTS)
1461  message(FATAL_ERROR
1462  "Unparsed arguments for vtk_module_compile_options: "
1463  "${_vtk_compile_options_UNPARSED_ARGUMENTS}.")
1464  endif ()
1465 
1466  _vtk_module_real_target(_vtk_compile_options_target "${module}")
1467  _vtk_module_target_function(_vtk_compile_options)
1468 
1469  target_compile_options("${_vtk_compile_options_target}"
1470  ${_vtk_compile_options_INTERFACE_args}
1471  ${_vtk_compile_options_PUBLIC_args}
1472  ${_vtk_compile_options_PRIVATE_args})
1473 endfunction ()
1474 
1475 #[==[
1476 @ingroup module
1477 @brief Add compile features to a module
1478 
1479 A wrapper around `target_compile_features` that works for modules.
1480 
1481 ~~~
1482 vtk_module_compile_features(<module>
1483  [PUBLIC <directory>...]
1484  [PRIVATE <directory>...]
1485  [INTERFACE <directory>...])
1486 ~~~
1487 #]==]
1488 function (vtk_module_compile_features module)
1489  cmake_parse_arguments(_vtk_compile_features
1490  ""
1491  ""
1492  "INTERFACE;PUBLIC;PRIVATE"
1493  ${ARGN})
1494 
1495  if (_vtk_compile_features_UNPARSED_ARGUMENTS)
1496  message(FATAL_ERROR
1497  "Unparsed arguments for vtk_module_compile_features: "
1498  "${_vtk_compile_features_UNPARSED_ARGUMENTS}.")
1499  endif ()
1500 
1501  _vtk_module_real_target(_vtk_compile_features_target "${module}")
1502  _vtk_module_target_function(_vtk_compile_features)
1503 
1504  target_compile_features("${_vtk_compile_features_target}"
1505  ${_vtk_compile_features_INTERFACE_args}
1506  ${_vtk_compile_features_PUBLIC_args}
1507  ${_vtk_compile_features_PRIVATE_args})
1508 endfunction ()
1509 
1510 #[==[
1511 @ingroup module
1512 @brief Add link libraries to a module
1513 
1514 A wrapper around `target_link_libraries` that works for modules. Note that this
1515 function does extra work in kit builds, so circumventing it may break in kit
1516 builds.
1517 
1518 ~~~
1519 vtk_module_link(<module>
1520  [PUBLIC <directory>...]
1521  [PRIVATE <directory>...]
1522  [INTERFACE <directory>...])
1523 ~~~
1524 #]==]
1525 function (vtk_module_link module)
1526  cmake_parse_arguments(_vtk_link
1527  ""
1528  ""
1529  "INTERFACE;PUBLIC;PRIVATE"
1530  ${ARGN})
1531 
1532  if (_vtk_link_UNPARSED_ARGUMENTS)
1533  message(FATAL_ERROR
1534  "Unparsed arguments for vtk_module_link: "
1535  "${_vtk_link_UNPARSED_ARGUMENTS}.")
1536  endif ()
1537 
1538  _vtk_module_real_target(_vtk_link_target "${module}")
1539  _vtk_module_target_function(_vtk_link)
1540 
1541  get_property(_vtk_link_kit GLOBAL
1542  PROPERTY "_vtk_module_${module}_kit")
1543  if (_vtk_link_kit AND NOT CMAKE_VERSION VERSION_LESS "3.12")
1544  foreach (_vtk_link_private IN LISTS _vtk_link_PRIVATE)
1545  if (NOT TARGET "${_vtk_link_private}")
1546  continue ()
1547  endif ()
1548 
1549  get_property(_vtk_link_private_imported
1550  TARGET "${_vtk_link_private}"
1551  PROPERTY IMPORTED)
1552  if (_vtk_link_private_imported)
1553  get_property(_vtk_link_private_imported_global
1554  TARGET "${_vtk_link_private}"
1555  PROPERTY IMPORTED_GLOBAL)
1556  if (NOT _vtk_link_private_imported_global)
1557  set_property(TARGET "${_vtk_link_private}"
1558  PROPERTY
1559  IMPORTED_GLOBAL TRUE)
1560  endif ()
1561  endif ()
1562  endforeach ()
1563  set_property(GLOBAL APPEND
1564  PROPERTY
1565  "_vtk_kit_${_vtk_link_kit}_private_links" ${_vtk_link_PRIVATE})
1566  endif ()
1567 
1568  target_link_libraries("${_vtk_link_target}"
1569  ${_vtk_link_INTERFACE_args}
1570  ${_vtk_link_PUBLIC_args}
1571  ${_vtk_link_PRIVATE_args})
1572 endfunction ()
1573 
1574 #[==[
1575 @ingroup module
1576 @brief Add link options to a module
1577 
1578 A wrapper around `target_link_options` that works for modules.
1579 
1580 ~~~
1581 vtk_module_link_options(<module>
1582  [PUBLIC <directory>...]
1583  [PRIVATE <directory>...]
1584  [INTERFACE <directory>...])
1585 ~~~
1586 #]==]
1587 function (vtk_module_link_options module)
1588  cmake_parse_arguments(_vtk_link_options
1589  ""
1590  ""
1591  "INTERFACE;PUBLIC;PRIVATE"
1592  ${ARGN})
1593 
1594  if (_vtk_link_options_UNPARSED_ARGUMENTS)
1595  message(FATAL_ERROR
1596  "Unparsed arguments for vtk_module_link_options: "
1597  "${_vtk_link_options_UNPARSED_ARGUMENTS}.")
1598  endif ()
1599 
1600  _vtk_module_real_target(_vtk_link_options_target "${module}")
1601  _vtk_module_target_function(_vtk_link_options)
1602 
1603  target_link_options("${_vtk_link_options_target}"
1604  ${_vtk_link_options_INTERFACE_args}
1605  ${_vtk_link_options_PUBLIC_args}
1606  ${_vtk_link_options_PRIVATE_args})
1607 endfunction ()
1608 
1609 #[==[
1610 @page module-internal-api
1611 
1612 @ingroup module-internal
1613 @section module-properties Module properties
1614 
1615 The VTK module system leverages CMake's target propagation and storage. As
1616 such, there are a number of properties added to the targets representing
1617 modules. These properties are intended for use by the module system and
1618 associated functionality. In particular, more properties may be available by
1619 language wrappers.
1620 
1621 @subsection module-properties-naming Naming properties
1622 
1623 When creating properties for use with the module system, they should be
1624 prefixed with `INTERFACE_vtk_module_`. The `INTERFACE_` portion is required in
1625 order to work with interface libraries. The `vtk_module_` portion is to avoid
1626 colliding with any other properties. This function assumes this naming scheme
1627 for some of its convenience features as well.
1628 
1629 Properties should be the same in the local build as well as when imported to
1630 ease use.
1631 
1632 @subsection module-properties-system VTK module system properties
1633 
1634 There are a number of properties that are used and expected by the core of the
1635 module system. These are generally module metadata (module dependencies,
1636 whether to wrap or not, etc.). The properties all have the
1637 `INTERFACE_vtk_module_` prefix mentioned in the previous section.
1638 
1639  * `third_party`: If set, the module represents a third party
1640  dependency and should be treated specially. Third party modules are very
1641  restricted and generally do not have any other properties set on them.
1642  * `exclude_wrap`: If set, the module should not be wrapped by an external
1643  language.
1644  * `depends`: The list of dependent modules. Language wrappers will generally
1645  require this to satisfy references to parent classes of the classes in the
1646  module.
1647  * `private_depends`: The list of privately dependent modules. Language
1648  wrappers may require this to satisfy references to parent classes of the
1649  classes in the module.
1650  * `optional_depends`: The list of optionally dependent modules. Language
1651  wrappers may require this to satisfy references to parent classes of the
1652  classes in the module.
1653  * `kit`: The kit the module is a member of. Only set if the module is
1654  actually a member of the kit (i.e., the module was built with
1655  `BUILD_WITH_KITS ON`).
1656  * `implements`: The list of modules for which this module registers to. This
1657  is used by the autoinit subsystem and generally is not required.
1658  * `implementable`: If set, this module provides registries which may be
1659  populated by dependent modules. It is used to check the `implements`
1660  property to help minimize unnecessary work from the autoinit subsystem.
1661  * `needs_autoinit`: If set, linking to this module requires the autoinit
1662  subsystem to ensure that registries in modules are fully populated.
1663  * `headers`: Paths to the public headers from the module. These are the
1664  headers which should be handled by language wrappers.
1665  * `hierarchy`: The path to the hierarchy file describing inheritance of the
1666  classes for use in language wrappers.
1667  * `forward_link`: Usage requirements that must be forwarded even though the
1668  module is linked to privately.
1669 
1670 Kits have the following properties available (but only if kits are enabled):
1671 
1672  * `kit_modules`: Modules which are compiled into the kit.
1673 #]==]
1674 
1675 #[==[
1676 @ingroup module-internal
1677 @brief Set a module property
1678 
1679 This function sets a [module property](@ref module-properties) on a module. The
1680 required prefix will automatically be added to the passed name.
1681 
1682 ~~~
1683 _vtk_module_set_module_property(<module>
1684  [APPEND] [APPEND_STRING]
1685  PROPERTY <property>
1686  VALUE <value>...)
1687 ~~~
1688 #]==]
1689 function (_vtk_module_set_module_property module)
1690  cmake_parse_arguments(_vtk_property
1691  "APPEND;APPEND_STRING"
1692  "PROPERTY"
1693  "VALUE"
1694  ${ARGN})
1695 
1696  if (_vtk_property_UNPARSED_ARGUMENTS)
1697  message(FATAL_ERROR
1698  "Unparsed arguments for vtk_module_set_module_property: "
1699  "${_vtk_property_UNPARSED_ARGUMENTS}.")
1700  endif ()
1701 
1702  if (NOT DEFINED _vtk_property_PROPERTY)
1703  message(FATAL_ERROR
1704  "The `PROPERTY` argument is required.")
1705  endif ()
1706 
1707  if (NOT DEFINED _vtk_property_VALUE)
1708  message(FATAL_ERROR
1709  "The `VALUE` argument is required.")
1710  endif ()
1711 
1712  if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1713  message(FATAL_ERROR
1714  "`APPEND` and `APPEND_STRING` may not be used at the same time.")
1715  endif ()
1716 
1717  set(_vtk_property_args)
1718  if (_vtk_property_APPEND)
1719  list(APPEND _vtk_property_args
1720  APPEND)
1721  endif ()
1722  if (_vtk_property_APPEND_STRING)
1723  list(APPEND _vtk_property_args
1724  APPEND_STRING)
1725  endif ()
1726 
1727  get_property(_vtk_property_is_alias
1728  TARGET "${module}"
1729  PROPERTY ALIASED_TARGET
1730  SET)
1731  if (_vtk_property_is_alias)
1732  _vtk_module_real_target(_vtk_property_target "${module}")
1733  else ()
1734  set(_vtk_property_target "${module}")
1735  endif ()
1736 
1737  set_property(TARGET "${_vtk_property_target}"
1738  ${_vtk_property_args}
1739  PROPERTY
1740  "INTERFACE_vtk_module_${_vtk_property_PROPERTY}" "${_vtk_property_VALUE}")
1741 endfunction ()
1742 
1743 #[==[
1744 @ingroup module-internal
1745 @brief Get a module property
1746 
1747 Get a [module property](@ref module-properties) from a module.
1748 
1749 ~~~
1750 _vtk_module_get_module_property(<module>
1751  PROPERTY <property>
1752  VARIABLE <variable>)
1753 ~~~
1754 
1755 As with @ref vtk_module_get_property, the output variable will be unset if the
1756 property is not set. The property name is automatically prepended with the
1757 required prefix.
1758 #]==]
1759 function (_vtk_module_get_module_property module)
1760  cmake_parse_arguments(_vtk_property
1761  ""
1762  "PROPERTY;VARIABLE"
1763  ""
1764  ${ARGN})
1765 
1766  if (_vtk_property_UNPARSED_ARGUMENTS)
1767  message(FATAL_ERROR
1768  "Unparsed arguments for vtk_module_get_module_property: "
1769  "${_vtk_property_UNPARSED_ARGUMENTS}.")
1770  endif ()
1771 
1772  if (NOT DEFINED _vtk_property_PROPERTY)
1773  message(FATAL_ERROR
1774  "The `PROPERTY` argument is required.")
1775  endif ()
1776 
1777  if (NOT DEFINED _vtk_property_VARIABLE)
1778  message(FATAL_ERROR
1779  "The `VARIABLE` argument is required.")
1780  endif ()
1781 
1782  get_property(_vtk_property_is_alias
1783  TARGET "${module}"
1784  PROPERTY ALIASED_TARGET
1785  SET)
1786  if (_vtk_property_is_alias)
1787  _vtk_module_real_target(_vtk_property_target "${module}")
1788  else ()
1789  set(_vtk_property_target "${module}")
1790  endif ()
1791 
1792  get_property(_vtk_property_is_set
1793  TARGET "${_vtk_property_target}"
1794  PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}"
1795  SET)
1796  if (_vtk_property_is_set)
1797  get_property(_vtk_property_value
1798  TARGET "${_vtk_property_target}"
1799  PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}")
1800 
1801  set("${_vtk_property_VARIABLE}"
1802  "${_vtk_property_value}"
1803  PARENT_SCOPE)
1804  else ()
1805  unset("${_vtk_property_VARIABLE}"
1806  PARENT_SCOPE)
1807  endif ()
1808 endfunction ()
1809 
1810 #[==[
1811 @ingroup module-internal
1812 @brief Check that destinations are valid
1813 
1814 All installation destinations are expected to be relative so that
1815 `CMAKE_INSTALL_PREFIX` can be relied upon in all code paths. This function may
1816 be used to verify that destinations are relative.
1817 
1818 ~~~
1819 _vtk_module_check_destinations(<prefix> [<suffix>...])
1820 ~~~
1821 
1822 For each `suffix`, `prefix` is prefixed to it and the resulting variable name
1823 is checked for validity as an install prefix. Raises an error if any is
1824 invalid.
1825 #]==]
1826 function (_vtk_module_check_destinations prefix)
1827  foreach (suffix IN LISTS ARGN)
1828  if (IS_ABSOLUTE "${${prefix}${suffix}}")
1829  message(FATAL_ERROR
1830  "The `${suffix}` must not be an absolute path. Use "
1831  "`CMAKE_INSTALL_PREFIX` to keep everything in a single installation "
1832  "prefix.")
1833  endif ()
1834  endforeach ()
1835 endfunction ()
1836 
1837 #[==[
1838 @ingroup module-internal
1839 @brief Write an import prefix statement
1840 
1841 CMake files, once installed, may need to construct paths to other locations
1842 within the install prefix. This function writes a prefix computation for file
1843 given its install destination.
1844 
1845 ~~~
1846 _vtk_module_write_import_prefix(<file> <destination>)
1847 ~~~
1848 
1849 The passed file is cleared so that it occurs at the top of the file. The prefix
1850 is available in the file as the `_vtk_module_import_prefix` variable. It is
1851 recommended to unset the variable at the end of the file.
1852 #]==]
1853 function (_vtk_module_write_import_prefix file destination)
1854  if (IS_ABSOLUTE "${destination}")
1855  message(FATAL_ERROR
1856  "An import prefix cannot be determined from an absolute installation "
1857  "destination. Use `CMAKE_INSTALL_PREFIX` to keep everything in a single "
1858  "installation prefix.")
1859  endif ()
1860 
1861  file(WRITE "${file}"
1862  "set(_vtk_module_import_prefix \"\${CMAKE_CURRENT_LIST_DIR}\")\n")
1863  while (destination)
1864  get_filename_component(destination "${destination}" DIRECTORY)
1865  file(APPEND "${file}"
1866  "get_filename_component(_vtk_module_import_prefix \"\${_vtk_module_import_prefix}\" DIRECTORY)\n")
1867  endwhile ()
1868 endfunction ()
1869 
1870 #[==[
1871 @ingroup module-internal
1872 @brief Export properties on modules and targets
1873 
1874 This function is intended for use in support functions which leverage the
1875 module system, not by general system users. This function supports exporting
1876 properties from the build into dependencies via target properties which are
1877 loaded from a project's config file which is loaded via CMake's `find_package`
1878 function.
1879 
1880 ~~~
1882  [MODULE <module>]
1883  [KIT <kit>]
1884  BUILD_FILE <path>
1885  INSTALL_FILE <path>
1886  [PROPERTIES <property>...]
1887  [FROM_GLOBAL_PROPERTIES <property fragment>...]
1888  [SPLIT_INSTALL_PROPERTIES <property fragment>...])
1889 ~~~
1890 
1891 The `BUILD_FILE` and `INSTALL_FILE` arguments are required. Exactly one of
1892 `MODULE` and `KIT` is also required. The `MODULE` or `KIT` argument holds the
1893 name of the module or kit that will have properties exported. The `BUILD_FILE`
1894 and `INSTALL_FILE` paths are *appended to*. As such, when setting up these
1895 files, it should be preceded with:
1896 
1897 ~~~{.cmake}
1898 file(WRITE "${build_file}")
1899 file(WRITE "${install_file}")
1900 ~~~
1901 
1902 To avoid accidental usage of the install file from the build tree, it is
1903 recommended to store it under a `CMakeFiles/` directory in the build tree with
1904 an additional `.install` suffix and use `install(RENAME)` to rename it at
1905 install time.
1906 
1907 The set of properties exported is computed as follows:
1908 
1909  * `PROPERTIES` queries the module target for the given property and exports
1910  its value as-is to both the build and install files. In addition, these
1911  properties are set on the target directly as the same name.
1912  * `FROM_GLOBAL_PROPERTIES` queries the global
1913  `_vtk_module_<MODULE>_<fragment>` property and exports it to both the build
1914  and install files as `INTERFACE_vtk_module_<fragment>`.
1915  * `SPLIT_INSTALL_PROPERTIES` queries the target for
1916  `INTERFACE_vtk_module_<fragment>` and exports its value to the build file
1917  and `INTERFACE_vtk_module_<fragment>_install` to the install file as the
1918  non-install property name. This is generally useful for properties which
1919  change between the build and installation.
1920 #]==]
1922  cmake_parse_arguments(_vtk_export_properties
1923  ""
1924  "BUILD_FILE;INSTALL_FILE;MODULE;KIT"
1925  "FROM_GLOBAL_PROPERTIES;PROPERTIES;SPLIT_INSTALL_PROPERTIES"
1926  ${ARGN})
1927 
1928  if (_vtk_export_properties_UNPARSED_ARGUMENTS)
1929  message(FATAL_ERROR
1930  "Unparsed arguments for _vtk_export_properties: "
1931  "${_vtk_export_properties_UNPARSED_ARGUMENTS}.")
1932  endif ()
1933 
1934  if (DEFINED _vtk_export_properties_MODULE)
1935  if (DEFINED _vtk_export_properties_KIT)
1936  message(FATAL_ERROR
1937  "Only one of `MODULE` or `KIT` is required to export properties.")
1938  endif ()
1939  set(_vtk_export_properties_type "module")
1940  set(_vtk_export_properties_name "${_vtk_export_properties_MODULE}")
1941  elseif (_vtk_export_properties_KIT)
1942  set(_vtk_export_properties_type "kit")
1943  set(_vtk_export_properties_name "${_vtk_export_properties_KIT}")
1944  else ()
1945  message(FATAL_ERROR
1946  "A module or kit is required to export properties.")
1947  endif ()
1948 
1949  if (NOT _vtk_export_properties_BUILD_FILE)
1950  message(FATAL_ERROR
1951  "Exporting properties requires a build file to write to.")
1952  endif ()
1953 
1954  if (NOT _vtk_export_properties_INSTALL_FILE)
1955  message(FATAL_ERROR
1956  "Exporting properties requires an install file to write to.")
1957  endif ()
1958 
1959  if (_vtk_export_properties_type STREQUAL "module")
1960  _vtk_module_real_target(_vtk_export_properties_target_name "${_vtk_export_properties_name}")
1961  elseif (_vtk_export_properties_type STREQUAL "kit")
1962  _vtk_module_real_target_kit(_vtk_export_properties_target_name "${_vtk_export_properties_name}")
1963  endif ()
1964 
1965  foreach (_vtk_export_properties_global IN LISTS _vtk_export_properties_FROM_GLOBAL_PROPERTIES)
1966  get_property(_vtk_export_properties_is_set GLOBAL
1967  PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}"
1968  SET)
1969  if (NOT _vtk_export_properties_is_set)
1970  continue ()
1971  endif ()
1972 
1973  get_property(_vtk_export_properties_value GLOBAL
1974  PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}")
1975  set(_vtk_export_properties_set_property
1976  "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}\" \"${_vtk_export_properties_value}\")\n")
1977 
1978  set_property(TARGET "${_vtk_export_properties_target_name}"
1979  PROPERTY
1980  "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}" "${_vtk_export_properties_value}")
1981  file(APPEND "${_vtk_export_properties_BUILD_FILE}"
1982  "${_vtk_export_properties_set_property}")
1983  file(APPEND "${_vtk_export_properties_INSTALL_FILE}"
1984  "${_vtk_export_properties_set_property}")
1985  endforeach ()
1986 
1987  foreach (_vtk_export_properties_target IN LISTS _vtk_export_properties_PROPERTIES)
1988  get_property(_vtk_export_properties_is_set
1989  TARGET "${_vtk_export_properties_target_name}"
1990  PROPERTY "${_vtk_export_properties_target}"
1991  SET)
1992  if (NOT _vtk_export_properties_is_set)
1993  continue ()
1994  endif ()
1995 
1996  get_property(_vtk_export_properties_value
1997  TARGET "${_vtk_export_properties_target_name}"
1998  PROPERTY "${_vtk_export_properties_target}")
1999  set(_vtk_export_properties_set_property
2000  "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"${_vtk_export_properties_target}\" \"${_vtk_export_properties_value}\")\n")
2001 
2002  file(APPEND "${_vtk_export_properties_BUILD_FILE}"
2003  "${_vtk_export_properties_set_property}")
2004  file(APPEND "${_vtk_export_properties_INSTALL_FILE}"
2005  "${_vtk_export_properties_set_property}")
2006  endforeach ()
2007 
2008  foreach (_vtk_export_properties_split IN LISTS _vtk_export_properties_SPLIT_INSTALL_PROPERTIES)
2009  get_property(_vtk_export_properties_is_set
2010  TARGET "${_vtk_export_properties_target_name}"
2011  PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}"
2012  SET)
2013  if (NOT _vtk_export_properties_is_set)
2014  continue ()
2015  endif ()
2016 
2017  get_property(_vtk_export_properties_value
2018  TARGET "${_vtk_export_properties_target_name}"
2019  PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}")
2020  set(_vtk_export_properties_set_property
2021  "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2022  file(APPEND "${_vtk_export_properties_BUILD_FILE}"
2023  "${_vtk_export_properties_set_property}")
2024 
2025  get_property(_vtk_export_properties_value
2026  TARGET "${_vtk_export_properties_target_name}"
2027  PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}_install")
2028  set(_vtk_export_properties_set_property
2029  "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2030  file(APPEND "${_vtk_export_properties_INSTALL_FILE}"
2031  "${_vtk_export_properties_set_property}")
2032  endforeach ()
2033 endfunction ()
2034 
2035 include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleTesting.cmake")
2036 
2037 #[==[
2038 @ingroup module
2039 @brief Build modules and kits
2040 
2041 Once all of the modules have been scanned, they need to be built. Generally,
2042 there will be just one build necessary for a set of scans, though they may be
2043 built distinctly as well. If there are multiple calls to this function, they
2044 should generally in reverse order of their scans.
2045 
2046 ~~~
2047 vtk_module_build(
2048  MODULES <module>...
2049  [KITS <kit>...]
2050 
2051  [LIBRARY_NAME_SUFFIX <suffix>]
2052  [VERSION <version>]
2053  [SOVERSION <soversion>]
2054 
2055  [PACKAGE <package>]
2056 
2057  [BUILD_WITH_KITS <ON|OFF>]
2058 
2059  [ENABLE_WRAPPING <ON|OFF>]
2060 
2061  [USE_EXTERNAL <ON|OFF>]
2062 
2063  [INSTALL_HEADERS <ON|OFF>]
2064  [HEADERS_COMPONENT <component>]
2065 
2066  [TARGETS_COMPONENT <component>]
2067  [INSTALL_EXPORT <export>]
2068 
2069  [TEST_DIRECTORY_NAME <name>]
2070  [TEST_DATA_TARGET <target>]
2071  [TEST_INPUT_DATA_DIRECTORY <directory>]
2072  [TEST_OUTPUT_DATA_DIRECTORY <directory>]
2073  [TEST_OUTPUT_DIRECTORY <directory>]
2074 
2075  [ARCHIVE_DESTINATION <destination>]
2076  [HEADERS_DESTINATION <destination>]
2077  [LIBRARY_DESTINATION <destination>]
2078  [RUNTIME_DESTINATION <destination>]
2079  [CMAKE_DESTINATION <destination>]
2080  [LICENSE_DESTINATION <destination>]
2081  [HIERARCHY_DESTINATION <destination>])
2082 ~~~
2083 
2084 The only requirement of the function is the list of modules to build, the rest
2085 have reasonable defaults if not specified.
2086 
2087  * `MODULES`: (Required) The list of modules to build.
2088  * `KITS`: (Required if `BUILD_WITH_KITS` is `ON`) The list of kits to build.
2089  * `LIBRARY_NAME_SUFFIX`: (Defaults to `""`) A suffix to add to library names.
2090  If it is not empty, it is prefixed with `-` to separate it from the kit
2091  name.
2092  * `VERSION`: If specified, the `VERSION` property on built libraries will be
2093  set to this value.
2094  * `SOVERSION`: If specified, the `SOVERSION` property on built libraries will
2095  be set to this value.
2096  * `PACKAGE`: (Defaults to `${CMAKE_PROJECT_NAME}`) The name the build is
2097  meant to be found as when using `find_package`. Note that separate builds
2098  will require distinct `PACKAGE` values.
2099  * `BUILD_WITH_KITS`: (Defaults to `OFF`) If enabled, kit libraries will be
2100  built.
2101  * `ENABLE_WRAPPING`: (Default depends on the existence of
2102  `VTK::WrapHierarchy` or `VTKCompileTools::WrapHierarchy` targets) If
2103  enabled, wrapping will be available to the modules built in this call.
2104  * `USE_EXTERNAL`: (Defaults to `OFF`) Whether third party modules should find
2105  external copies rather than building their own copy.
2106  * `INSTALL_HEADERS`: (Defaults to `ON`) Whether or not to install public headers.
2107  * `HEADERS_COMPONENT`: (Defaults to `development`) The install component to
2108  use for header installation. Note that other SDK-related bits use the same
2109  component (e.g., CMake module files).
2110  * `TARGETS_COMPONENT`: `Defaults to `runtime`) The install component to use
2111  for the libraries built.
2112  * `TARGET_NAMESPACE`: `Defaults to `<AUTO>`) The namespace for installed
2113  targets. All targets must have the same namespace. If set to `<AUTO>`,
2114  the namespace will be detected automatically.
2115  * `INSTALL_EXPORT`: (Defaults to `""`) If non-empty, targets will be added to
2116  the given export. The export will also be installed as part of this build
2117  command.
2118  * `TEST_DIRECTORY_NAME`: (Defaults to `Testing`) The name of the testing
2119  directory to look for in each module. Set to `NONE` to disable automatic
2120  test management.
2121  * `TEST_DATA_TARGET`: (Defaults to `<PACKAGE>-data`) The target to add
2122  testing data download commands to.
2123  * `TEST_INPUT_DATA_DIRECTORY`: (Defaults to
2124  `${CMAKE_CURRENT_SOURCE_DIR}/Data`) The directory which will contain data
2125  for use by tests.
2126  * `TEST_OUTPUT_DATA_DIRECTORY`: (Defaults to
2127  `${CMAKE_CURRENT_BINARY_DIR}/Data`) The directory which will contain data
2128  for use by tests.
2129  * `TEST_OUTPUT_DIRECTORY`: (Defaults to
2130  `${CMAKE_BINARY_DIR}/<TEST_DIRECTORY_NAME>/Temporary`) The directory which
2131  tests may write any output files to.
2132 
2133 The remaining arguments control where to install files related to the build.
2134 See CMake documentation for the difference between `ARCHIVE`, `LIBRARY`, and
2135 `RUNTIME`.
2136 
2137  * `ARCHIVE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2138  destination for archive files.
2139  * `HEADERS_DESTINATION`: (Defaults to `${CMAKE_INSTALL_INCLUDEDIR}`) The
2140  install destination for header files.
2141  * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2142  destination for library files.
2143  * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) The install
2144  destination for runtime files.
2145  * `CMAKE_DESTINATION`: (Defaults to `<library destination>/cmake/<package>`)
2146  The install destination for CMake files.
2147  * `LICENSE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}`)
2148  The install destination for license files (relevant for third party
2149  packages).
2150  * `HIERARCHY_DESTINATION`: (Defaults to `<library
2151  destination>/vtk/hierarchy/<PACKAGE>`) The install destination
2152  for hierarchy files (used for language wrapping).
2153 #]==]
2154 function (vtk_module_build)
2155  set(_vtk_build_install_arguments
2156  # Headers
2157  INSTALL_HEADERS
2158  HEADERS_COMPONENT
2159 
2160  # Targets
2161  INSTALL_EXPORT
2162  TARGETS_COMPONENT
2163  TARGET_NAMESPACE
2164 
2165  # Destinations
2166  ARCHIVE_DESTINATION
2167  HEADERS_DESTINATION
2168  LIBRARY_DESTINATION
2169  RUNTIME_DESTINATION
2170  CMAKE_DESTINATION
2171  LICENSE_DESTINATION
2172  HIERARCHY_DESTINATION)
2173  set(_vtk_build_test_arguments
2174  # Testing
2175  TEST_DIRECTORY_NAME
2176  TEST_DATA_TARGET
2177  TEST_INPUT_DATA_DIRECTORY
2178  TEST_OUTPUT_DATA_DIRECTORY
2179  TEST_OUTPUT_DIRECTORY)
2180 
2181  # TODO: Add an option to build statically? Currently, `BUILD_SHARED_LIBS` is
2182  # used.
2183 
2184  cmake_parse_arguments(_vtk_build
2185  ""
2186  "BUILD_WITH_KITS;USE_EXTERNAL;LIBRARY_NAME_SUFFIX;VERSION;SOVERSION;PACKAGE;ENABLE_WRAPPING;${_vtk_build_install_arguments};${_vtk_build_test_arguments}"
2187  "MODULES;KITS"
2188  ${ARGN})
2189 
2190  if (_vtk_build_UNPARSED_ARGUMENTS)
2191  message(FATAL_ERROR
2192  "Unparsed arguments for vtk_module_build: "
2193  "${_vtk_build_UNPARSED_ARGUMENTS}")
2194  endif ()
2195 
2196  if (NOT DEFINED _vtk_build_USE_EXTERNAL)
2197  set(_vtk_build_USE_EXTERNAL OFF)
2198  endif ()
2199 
2200  if (NOT DEFINED _vtk_build_PACKAGE)
2201  set(_vtk_build_PACKAGE "${CMAKE_PROJECT_NAME}")
2202  endif ()
2203  get_property(_vtk_build_package_exists GLOBAL
2204  PROPERTY "_vtk_module_package_${_vtk_build_PACKAGE}"
2205  SET)
2206  if (_vtk_build_package_exists)
2207  message(FATAL_ERROR
2208  "A set of modules have already been built using the "
2209  "`${_vtk_build_PACKAGE}` package.")
2210  else ()
2211  set_property(GLOBAL
2212  PROPERTY
2213  "_vtk_module_package_${_vtk_build_PACKAGE}" "ON")
2214  endif ()
2215 
2216  if (NOT DEFINED _vtk_build_INSTALL_HEADERS)
2217  set(_vtk_build_INSTALL_HEADERS ON)
2218  endif ()
2219 
2220  if (NOT DEFINED _vtk_build_ENABLE_WRAPPING)
2221  if (TARGET "VTKCompileTools::WrapHierarchy" OR
2222  TARGET "VTK::WrapHierarchy")
2223  set(_vtk_build_ENABLE_WRAPPING ON)
2224  else ()
2225  set(_vtk_build_ENABLE_WRAPPING OFF)
2226  endif ()
2227  endif ()
2228 
2229  if (NOT DEFINED _vtk_build_TARGET_NAMESPACE)
2230  set(_vtk_build_TARGET_NAMESPACE "<AUTO>")
2231  endif ()
2232 
2233  if (NOT DEFINED _vtk_build_BUILD_WITH_KITS)
2234  set(_vtk_build_BUILD_WITH_KITS OFF)
2235  endif ()
2236 
2237  if (_vtk_build_BUILD_WITH_KITS AND CMAKE_VERSION VERSION_LESS "3.12")
2238  message(FATAL_ERROR
2239  "Building with kits enabled requires CMake 3.12 which introduced "
2240  "support for OBJECT libraries to have and utilize usage requirements.")
2241  endif ()
2242 
2243  if (_vtk_build_BUILD_WITH_KITS AND NOT DEFINED _vtk_build_KITS)
2244  message(FATAL_ERROR
2245  "Building with kits was requested, but no kits were specified.")
2246  endif ()
2247 
2248  if (NOT DEFINED _vtk_build_TEST_DIRECTORY_NAME)
2249  set(_vtk_build_TEST_DIRECTORY_NAME "Testing")
2250  endif ()
2251 
2252  if (NOT DEFINED _vtk_build_TEST_DATA_TARGET)
2253  set(_vtk_build_TEST_DATA_TARGET "${_vtk_build_PACKAGE}-data")
2254  endif ()
2255 
2256  if (NOT DEFINED _vtk_build_TEST_INPUT_DATA_DIRECTORY)
2257  set(_vtk_build_TEST_INPUT_DATA_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Data")
2258  endif ()
2259 
2260  if (NOT DEFINED _vtk_build_TEST_OUTPUT_DATA_DIRECTORY)
2261  set(_vtk_build_TEST_OUTPUT_DATA_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Data")
2262  endif ()
2263 
2264  if (NOT DEFINED _vtk_build_TEST_OUTPUT_DIRECTORY)
2265  set(_vtk_build_TEST_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_TEST_DIRECTORY_NAME}/Temporary")
2266  endif ()
2267 
2268  if (NOT DEFINED _vtk_build_HEADERS_COMPONENT)
2269  set(_vtk_build_HEADERS_COMPONENT "development")
2270  endif ()
2271 
2272  if (NOT DEFINED _vtk_build_ARCHIVE_DESTINATION)
2273  set(_vtk_build_ARCHIVE_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
2274  endif ()
2275 
2276  if (NOT DEFINED _vtk_build_HEADERS_DESTINATION)
2277  set(_vtk_build_HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
2278  endif ()
2279 
2280  if (NOT DEFINED _vtk_build_LIBRARY_DESTINATION)
2281  set(_vtk_build_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
2282  endif ()
2283 
2284  if (NOT DEFINED _vtk_build_RUNTIME_DESTINATION)
2285  set(_vtk_build_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}")
2286  endif ()
2287 
2288  if (NOT DEFINED _vtk_build_CMAKE_DESTINATION)
2289  set(_vtk_build_CMAKE_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/cmake/${_vtk_build_PACKAGE}")
2290  endif ()
2291 
2292  if (NOT DEFINED _vtk_build_LICENSE_DESTINATION)
2293  set(_vtk_build_LICENSE_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}")
2294  endif ()
2295 
2296  if (NOT DEFINED _vtk_build_HIERARCHY_DESTINATION)
2297  set(_vtk_build_HIERARCHY_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/vtk/hierarchy/${_vtk_build_PACKAGE}")
2298  endif ()
2299 
2300  if (NOT DEFINED _vtk_build_TARGETS_COMPONENT)
2301  set(_vtk_build_TARGETS_COMPONENT "runtime")
2302  endif ()
2303 
2304  if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
2305  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_ARCHIVE_DESTINATION}")
2306  endif ()
2307  if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
2308  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_LIBRARY_DESTINATION}")
2309  endif ()
2310  if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
2311  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_RUNTIME_DESTINATION}")
2312  endif ()
2313 
2314  if (NOT _vtk_build_MODULES)
2315  message(FATAL_ERROR
2316  "No modules given to build.")
2317  endif ()
2318 
2319  _vtk_module_check_destinations(_vtk_build_
2320  ARCHIVE_DESTINATION
2321  HEADERS_DESTINATION
2322  RUNTIME_DESTINATION
2323  CMAKE_DESTINATION
2324  LICENSE_DESTINATION
2325  HIERARCHY_DESTINATION)
2326 
2327  foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2328  get_property("_vtk_build_${_vtk_build_module}_depends" GLOBAL
2329  PROPERTY "_vtk_module_${_vtk_build_module}_depends")
2330  get_property("_vtk_build_${_vtk_build_module}_private_depends" GLOBAL
2331  PROPERTY "_vtk_module_${_vtk_build_module}_private_depends")
2332  get_property("_vtk_build_${_vtk_build_module}_optional_depends" GLOBAL
2333  PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
2334  get_property("_vtk_build_${_vtk_build_module}_order_depends" GLOBAL
2335  PROPERTY "_vtk_module_${_vtk_build_module}_order_depends")
2336  set("_vtk_build_${_vtk_build_module}_all_depends"
2337  ${_vtk_build_${_vtk_build_module}_depends}
2338  ${_vtk_build_${_vtk_build_module}_private_depends}
2339  ${_vtk_build_${_vtk_build_module}_optional_depends}
2340  ${_vtk_build_${_vtk_build_module}_order_depends})
2341  endforeach ()
2342 
2343  set(_vtk_build_sorted_modules "${_vtk_build_MODULES}")
2344  vtk_topological_sort(_vtk_build_sorted_modules "_vtk_build_" "_all_depends")
2345 
2346  foreach (_vtk_build_module IN LISTS _vtk_build_sorted_modules)
2347  if (NOT _vtk_build_module IN_LIST _vtk_build_MODULES)
2348  continue ()
2349  endif ()
2350 
2351  if (TARGET "${_vtk_build_module}")
2352  get_property(_vtk_build_is_imported
2353  TARGET "${_vtk_build_module}"
2354  PROPERTY IMPORTED)
2355 
2356  # TODO: Is this right?
2357  if (NOT _vtk_build_is_imported)
2358  message(FATAL_ERROR
2359  "The ${_vtk_build_module} module has been requested to be built, but "
2360  "it is already built by this project.")
2361  endif ()
2362 
2363  continue ()
2364  endif ()
2365 
2366  foreach (_vtk_build_depend IN LISTS "_vtk_build_${_vtk_build_module}_depends" "_vtk_build_${_vtk_build_module}_private_depends")
2367  if (NOT TARGET "${_vtk_build_depend}")
2368  message(FATAL_ERROR
2369  "The ${_vtk_build_depend} dependency is missing for ${_vtk_build_module}.")
2370  endif ()
2371  endforeach ()
2372 
2373  get_property(_vtk_build_module_file GLOBAL
2374  PROPERTY "_vtk_module_${_vtk_build_module}_file")
2375  if (NOT _vtk_build_module_file)
2376  message(FATAL_ERROR
2377  "The requested ${_vtk_build_module} module is not a VTK module.")
2378  endif ()
2379 
2380  _vtk_module_debug(building "@_vtk_build_module@ is being built")
2381 
2382  get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}" DIRECTORY)
2383  file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}" "${_vtk_build_module_dir}")
2384  add_subdirectory(
2385  "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}"
2386  "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}")
2387 
2388  if (NOT TARGET "${_vtk_build_module}")
2389  message(FATAL_ERROR
2390  "The ${_vtk_build_module} is being built, but a matching target was "
2391  "not created.")
2392  endif ()
2393  endforeach ()
2394 
2395  if (_vtk_build_BUILD_WITH_KITS)
2396  foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2397  get_property(_vtk_build_target_name GLOBAL
2398  PROPERTY "_vtk_kit_${_vtk_build_kit}_target_name")
2399  set(_vtk_kit_source_file
2400  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/vtk_module_kit_${_vtk_build_target_name}.c")
2401  file(GENERATE
2402  OUTPUT "${_vtk_kit_source_file}"
2403  CONTENT "void vtk_module_kit_${_vtk_build_target_name}() {}\n")
2404  add_library("${_vtk_build_target_name}"
2405  "${_vtk_kit_source_file}")
2406  get_property(_vtk_build_namespace GLOBAL
2407  PROPERTY "_vtk_kit_${_vtk_build_kit}_namespace")
2408  if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>")
2409  set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}")
2410  endif ()
2411  if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2412  message(FATAL_ERROR
2413  "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the "
2414  "same as the ${_vtk_build_kit} kit namespace "
2415  "(${_vtk_build_namespace}).")
2416  endif ()
2417  if (NOT _vtk_build_kit STREQUAL _vtk_build_target_name)
2418  add_library("${_vtk_build_kit}" ALIAS
2419  "${_vtk_build_target_name}")
2420  endif ()
2421  _vtk_module_apply_properties("${_vtk_build_target_name}")
2422  _vtk_module_install("${_vtk_build_target_name}")
2423 
2424  set(_vtk_build_kit_modules_object_libraries)
2425  set(_vtk_build_kit_modules_private_depends)
2426 
2427  get_property(_vtk_build_kit_modules GLOBAL
2428  PROPERTY "_vtk_kit_${_vtk_build_kit}_kit_modules")
2429  foreach (_vtk_build_kit_module IN LISTS _vtk_build_kit_modules)
2430  get_property(_vtk_build_kit_module_target_name GLOBAL
2431  PROPERTY "_vtk_module_${_vtk_build_kit_module}_target_name")
2432  list(APPEND _vtk_build_kit_modules_object_libraries
2433  "${_vtk_build_kit_module_target_name}-objects")
2434 
2435  # Since there is no link step for modules, we need to copy the private
2436  # dependencies of the constituent modules into the kit so that their
2437  # private dependencies are actually linked.
2438  get_property(_vtk_build_kit_module_private_depends GLOBAL
2439  PROPERTY "_vtk_module_${_vtk_build_kit_module}_private_depends")
2440  # Also grab optional dependencies since they end up being private
2441  # links.
2442  get_property(_vtk_build_kit_module_optional_depends GLOBAL
2443  PROPERTY "_vtk_module_${_vtk_build_kit_module}_optional_depends")
2444  foreach (_vtk_build_kit_module_private_depend IN LISTS _vtk_build_kit_module_private_depends _vtk_build_kit_module_optional_depends)
2445  if (NOT TARGET "${_vtk_build_kit_module_private_depend}")
2446  continue ()
2447  endif ()
2448 
2449  # But we don't need to link to modules that are part of the kit we are
2450  # building.
2451  if (NOT _vtk_build_kit_module_private_depend IN_LIST _vtk_build_kit_modules)
2452  list(APPEND _vtk_build_kit_modules_private_depends
2453  "$<LINK_ONLY:${_vtk_build_kit_module_private_depend}>")
2454  endif ()
2455  endforeach ()
2456  endforeach ()
2457 
2458  get_property(_vtk_build_kit_private_links GLOBAL
2459  PROPERTY "_vtk_kit_${_vtk_build_kit}_private_links")
2460 
2461  if (_vtk_build_kit_modules_private_depends)
2462  list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_depends)
2463  endif ()
2464  if (_vtk_build_kit_modules_private_links)
2465  list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_links)
2466  endif ()
2467 
2468  target_link_libraries("${_vtk_build_target_name}"
2469  PRIVATE
2470  ${_vtk_build_kit_modules_object_libraries}
2471  ${_vtk_build_kit_modules_private_depends}
2472  ${_vtk_build_kit_private_links})
2473  get_property(_vtk_build_kit_library_name GLOBAL
2474  PROPERTY "_vtk_kit_${_vtk_build_kit}_library_name")
2475  if (_vtk_build_LIBRARY_NAME_SUFFIX)
2476  string(APPEND _vtk_build_kit_library_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}")
2477  endif ()
2478  set_target_properties("${_vtk_build_target_name}"
2479  PROPERTIES
2480  OUTPUT_NAME "${_vtk_build_kit_library_name}")
2481  endforeach ()
2482  endif ()
2483 
2484  set(_vtk_build_properties_filename "${_vtk_build_PACKAGE}-vtk-module-properties.cmake")
2485  set(_vtk_build_properties_install_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_build_properties_filename}.install")
2486  set(_vtk_build_properties_build_file "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_properties_filename}")
2487 
2488  file(WRITE "${_vtk_build_properties_build_file}")
2489 
2490  _vtk_module_write_import_prefix(
2491  "${_vtk_build_properties_install_file}"
2492  "${_vtk_build_CMAKE_DESTINATION}")
2493 
2494  foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2495  get_property(_vtk_build_namespace GLOBAL
2496  PROPERTY "_vtk_module_${_vtk_build_module}_namespace")
2497  if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>")
2498  set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}")
2499  endif ()
2500  if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2501  message(FATAL_ERROR
2502  "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the "
2503  "same as the ${_vtk_build_module} module namespace "
2504  "(${_vtk_build_namespace}).")
2505  endif ()
2506 
2507  get_property(_vtk_build_is_third_party
2508  TARGET "${_vtk_build_module}"
2509  PROPERTY "INTERFACE_vtk_module_third_party")
2510  if (_vtk_build_is_third_party)
2511  _vtk_module_export_properties(
2512  BUILD_FILE "${_vtk_build_properties_build_file}"
2513  INSTALL_FILE "${_vtk_build_properties_install_file}"
2514  MODULE "${_vtk_build_module}"
2515  FROM_GLOBAL_PROPERTIES
2516  # Export the dependencies of a module.
2517  depends
2518  private_depends
2519  optional_depends
2520  # The library name of the module.
2521  library_name
2522  PROPERTIES
2523  # Export whether a module is third party or not.
2524  INTERFACE_vtk_module_third_party
2525  INTERFACE_vtk_module_exclude_wrap)
2526  continue ()
2527  endif ()
2528 
2529  set(_vtk_build_split_properties)
2530  get_property(_vtk_build_exclude_wrap
2531  TARGET "${_vtk_build_module}"
2532  PROPERTY "INTERFACE_vtk_module_${_vtk_build_module}_exclude_wrap")
2533  if (NOT _vtk_build_exclude_wrap)
2534  list(APPEND _vtk_build_split_properties
2535  headers)
2536  if (_vtk_build_ENABLE_WRAPPING)
2537  list(APPEND _vtk_build_split_properties
2538  hierarchy)
2539  endif ()
2540  endif ()
2541 
2542  set(_vtk_build_properties_kit_properties)
2543  if (_vtk_build_BUILD_WITH_KITS)
2544  list(APPEND _vtk_build_properties_kit_properties
2545  # Export the kit membership of a module.
2546  kit)
2547  endif ()
2548 
2549  _vtk_module_export_properties(
2550  BUILD_FILE "${_vtk_build_properties_build_file}"
2551  INSTALL_FILE "${_vtk_build_properties_install_file}"
2552  MODULE "${_vtk_build_module}"
2553  FROM_GLOBAL_PROPERTIES
2554  # Export whether the module should be excluded from wrapping or not.
2555  exclude_wrap
2556  # Export the dependencies of a module.
2557  depends
2558  private_depends
2559  optional_depends
2560  # Export what modules are implemented by the module.
2561  implements
2562  # Export whether the module contains autoinit logic.
2563  implementable
2564  # The library name of the module.
2565  library_name
2566  ${_vtk_build_properties_kit_properties}
2567  PROPERTIES
2568  # Export whether the module needs autoinit logic handled.
2569  INTERFACE_vtk_module_needs_autoinit
2570  # Forward private usage requirements with global effects.
2571  INTERFACE_vtk_module_forward_link
2572  SPLIT_INSTALL_PROPERTIES
2573  # Set the properties which differ between build and install trees.
2574  ${_vtk_build_split_properties})
2575  endforeach ()
2576 
2577  if (_vtk_build_BUILD_WITH_KITS)
2578  foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2579  _vtk_module_export_properties(
2580  BUILD_FILE "${_vtk_build_properties_build_file}"
2581  INSTALL_FILE "${_vtk_build_properties_install_file}"
2582  KIT "${_vtk_build_kit}"
2583  FROM_GLOBAL_PROPERTIES
2584  # Export the list of modules in the kit.
2585  kit_modules)
2586  endforeach ()
2587  endif ()
2588 
2589  if (_vtk_build_INSTALL_EXPORT AND _vtk_build_INSTALL_HEADERS)
2590  set(_vtk_build_namespace)
2591  if (_vtk_build_TARGET_NAMESPACE)
2592  set(_vtk_build_namespace
2593  NAMESPACE "${_vtk_build_TARGET_NAMESPACE}::")
2594  endif ()
2595 
2596  export(
2597  EXPORT "${_vtk_build_INSTALL_EXPORT}"
2598  ${_vtk_build_namespace}
2599  FILE "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_PACKAGE}-targets.cmake")
2600  install(
2601  EXPORT "${_vtk_build_INSTALL_EXPORT}"
2602  DESTINATION "${_vtk_build_CMAKE_DESTINATION}"
2603  ${_vtk_build_namespace}
2604  FILE "${_vtk_build_PACKAGE}-targets.cmake"
2605  COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
2606 
2607  if (_vtk_build_INSTALL_HEADERS)
2608  file(APPEND "${_vtk_build_properties_install_file}"
2609  "unset(_vtk_module_import_prefix)\n")
2610 
2611  install(
2612  FILES "${_vtk_build_properties_install_file}"
2613  DESTINATION "${_vtk_build_CMAKE_DESTINATION}"
2614  RENAME "${_vtk_build_properties_filename}"
2615  COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
2616  endif ()
2617  endif ()
2618 
2619  get_property(_vtk_build_test_modules GLOBAL
2620  PROPERTY "_vtk_module_test_modules")
2621  set(_vtk_build_tests_handled)
2622  foreach (_vtk_build_test IN LISTS _vtk_build_test_modules)
2623  if (NOT _vtk_build_test IN_LIST _vtk_build_MODULES)
2624  continue ()
2625  endif ()
2626  list(APPEND _vtk_build_tests_handled
2627  "${_vtk_build_test}")
2628 
2629  get_property(_vtk_build_test_depends GLOBAL
2630  PROPERTY "_vtk_module_${_vtk_build_test}_test_depends")
2631 
2632  set(_vtk_build_test_has_depends TRUE)
2633  foreach (_vtk_build_test_depend IN LISTS _vtk_build_test_depends)
2634  if (NOT TARGET "${_vtk_build_test_depend}")
2635  set(_vtk_build_test_has_depends FALSE)
2636  _vtk_module_debug(testing "@_vtk_build_test@ testing disabled due to missing @_vtk_build_test_depend@")
2637  endif ()
2638  endforeach ()
2639  if (NOT _vtk_build_test_has_depends)
2640  continue ()
2641  endif ()
2642 
2643  get_property(_vtk_build_module_file GLOBAL
2644  PROPERTY "_vtk_module_${_vtk_build_test}_file")
2645 
2646  if (NOT _vtk_build_TEST_DIRECTORY_NAME STREQUAL "NONE")
2647  get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}" DIRECTORY)
2648  file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}" "${_vtk_build_module_dir}")
2649  if (EXISTS "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}")
2650  get_property(_vtk_build_test_labels GLOBAL
2651  PROPERTY "_vtk_module_${_vtk_build_test}_test_labels")
2652  add_subdirectory(
2653  "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}"
2654  "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}")
2655  endif ()
2656  endif ()
2657  endforeach ()
2658 
2659  if (_vtk_build_test_modules AND _vtk_build_tests_handled)
2660  list(REMOVE_ITEM _vtk_build_test_modules
2661  ${_vtk_build_tests_handled})
2662  set_property(GLOBAL
2663  PROPERTY
2664  _vtk_module_test_modules "${_vtk_build_test_modules}")
2665  endif ()
2666 endfunction ()
2667 
2668 #[==[
2669 @ingroup module-impl
2670 @brief Add "standard" include directories to a module
2671 
2672 Add the "standard" includes for a module to its interface. These are the source
2673 and build directories for the module itself. They are always either `PUBLIC` or
2674 `INTERFACE` (depending on the module's target type).
2675 
2676 ~~~
2677 _vtk_module_standard_includes(
2678  [SYSTEM]
2679  [INTERFACE]
2680  TARGET <target>
2681  [HEADERS_DESTINATION <destination>])
2682 ~~~
2683 #]==]
2684 function (_vtk_module_standard_includes)
2685  cmake_parse_arguments(_vtk_standard_includes
2686  "SYSTEM;INTERFACE"
2687  "TARGET;HEADERS_DESTINATION"
2688  ""
2689  ${ARGN})
2690 
2691  if (NOT _vtk_standard_includes_TARGET)
2692  message(FATAL_ERROR
2693  "The `TARGET` argument is required.")
2694  endif ()
2695  if (NOT TARGET "${_vtk_standard_includes_TARGET}")
2696  message(FATAL_ERROR
2697  "The `TARGET` argument is not a target.")
2698  endif ()
2699 
2700  if (_vtk_standard_includes_UNPARSED_ARGUMENTS)
2701  message(FATAL_ERROR
2702  "Unparsed arguments for vtk_module_standard_includes: "
2703  "${_vtk_standard_includes_UNPARSED_ARGUMENTS}")
2704  endif ()
2705 
2706  set(_vtk_standard_includes_system)
2707  if (_vtk_standard_includes_SYSTEM)
2708  set(_vtk_standard_includes_system SYSTEM)
2709  endif ()
2710 
2711  set(_vtk_standard_includes_visibility PUBLIC)
2712  if (_vtk_standard_includes_INTERFACE)
2713  set(_vtk_standard_includes_visibility INTERFACE)
2714  endif ()
2715 
2716  target_include_directories("${_vtk_standard_includes_TARGET}"
2717  ${_vtk_standard_includes_system}
2718  "${_vtk_standard_includes_visibility}"
2719  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
2720  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
2721 
2722  if (_vtk_build_INSTALL_HEADERS AND _vtk_standard_includes_HEADERS_DESTINATION)
2723  target_include_directories("${_vtk_standard_includes_TARGET}"
2724  ${_vtk_standard_includes_system}
2725  "${_vtk_standard_includes_visibility}"
2726  $<INSTALL_INTERFACE:${_vtk_standard_includes_HEADERS_DESTINATION}>)
2727  endif ()
2728 endfunction ()
2729 
2730 #[==[
2731 @ingroup module-impl
2732 @brief Determine the default export macro for a module
2733 
2734 Determines the export macro to be used for a module from its metadata. Assumes
2735 it is called from within a @ref vtk_module_build call.
2736 
2737 ~~~
2738 _vtk_module_default_library_name(<varname>)
2739 ~~~
2740 #]==]
2741 function (_vtk_module_default_export_macro_prefix varname)
2742  get_property(_vtk_module_default_library_name GLOBAL
2743  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
2744  string(TOUPPER "${_vtk_module_default_library_name}" _vtk_default_export_macro_upper)
2745  set("${varname}"
2746  "${_vtk_default_export_macro_upper}"
2747  PARENT_SCOPE)
2748 endfunction ()
2749 
2750 # TODO: It would be nice to support `USE_LINK_PROPERTIES` instead of listing
2751 # the modules again here. However, the format of the `LINK_LIBRARIES` property
2752 # value may not be easy to handle.
2753 
2754 #[==[
2755 @page module-overview
2756 
2757 @ingroup module
2758 @section module-autoinit Autoinit
2759 
2760 When a module contains a factory which may be populated by other modules, these
2761 factories need to be populated when the modules are loaded by the dynamic linker
2762 (for shared builds) or program load time (for static builds). To provide for
2763 this, the module system contains an autoinit "subsystem".
2764 
2765 @subsection module-autoinit-leverage Leveraging the autoinit subsystem
2766 
2767 The subsystem provides the following hooks for use by projects:
2768 
2769  * In modules which `IMPLEMENTS` other modules, in the generated
2770  `<module>Module.h` header (which provides export symbols as well) will
2771  include the modules which are implemented.
2772  * In modules which are `IMPLEMENTABLE` or `IMPLEMENTS` another module, the
2773  generated `<module>Module.h` file will include the following block:
2774 
2775 ~~~{.c}
2776 #ifdef <module>_AUTOINIT_INCLUDE
2777 #include <module>_AUTOINIT_INCLUDE
2778 #endif
2779 #ifdef <module>_AUTOINIT
2780 #include <header>
2781 VTK_MODULE_AUTOINIT(<module>)
2782 #endif
2783 ~~~
2784 
2785 The @ref vtk_module_autoinit function will generate an include file and provide
2786 its path via the `<module>_AUTOINIT_INCLUDE` define. once it has been included,
2787 if the `<module>_AUTOINIT` symbol is defined, a header is included which is
2788 intended to provide the `VTK_MODULE_AUTOINIT` macro. This macro is given the
2789 module name and should use `<module>_AUTOINIT` to fill in the factories in the
2790 module with those from the `IMPLEMENTS` modules listed in that symbol.
2791 
2792 The `<module>_AUTOINIT` symbol's value is:
2793 
2794 ~~~
2795 <count>(<module1>,<module2>,<module3>)
2796 ~~~
2797 
2798 where `<count>` is the number of modules in the parentheses and each module
2799 listed need to register something to `<module>`.
2800 
2801 If not provided via the `AUTOINIT_INCLUDE` argument to the
2802 @ref vtk_module_add_module function, the header to use is fetched from the
2803 `_vtk_module_autoinit_include` global property. This only needs to be managed
2804 in modules that `IMPLEMENTS` or are `IMPLEMENTABLE`. This should be provided by
2805 projects using the module system at its lowest level. Projects not implementing
2806 the `VTK_MODULE_AUTOINIT` macro should have its value provided by
2807 `find_package` dependencies in some way.
2808 #]==]
2809 
2810 #[==[
2811 @ingroup module
2812 @brief Linking to autoinit-using modules
2813 
2814 When linking to modules, in order for the autoinit system to work, modules need
2815 to declare their registration. In order to do this, defines may need to be
2816 provided to targets in order to trigger registration. These defines may be
2817 added to targets by using this function.
2818 
2819 ~~~
2820 vtk_module_autoinit(
2821  TARGETS <target>...
2822  MODULES <module>...)
2823 ~~~
2824 
2825 After this call, the targets given to the `TARGETS` argument will gain the
2826 preprocessor definitions to trigger registrations properly.
2827 #]==]
2828 function (vtk_module_autoinit)
2829  cmake_parse_arguments(_vtk_autoinit
2830  ""
2831  ""
2832  "TARGETS;MODULES"
2833  ${ARGN})
2834 
2835  if (_vtk_autoinit_UNRECOGNIZED_ARGUMENTS)
2836  message(FATAL_ERROR
2837  "Unparsed arguments for vtk_module_autoinit: "
2838  "${_vtk_autoinit_UNRECOGNIZED_ARGUMENTS}.")
2839  endif ()
2840 
2841  if (NOT _vtk_autoinit_TARGETS)
2842  message(FATAL_ERROR
2843  "The `TARGETS` argument is required.")
2844  endif ()
2845 
2846  if (NOT _vtk_autoinit_MODULES)
2847  message(AUTHOR_WARNING
2848  "No `MODULES` passed to `vtk_modules_autoinit`.")
2849  endif ()
2850 
2851  set(_vtk_autoinit_module_stack
2852  ${_vtk_autoinit_MODULES})
2853 
2854  set(_vtk_autoinit_needs_implements)
2855  set(_vtk_autoinit_seen)
2856  while (_vtk_autoinit_module_stack)
2857  list(GET _vtk_autoinit_module_stack 0 _vtk_autoinit_current_module)
2858  list(REMOVE_AT _vtk_autoinit_module_stack 0)
2859  if (_vtk_autoinit_current_module IN_LIST _vtk_autoinit_seen)
2860  continue ()
2861  endif ()
2862  list(APPEND _vtk_autoinit_seen
2863  "${_vtk_autoinit_current_module}")
2864 
2865  _vtk_module_real_target(_vtk_autoinit_current_target "${_vtk_autoinit_current_module}")
2866  get_property(_vtk_autoinit_implements
2867  TARGET "${_vtk_autoinit_current_target}"
2868  PROPERTY "INTERFACE_vtk_module_implements")
2869 
2870  list(APPEND _vtk_autoinit_needs_implements
2871  ${_vtk_autoinit_implements})
2872  foreach (_vtk_autoinit_implement IN LISTS _vtk_autoinit_implements)
2873  _vtk_module_real_target(_vtk_autoinit_implements_target "${_vtk_autoinit_implement}")
2874  get_property(_vtk_autoinit_implementable
2875  TARGET "${_vtk_autoinit_implements_target}"
2876  PROPERTY "INTERFACE_vtk_module_implementable")
2877 
2878  if (NOT _vtk_autoinit_implementable)
2879  message(FATAL_ERROR
2880  "The `${_vtk_autoinit_current_module}` module says that it "
2881  "implements the `${_vtk_autoinit_implement}` module, but it is not "
2882  "implementable.")
2883  endif ()
2884 
2885  list(APPEND "_vtk_autoinit_implements_${_vtk_autoinit_implement}"
2886  "${_vtk_autoinit_current_module}")
2887  endforeach ()
2888  endwhile ()
2889 
2890  if (NOT _vtk_autoinit_needs_implements)
2891  return ()
2892  endif ()
2893  list(REMOVE_DUPLICATES _vtk_autoinit_needs_implements)
2894  list(SORT _vtk_autoinit_needs_implements)
2895 
2896  set(_vtk_autoinit_hash_content)
2897  foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
2898  if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
2899  continue ()
2900  endif ()
2901  list(SORT "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}")
2902 
2903  string(APPEND _vtk_autoinit_hash_content
2904  "${_vtk_autoinit_need_implements}: ${_vtk_autoinit_implements_${_vtk_autoinit_need_implements}}\n")
2905  endforeach ()
2906  string(MD5 _vtk_autoinit_header_tag "${_vtk_autoinit_hash_content}")
2907  set(_vtk_autoinit_header
2908  "${CMAKE_BINARY_DIR}/CMakeFiles/vtkModuleAutoInit_${_vtk_autoinit_header_tag}.h")
2909 
2910  get_property(_vtk_autoinit_header_generated GLOBAL
2911  PROPERTY "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}")
2912 
2913  set(_vtk_autoinit_defines)
2914  set(_vtk_autoinit_header_content)
2915  foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
2916  if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
2917  continue ()
2918  endif ()
2919 
2920  get_property(_vtk_autoinit_implements_library_name
2921  TARGET "${_vtk_autoinit_need_implements}"
2922  PROPERTY "INTERFACE_vtk_module_library_name")
2923 
2924  if (NOT _vtk_autoinit_header_generated)
2925  list(LENGTH "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}"
2926  _vtk_autoinit_length)
2927  set(_vtk_autoinit_args)
2928  foreach (_vtk_autoinit_arg IN LISTS "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}")
2929  get_property(_vtk_autoinit_arg_library_name
2930  TARGET "${_vtk_autoinit_arg}"
2931  PROPERTY "INTERFACE_vtk_module_library_name")
2932  list(APPEND _vtk_autoinit_args
2933  "${_vtk_autoinit_arg_library_name}")
2934  endforeach ()
2935  string(REPLACE ";" "," _vtk_autoinit_args "${_vtk_autoinit_args}")
2936  string(APPEND _vtk_autoinit_header_content
2937  "#define ${_vtk_autoinit_implements_library_name}_AUTOINIT ${_vtk_autoinit_length}(${_vtk_autoinit_args})\n")
2938  endif ()
2939 
2940  list(APPEND _vtk_autoinit_defines
2941  "${_vtk_autoinit_implements_library_name}_AUTOINIT_INCLUDE=\"${_vtk_autoinit_header}\"")
2942  endforeach ()
2943 
2944  if (NOT _vtk_autoinit_header_generated)
2945  file(GENERATE
2946  OUTPUT "${_vtk_autoinit_header}"
2947  CONTENT "${_vtk_autoinit_header_content}")
2948 
2949  set_property(GLOBAL
2950  PROPERTY
2951  "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}" TRUE)
2952  endif ()
2953 
2954  foreach (_vtk_autoinit_target IN LISTS _vtk_autoinit_TARGETS)
2955  get_property(_vtk_autoinit_target_type
2956  TARGET "${_vtk_autoinit_target}"
2957  PROPERTY TYPE)
2958  if (_vtk_autoinit_target_type STREQUAL "INTERFACE_LIBRARY")
2959  continue ()
2960  endif ()
2961 
2962  target_compile_definitions("${_vtk_autoinit_target}"
2963  PRIVATE
2964  ${_vtk_autoinit_defines})
2965  endforeach ()
2966 endfunction ()
2967 
2968 #[==[
2969 @ingroup module-impl
2970 @brief Generate the hierarchy for a module
2971 
2972 Write wrap hierarchy files for the module currently being built. This also
2973 installs the hierarchy file for use by dependent projects if `INSTALL_HEADERS`
2974 is set.
2975 
2976 ~~~
2977 _vtk_module_write_wrap_hierarchy()
2978 ~~~
2979 #]==]
2980 function (_vtk_module_write_wrap_hierarchy)
2981  file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}")
2982 
2983  get_property(_vtk_hierarchy_library_name GLOBAL
2984  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
2985  set(_vtk_hierarchy_filename "${_vtk_hierarchy_library_name}-hierarchy.txt")
2986  set(_vtk_hierarchy_file "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}")
2987  set(_vtk_hierarchy_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.$<CONFIGURATION>.args")
2988  set(_vtk_hierarchy_data_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.data")
2989  set(_vtk_hierarchy_depends_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.depends.args")
2990 
2991  set_property(TARGET "${_vtk_add_module_real_target}"
2992  PROPERTY
2993  "INTERFACE_vtk_module_hierarchy" "${_vtk_hierarchy_file}")
2994 
2995  set(_vtk_add_module_target_name_iface "${_vtk_add_module_target_name}")
2996  if (_vtk_add_module_build_with_kit)
2997  set(_vtk_add_module_target_name_iface "${_vtk_add_module_target_name}-objects")
2998  endif ()
2999  set(_vtk_hierarchy_genex_compile_definitions
3000  "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},COMPILE_DEFINITIONS>")
3001  set(_vtk_hierarchy_genex_include_directories
3002  "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},INCLUDE_DIRECTORIES>")
3003  file(GENERATE
3004  OUTPUT "${_vtk_hierarchy_args_file}"
3005  CONTENT "$<$<BOOL:${_vtk_hierarchy_genex_compile_definitions}>:\n-D\'$<JOIN:${_vtk_hierarchy_genex_compile_definitions},\'\n-D\'>\'>\n
3006 $<$<BOOL:${_vtk_hierarchy_genex_include_directories}>:\n-I\'$<JOIN:${_vtk_hierarchy_genex_include_directories},\'\n-I\'>\'>\n")
3007 
3008  get_property(_vtk_hierarchy_depends_is_global GLOBAL
3009  PROPERTY "_vtk_module_${_vtk_build_module}_depends"
3010  SET)
3011  if (_vtk_hierarchy_depends_is_global)
3012  get_property(_vtk_hierarchy_depends GLOBAL
3013  PROPERTY "_vtk_module_${_vtk_build_module}_depends")
3014  else ()
3015  get_property(_vtk_hierarchy_depends GLOBAL
3016  TARGET "${_vtk_add_module_real_target}"
3017  PROPERTY "INTERFACE_vtk_module_depends")
3018  endif ()
3019 
3020  set(_vtk_hierarchy_depends_files)
3021  set(_vtk_hierarchy_depends_targets)
3022  foreach (_vtk_hierarchy_depend IN LISTS _vtk_hierarchy_depends)
3023  _vtk_module_get_module_property("${_vtk_hierarchy_depend}"
3024  PROPERTY "hierarchy"
3025  VARIABLE _vtk_hierarchy_depend_hierarchy)
3026  if (NOT DEFINED _vtk_hierarchy_depend_hierarchy)
3027  continue ()
3028  endif ()
3029 
3030  list(APPEND _vtk_hierarchy_depends_files
3031  "${_vtk_hierarchy_depend_hierarchy}")
3032 
3033  # Find the hierarchy target of the module.
3034  get_property(_vtk_hierarchy_module_is_imported
3035  TARGET "${_vtk_hierarchy_depend}"
3036  PROPERTY IMPORTED)
3037  # Imported target modules are external and should already have their file
3038  # generated.
3039  if (_vtk_hierarchy_module_is_imported)
3040  continue ()
3041  endif ()
3042 
3043  get_property(_vtk_hierarchy_depend_library_name GLOBAL
3044  PROPERTY "_vtk_module_${_vtk_hierarchy_depend}_library_name")
3045  if (TARGET "${_vtk_hierarchy_depend_library_name}-hierarchy")
3046  list(APPEND _vtk_hierarchy_depends_targets
3047  "${_vtk_hierarchy_depend_library_name}-hierarchy")
3048  endif ()
3049  endforeach ()
3050 
3051  set(_vtk_hierarchy_depends_files_arg)
3052  if (_vtk_hierarchy_depends_files)
3053  file(GENERATE
3054  OUTPUT "${_vtk_hierarchy_depends_args_file}"
3055  CONTENT "\"$<JOIN:${_vtk_hierarchy_depends_files},\"\n\">\"\n")
3056  else ()
3057  file(GENERATE
3058  OUTPUT "${_vtk_hierarchy_depends_args_file}"
3059  CONTENT "")
3060  endif ()
3061 
3062  _vtk_module_get_module_property("${_vtk_build_module}"
3063  PROPERTY "headers"
3064  VARIABLE _vtk_hierarchy_headers)
3065  set(_vtk_hierarchy_data_content "")
3066  foreach (_vtk_hierarchy_header IN LISTS _vtk_hierarchy_headers)
3067  string(APPEND _vtk_hierarchy_data_content
3068  "${_vtk_hierarchy_header};${_vtk_hierarchy_library_name}\n")
3069  endforeach ()
3070  file(GENERATE
3071  OUTPUT "${_vtk_hierarchy_data_file}"
3072  CONTENT "${_vtk_hierarchy_data_content}")
3073 
3074  if (CMAKE_GENERATOR MATCHES "Ninja")
3075  set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_files})
3076  else ()
3077  set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_targets})
3078  endif ()
3079 
3080  set(_vtk_hierarchy_tool_target "VTK::WrapHierarchy")
3081  set(_vtk_hierarchy_macros_args)
3082  if (TARGET VTKCompileTools::WrapHierarchy)
3083  set(_vtk_hierarchy_tool_target "VTKCompileTools::WrapHierarchy")
3084  if (TARGET VTKCompileTools_macros)
3085  list(APPEND _vtk_hierarchy_command_depends
3086  "VTKCompileTools_macros")
3087  list(APPEND _vtk_hierarchy_macros_args
3088  -undef
3089  -imacros "${_VTKCompileTools_macros_file}")
3090  endif ()
3091  endif ()
3092 
3093  add_custom_command(
3094  OUTPUT "${_vtk_hierarchy_file}"
3095  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
3096  "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>"
3097  "@${_vtk_hierarchy_args_file}"
3098  -o "${_vtk_hierarchy_file}"
3099  "${_vtk_hierarchy_data_file}"
3100  "@${_vtk_hierarchy_depends_args_file}"
3101  ${_vtk_hierarchy_macros_args}
3102  COMMENT "Generating the wrap hierarchy for ${_vtk_build_module}"
3103  DEPENDS
3104  ${_vtk_hierarchy_headers}
3105  "${_vtk_hierarchy_args_file}"
3106  "${_vtk_hierarchy_data_file}"
3107  "${_vtk_hierarchy_depends_args_file}"
3108  ${_vtk_hierarchy_command_depends})
3109  add_custom_target("${_vtk_add_module_library_name}-hierarchy" ALL
3110  DEPENDS
3111  "${_vtk_hierarchy_file}"
3112  "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>")
3113  set_property(TARGET "${_vtk_add_module_real_target}"
3114  PROPERTY
3115  "INTERFACE_vtk_module_hierarchy" "${_vtk_hierarchy_file}")
3116 
3117  if (_vtk_build_INSTALL_HEADERS)
3118  set_property(TARGET "${_vtk_add_module_real_target}"
3119  PROPERTY
3120  "INTERFACE_vtk_module_hierarchy_install" "\${_vtk_module_import_prefix}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}")
3121  install(
3122  FILES "${_vtk_hierarchy_file}"
3123  DESTINATION "${_vtk_build_HIERARCHY_DESTINATION}"
3124  RENAME "${_vtk_hierarchy_filename}"
3125  COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
3126  endif ()
3127 endfunction ()
3128 
3129 include(GenerateExportHeader)
3130 
3131 #[==[
3132 @ingroup module
3133 @brief Create a module library
3134 
3135 ~~~
3136 vtk_module_add_module(<name>
3137  [FORCE_STATIC] [HEADER_ONLY]
3138  [EXPORT_MACRO_PREFIX <prefix>]
3139  [HEADERS_SUBDIR <subdir>]
3140  [LIBRARY_NAME_SUFFIX <suffix>]
3141  [CLASSES <class>...]
3142  [TEMPLATE_CLASSES <template class>...]
3143  [SOURCES <source>...]
3144  [HEADERS <header>...]
3145  [TEMPLATES <template>...]
3146  [PRIVATE_CLASSES <class>...]
3147  [PRIVATE_TEMPLATE_CLASSES <template class>...]
3148  [PRIVATE_HEADERS <header>...]
3149  [PRIVATE_TEMPLATES <template>...])
3150 ~~~
3151 
3152 The `PRIVATE_` arguments are analogous to their non-`PRIVATE_` arguments, but
3153 the associated files are not installed or available for wrapping (`SOURCES` are
3154 always private, so there is no `PRIVATE_` variant for that argument).
3155 
3156  * `FORCE_STATIC`: For a static library to be created. If not provided,
3157  `BUILD_SHARED_LIBS` will control the library type.
3158  * `HEADER_ONLY`: The module only contains headers (or templates) and contains
3159  no compilation steps. Mutually exclusive with `FORCE_STATIC`.
3160  * `EXPORT_MACRO_PREFIX`: The prefix for the export macro definitions.
3161  Defaults to the library name of the module in all uppercase.
3162  * `HEADERS_SUBDIR`: The subdirectory to install headers into in the install
3163  tree.
3164  * `LIBRARY_NAME_SUFFIX`: The suffix to the module's library name if
3165  additional information is required.
3166  * `CLASSES`: A list of classes in the module. This is a shortcut for adding
3167  `<class>.cxx` to `SOURCES` and `<class>.h` to `HEADERS`.
3168  * `TEMPLATE_CLASSES`: A list of template classes in the module. This is a
3169  shortcut for adding `<class>.txx` to `TEMPLATES` and `<class>.h` to
3170  `HEADERS`.
3171  * `SOURCES`: A list of source files which require compilation.
3172  * `HEADERS`: A list of header files which will be available for wrapping and
3173  installed.
3174  * `TEMPLATES`: A list of template files which will be installed.
3175 #]==]
3177  if (NOT name STREQUAL _vtk_build_module)
3178  message(FATAL_ERROR
3179  "The ${_vtk_build_module}'s CMakeLists.txt may not add the ${name} module.")
3180  endif ()
3181 
3182  set(_vtk_add_module_source_keywords)
3183  foreach (_vtk_add_module_kind IN ITEMS CLASSES TEMPLATE_CLASSES HEADERS TEMPLATES)
3184  list(APPEND _vtk_add_module_source_keywords
3185  "${_vtk_add_module_kind}"
3186  "PRIVATE_${_vtk_add_module_kind}")
3187  endforeach ()
3188 
3189  cmake_parse_arguments(_vtk_add_module
3190  "FORCE_STATIC;HEADER_ONLY"
3191  "EXPORT_MACRO_PREFIX;HEADERS_SUBDIR;LIBRARY_NAME_SUFFIX"
3192  "${_vtk_add_module_source_keywords};SOURCES"
3193  ${ARGN})
3194 
3195  if (_vtk_add_module_UNPARSED_ARGUMENTS)
3196  message(FATAL_ERROR
3197  "Unparsed arguments for vtk_module_add_module: "
3198  "${_vtk_add_module_UNPARSED_ARGUMENTS}")
3199  endif ()
3200 
3201  if (NOT DEFINED _vtk_add_module_EXPORT_MACRO_PREFIX)
3202  _vtk_module_default_export_macro_prefix(_vtk_add_module_EXPORT_MACRO_PREFIX)
3203  endif ()
3204 
3205  if (_vtk_add_module_HEADER_ONLY AND _vtk_add_module_FORCE_STATIC)
3206  message(FATAL_ERROR
3207  "The ${_vtk_build_module} module cannot be header only yet forced "
3208  "static.")
3209  endif ()
3210 
3211  foreach (_vtk_add_module_class IN LISTS _vtk_add_module_CLASSES)
3212  list(APPEND _vtk_add_module_SOURCES
3213  "${_vtk_add_module_class}.cxx")
3214  list(APPEND _vtk_add_module_HEADERS
3215  "${_vtk_add_module_class}.h")
3216  endforeach ()
3217 
3218  foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_TEMPLATE_CLASSES)
3219  list(APPEND _vtk_add_module_TEMPLATES
3220  "${_vtk_add_module_template_class}.txx")
3221  list(APPEND _vtk_add_module_HEADERS
3222  "${_vtk_add_module_template_class}.h")
3223  endforeach ()
3224 
3225  foreach (_vtk_add_module_class IN LISTS _vtk_add_module_PRIVATE_CLASSES)
3226  list(APPEND _vtk_add_module_SOURCES
3227  "${_vtk_add_module_class}.cxx")
3228  list(APPEND _vtk_add_module_PRIVATE_HEADERS
3229  "${_vtk_add_module_class}.h")
3230  endforeach ()
3231 
3232  foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_PRIVATE_TEMPLATE_CLASSES)
3233  list(APPEND _vtk_add_module_PRIVATE_TEMPLATES
3234  "${_vtk_add_module_template_class}.txx")
3235  list(APPEND _vtk_add_module_PRIVATE_HEADERS
3236  "${_vtk_add_module_template_class}.h")
3237  endforeach ()
3238 
3239  if (NOT _vtk_add_module_SOURCES AND NOT _vtk_add_module_HEADER_ONLY)
3240  message(WARNING
3241  "The ${_vtk_build_module} module has no source files.")
3242  endif ()
3243 
3244  get_property(_vtk_add_module_third_party GLOBAL
3245  PROPERTY "_vtk_module_${_vtk_build_module}_third_party")
3246 
3247  get_property(_vtk_add_module_library_name GLOBAL
3248  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
3249  set(_vtk_add_module_module_header_name
3250  "${_vtk_add_module_library_name}Module.h")
3251  if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3252  set(_vtk_add_module_generated_header
3253  "${CMAKE_CURRENT_BINARY_DIR}/${_vtk_add_module_module_header_name}")
3254  list(APPEND _vtk_add_module_HEADERS
3255  "${_vtk_add_module_generated_header}")
3256  endif ()
3257 
3258  vtk_module_install_headers(
3259  FILES ${_vtk_add_module_HEADERS}
3260  ${_vtk_add_module_TEMPLATES}
3261  SUBDIR "${_vtk_add_module_HEADERS_SUBDIR}")
3262 
3263  set(_vtk_add_module_type)
3264  if (_vtk_add_module_FORCE_STATIC)
3265  set(_vtk_add_module_type STATIC)
3266  endif ()
3267 
3268  set(_vtk_add_module_build_with_kit)
3269  if (_vtk_build_BUILD_WITH_KITS)
3270  get_property(_vtk_add_module_build_with_kit GLOBAL
3271  PROPERTY "_vtk_module_${_vtk_build_module}_kit")
3272  endif ()
3273 
3274  get_property(_vtk_add_module_namespace GLOBAL
3275  PROPERTY "_vtk_module_${_vtk_build_module}_namespace")
3276  get_property(_vtk_add_module_target_name GLOBAL
3277  PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
3278  set(_vtk_add_module_real_target "${_vtk_add_module_target_name}")
3279  if (_vtk_add_module_HEADER_ONLY)
3280  if (_vtk_add_module_build_with_kit)
3281  message(FATAL_ERROR
3282  "The module ${_vtk_build_module} is header-only, but is part of the "
3283  "${_vtk_add_module_build_with_kit} kit. Header-only modules do not "
3284  "belong in kits.")
3285  endif ()
3286 
3287  # XXX(cmake-3.12.0): This unset is no longer necessary when 3.12.0 is required.
3288  unset("${_vtk_build_module}_LIB_DEPENDS" CACHE)
3289  add_library("${_vtk_add_module_real_target}" INTERFACE)
3290 
3291  if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3292  add_library("${_vtk_build_module}" ALIAS
3293  "${_vtk_add_module_real_target}")
3294  endif ()
3295  else ()
3296  if (_vtk_add_module_build_with_kit)
3297  add_library("${_vtk_add_module_real_target}" INTERFACE)
3298  target_link_libraries("${_vtk_add_module_real_target}"
3299  INTERFACE
3300  # For usage requirements.
3301  "${_vtk_add_module_real_target}-objects"
3302  # For the implementation.
3303  "$<LINK_ONLY:${_vtk_add_module_build_with_kit}>")
3304 
3305  if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3306  add_library("${_vtk_build_module}" ALIAS
3307  "${_vtk_add_module_real_target}")
3308  endif ()
3309 
3310  # Set up properties necessary for other infrastructure.
3311  set_property(TARGET "${_vtk_add_module_real_target}"
3312  PROPERTY
3313  "INTERFACE_vtk_module_library_name" "${_vtk_add_module_library_name}")
3314 
3315  # XXX(cmake-3.12.0): This unset is no longer necessary when 3.12.0 is required.
3316  unset("${_vtk_build_module}_LIB_DEPENDS" CACHE)
3317  add_library("${_vtk_add_module_real_target}-objects" OBJECT
3318  ${_vtk_add_module_SOURCES}
3319  ${_vtk_add_module_TEMPLATES}
3320  ${_vtk_add_module_PRIVATE_TEMPLATES}
3321  ${_vtk_add_module_HEADERS}
3322  ${_vtk_add_module_PRIVATE_HEADERS})
3323  set_target_properties("${_vtk_add_module_real_target}-objects"
3324  PROPERTIES
3325  # Emulate the regular library as much as possible.
3326  DEFINE_SYMBOL "${_vtk_add_module_real_target}_EXPORT"
3327  POSITION_INDEPENDENT_CODE ON)
3328  target_compile_definitions("${_vtk_add_module_real_target}-objects"
3329  PRIVATE
3330  "${_vtk_add_module_real_target}_EXPORT")
3331  set(_vtk_add_module_real_target "${_vtk_add_module_real_target}-objects")
3332  else ()
3333  add_library("${_vtk_add_module_real_target}" ${_vtk_add_module_type}
3334  ${_vtk_add_module_SOURCES}
3335  ${_vtk_add_module_TEMPLATES}
3336  ${_vtk_add_module_HEADERS}
3337  ${_vtk_add_module_PRIVATE_HEADERS})
3338 
3339  set_property(TARGET "${_vtk_add_module_real_target}"
3340  PROPERTY
3341  POSITION_INDEPENDENT_CODE ON)
3342 
3343  if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3344  add_library("${_vtk_build_module}" ALIAS
3345  "${_vtk_add_module_real_target}")
3346  endif ()
3347  endif ()
3348  endif ()
3349 
3350  set_property(TARGET "${_vtk_add_module_real_target}"
3351  PROPERTY
3352  "INTERFACE_vtk_module_library_name" "${_vtk_add_module_library_name}")
3353 
3354  get_property(_vtk_add_module_depends GLOBAL
3355  PROPERTY "_vtk_module_${_vtk_build_module}_depends")
3356  set_property(TARGET "${_vtk_add_module_real_target}"
3357  PROPERTY
3358  "INTERFACE_vtk_module_depends" "${_vtk_add_module_depends}")
3359  set(_vtk_add_module_includes_interface)
3360  if (_vtk_add_module_HEADER_ONLY)
3361  target_link_libraries("${_vtk_add_module_real_target}"
3362  INTERFACE
3363  ${_vtk_add_module_depends})
3364  set(_vtk_add_module_includes_interface INTERFACE)
3365  else ()
3366  get_property(_vtk_add_module_private_depends GLOBAL
3367  PROPERTY "_vtk_module_${_vtk_build_module}_private_depends")
3368 
3369  # XXX(cmake#18484): Linking dependencies directly currently creates
3370  # circular dependencies. This logic should be removed once the minimum for
3371  # kits contains a fix for the mentioned issue.
3372  #
3373  # When two modules are part of the same kit, we can get this problem:
3374  #
3375  # A - iface -> A-objects <- tll - K
3376  # ^ |
3377  # | |
3378  # B - iface -> B-objects <- tll -/
3379  #
3380  # If B depends on A, it ends up with a circular dependency since A has a
3381  # `$<LINK_ONLY:K>` link. instead, munge up dependencies of intra-kit
3382  # dependencies to link to the `-objects` target instead.
3383  if (_vtk_add_module_build_with_kit)
3384  set(_vtk_add_module_depends_link)
3385  set(_vtk_add_module_private_depends_link)
3386  foreach (_vtk_add_module_depend IN LISTS _vtk_add_module_depends)
3387  get_property(_vtk_add_module_depend_kit GLOBAL
3388  PROPERTY "_vtk_module_${_vtk_add_module_depend}_kit")
3389  if (_vtk_add_module_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3390  # We're in the same kit; depend on the `-objects` library of the
3391  # module.
3392  get_property(_vtk_add_module_depend_target_name GLOBAL
3393  PROPERTY "_vtk_module_${_vtk_add_module_depend}_target_name")
3394  list(APPEND _vtk_add_module_depends_link
3395  "${_vtk_add_module_depend_target_name}-objects")
3396  else ()
3397  # Different kit, just use as normal.
3398  list(APPEND _vtk_add_module_depends_link
3399  "${_vtk_add_module_depend}")
3400  endif ()
3401  endforeach ()
3402  foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_private_depends)
3403  get_property(_vtk_add_module_private_depend_kit GLOBAL
3404  PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_kit")
3405  if (_vtk_add_module_private_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3406  # We're in the same kit; depend on the `-objects` library of the
3407  # module.
3408  get_property(_vtk_add_module_private_depend_target_name GLOBAL
3409  PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_target_name")
3410  list(APPEND _vtk_add_module_private_depends_link
3411  "${_vtk_add_module_private_depend_target_name}-objects")
3412  else ()
3413  # Different kit, just use as normal.
3414  list(APPEND _vtk_add_module_private_depends_link
3415  "${_vtk_add_module_private_depend}")
3416  endif ()
3417  endforeach ()
3418 
3419  # Add the `DEFINE_SYMBOL` for all other modules within the same kit which
3420  # have already been processed because the direct dependencies are not
3421  # sufficient: export symbols from any included header needs to be
3422  # correct. Since modules are built in topological order, a module can
3423  # only possibly include modules in the kit which have already been built.
3424  get_property(_vtk_add_module_kit_modules GLOBAL
3425  PROPERTY "_vtk_kit_${_vtk_add_module_build_with_kit}_kit_modules")
3426  list(REMOVE_ITEM _vtk_add_module_kit_modules "${_vtk_build_module}")
3427  foreach (_vtk_add_module_kit_module IN LISTS _vtk_add_module_kit_modules)
3428  get_property(_vtk_add_module_kit_module_target_name GLOBAL
3429  PROPERTY "_vtk_module_${_vtk_add_module_kit_module}_target_name")
3430  if (TARGET "${_vtk_add_module_kit_module_target_name}-objects")
3431  get_property(_vtk_add_module_kit_module_define_symbol
3432  TARGET "${_vtk_add_module_kit_module_target_name}-objects"
3433  PROPERTY DEFINE_SYMBOL)
3434  target_compile_definitions("${_vtk_add_module_real_target}"
3435  PRIVATE
3436  "${_vtk_add_module_kit_module_define_symbol}")
3437  endif ()
3438  endforeach ()
3439  else ()
3440  set(_vtk_add_module_depends_link ${_vtk_add_module_depends})
3441  set(_vtk_add_module_private_depends_link ${_vtk_add_module_private_depends})
3442  endif ()
3443  target_link_libraries("${_vtk_add_module_real_target}"
3444  PUBLIC
3445  ${_vtk_add_module_depends_link}
3446  PRIVATE
3447  ${_vtk_add_module_private_depends_link})
3448 
3449  set(_vtk_add_module_private_depends_forward_link)
3450  foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_depends_link _vtk_add_module_private_depends)
3451  _vtk_module_get_module_property("${_vtk_add_module_private_depend}"
3452  PROPERTY "forward_link"
3453  VARIABLE _vtk_add_module_forward_link)
3454  list(APPEND _vtk_add_module_private_depends_forward_link
3455  ${_vtk_add_module_forward_link})
3456  endforeach ()
3457 
3458  get_property(_vtk_add_module_optional_depends GLOBAL
3459  PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
3460  foreach (_vtk_add_module_optional_depend IN LISTS _vtk_add_module_optional_depends)
3461  if (TARGET "${_vtk_add_module_optional_depend}")
3462  set(_vtk_add_module_have_optional_depend 1)
3463  set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend}")
3464  if (_vtk_add_module_build_with_kit)
3465  get_property(_vtk_add_module_optional_depend_kit GLOBAL
3466  PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_kit")
3467  if (_vtk_add_module_optional_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3468  # We're in the same kit; depend on the `-objects` library of the
3469  # module to avoid circular dependency (see explanation earlier)
3470  get_property(_vtk_add_module_optional_depend_target_name GLOBAL
3471  PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_target_name")
3472  set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend_target_name}-objects")
3473  endif ()
3474  endif ()
3475  _vtk_module_get_module_property("${_vtk_add_module_optional_depend_link}"
3476  PROPERTY "forward_link"
3477  VARIABLE _vtk_add_module_forward_link)
3478  list(APPEND _vtk_add_module_private_depends_forward_link
3479  ${_vtk_add_module_forward_link})
3480  target_link_libraries("${_vtk_add_module_real_target}"
3481  PRIVATE
3482  "${_vtk_add_module_optional_depend_link}")
3483  else ()
3484  set(_vtk_add_module_have_optional_depend 0)
3485  endif ()
3486  string(REPLACE "::" "_" _vtk_add_module_optional_depend_safe "${_vtk_add_module_optional_depend}")
3487  target_compile_definitions("${_vtk_add_module_real_target}"
3488  PRIVATE
3489  "VTK_MODULE_ENABLE_${_vtk_add_module_optional_depend_safe}=${_vtk_add_module_have_optional_depend}")
3490  endforeach ()
3491 
3492  if (_vtk_add_module_private_depends_forward_link)
3493  list(REMOVE_DUPLICATES _vtk_add_module_private_depends_forward_link)
3494  _vtk_module_set_module_property("${_vtk_build_module}" APPEND
3495  PROPERTY "forward_link"
3496  VALUE "${_vtk_add_module_private_depends_forward_link}")
3497  target_link_libraries("${_vtk_add_module_real_target}"
3498  PUBLIC
3499  "${_vtk_add_module_private_depends_forward_link}")
3500  endif ()
3501  endif ()
3502  _vtk_module_standard_includes(
3503  TARGET "${_vtk_add_module_real_target}"
3504  ${_vtk_add_module_includes_interface}
3505  HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}")
3506 
3507  vtk_module_autoinit(
3508  MODULES ${_vtk_add_module_depends}
3509  ${_vtk_add_module_private_depends}
3510  "${_vtk_build_module}"
3511  TARGETS "${_vtk_add_module_real_target}")
3512 
3513  set(_vtk_add_module_headers_build)
3514  set(_vtk_add_module_headers_install)
3515  # TODO: Perform this in `vtk_module_install_headers` so that manually
3516  # installed headers may participate in wrapping as well.
3517  foreach (_vtk_add_module_header IN LISTS _vtk_add_module_HEADERS)
3518  if (IS_ABSOLUTE "${_vtk_add_module_header}")
3519  list(APPEND _vtk_add_module_headers_build
3520  "${_vtk_add_module_header}")
3521  else ()
3522  list(APPEND _vtk_add_module_headers_build
3523  "${CMAKE_CURRENT_SOURCE_DIR}/${_vtk_add_module_header}")
3524  endif ()
3525 
3526  get_filename_component(_vtk_add_module_header_name "${_vtk_add_module_header}" NAME)
3527  list(APPEND _vtk_add_module_headers_install
3528  "\${_vtk_module_import_prefix}/${_vtk_build_HEADERS_DESTINATION}/${_vtk_add_module_header_name}")
3529  endforeach ()
3530 
3531  set_property(TARGET "${_vtk_add_module_real_target}"
3532  PROPERTY
3533  "INTERFACE_vtk_module_headers" "${_vtk_add_module_headers_build}")
3534  if (_vtk_build_INSTALL_HEADERS)
3535  set_property(TARGET "${_vtk_add_module_real_target}"
3536  PROPERTY
3537  "INTERFACE_vtk_module_headers_install" "${_vtk_add_module_headers_install}")
3538  endif ()
3539 
3540  get_property(_vtk_add_module_exclude_wrap GLOBAL
3541  PROPERTY "_vtk_module_${_vtk_build_module}_exclude_wrap")
3542  set_property(TARGET "${_vtk_add_module_real_target}"
3543  PROPERTY
3544  "INTERFACE_vtk_module_exclude_wrap" "${_vtk_add_module_exclude_wrap}")
3545  if (NOT _vtk_add_module_exclude_wrap AND _vtk_build_ENABLE_WRAPPING)
3546  _vtk_module_write_wrap_hierarchy()
3547  endif ()
3548 
3549  set(_vtk_add_module_module_content)
3550 
3551  if (NOT _vtk_add_module_AUTOINIT_INCLUDE)
3552  get_property(_vtk_add_module_AUTOINIT_INCLUDE GLOBAL
3553  PROPERTY "_vtk_module_autoinit_include")
3554  endif ()
3555 
3556  set(_vtk_add_module_autoinit_include_header)
3557  if (_vtk_add_module_AUTOINIT_INCLUDE)
3558  set(_vtk_add_module_autoinit_include_header
3559  "#include ${_vtk_add_module_AUTOINIT_INCLUDE}")
3560  endif ()
3561 
3562  set(_vtk_add_module_autoinit_depends_includes)
3563  foreach (_vtk_add_module_autoinit_dependency IN LISTS _vtk_add_module_depends)
3564  get_property(_vtk_add_module_autoinit_dependency_target_name GLOBAL
3565  PROPERTY "_vtk_module_${_vtk_add_module_autoinit_dependency}_target_name")
3566  if (_vtk_add_module_autoinit_dependency_target_name)
3567  get_property(_vtk_add_module_depends_needs_autoinit
3568  TARGET "${_vtk_add_module_autoinit_dependency_target_name}"
3569  PROPERTY "INTERFACE_vtk_module_needs_autoinit")
3570  else ()
3571  set(_vtk_add_module_autoinit_dependency_target_name
3572  "${_vtk_add_module_autoinit_dependency}")
3573  get_property(_vtk_add_module_depends_needs_autoinit
3574  TARGET "${_vtk_add_module_autoinit_dependency}"
3575  PROPERTY "INTERFACE_vtk_module_needs_autoinit")
3576  endif ()
3577  if (NOT _vtk_add_module_depends_needs_autoinit)
3578  continue ()
3579  endif ()
3580  get_property(_vtk_add_module_depends_library_name
3581  TARGET "${_vtk_add_module_autoinit_dependency_target_name}"
3582  PROPERTY "INTERFACE_vtk_module_library_name")
3583 
3584  string(APPEND _vtk_add_module_autoinit_depends_includes
3585  "#include \"${_vtk_add_module_depends_library_name}Module.h\"\n")
3586  endforeach ()
3587 
3588  set(_vtk_add_module_autoinit_content)
3589  if (_vtk_add_module_autoinit_depends_includes)
3590  set(_vtk_add_module_autoinit_content
3591  "${_vtk_add_module_autoinit_content}/* AutoInit dependencies. */\n${_vtk_add_module_autoinit_depends_includes}\n")
3592  endif ()
3593 
3594  get_property(_vtk_add_module_implementable GLOBAL
3595  PROPERTY "_vtk_module_${_vtk_build_module}_implementable")
3596  get_property(_vtk_add_module_implements GLOBAL
3597  PROPERTY "_vtk_module_${_vtk_build_module}_implements")
3598  if (_vtk_add_module_implementable)
3599  set_property(TARGET "${_vtk_add_module_real_target}"
3600  PROPERTY
3601  "INTERFACE_vtk_module_implementable" 1)
3602  endif ()
3603 
3604  if (_vtk_add_module_implementable OR _vtk_add_module_implements)
3605  set_property(TARGET "${_vtk_add_module_real_target}"
3606  PROPERTY
3607  "INTERFACE_vtk_module_implements" "${_vtk_add_module_implements}")
3608  set_property(TARGET "${_vtk_add_module_real_target}"
3609  PROPERTY
3610  "INTERFACE_vtk_module_needs_autoinit" 1)
3611 
3612  set(_vtk_add_module_autoinit_content
3613  "${_vtk_add_module_autoinit_content}
3614 /* AutoInit implementations. */
3615 #ifdef ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3616 #include ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3617 #endif
3618 #ifdef ${_vtk_add_module_library_name}_AUTOINIT
3619 ${_vtk_add_module_autoinit_include_header}
3620 VTK_MODULE_AUTOINIT(${_vtk_add_module_library_name})
3621 #endif
3622 ")
3623 
3624  set(_vtk_add_module_module_content
3625  "${_vtk_add_module_module_content}${_vtk_add_module_autoinit_content}")
3626  endif ()
3627 
3628  if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3629  generate_export_header("${_vtk_add_module_real_target}"
3630  EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_EXPORT"
3631  NO_EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_EXPORT"
3632  DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_DEPRECATED"
3633  NO_DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_DEPRECATED"
3634  STATIC_DEFINE "${_vtk_add_module_EXPORT_MACRO_PREFIX}_STATIC_DEFINE"
3635  EXPORT_FILE_NAME "${_vtk_add_module_module_header_name}"
3636  CUSTOM_CONTENT_FROM_VARIABLE _vtk_add_module_module_content)
3637  endif ()
3638 
3639  _vtk_module_apply_properties("${_vtk_add_module_target_name}")
3640  _vtk_module_install("${_vtk_add_module_target_name}")
3641  _vtk_module_add_header_tests()
3642 
3643  if (_vtk_add_module_build_with_kit)
3644  _vtk_module_install("${_vtk_add_module_target_name}-objects")
3645  endif ()
3646 endfunction ()
3647 
3648 #[==[
3649 @ingroup module-impl
3650 @brief Add header tests for a module
3651 
3652 @todo Move this function out to be VTK-specific, probably into
3653 `vtkModuleTesting.cmake`. Each module would then need to manually call this
3654 function. It currently assumes it is in VTK itself.
3655 
3656 ~~~
3657 _vtk_module_add_header_tests()
3658 ~~~
3659 #]==]
3660 function (_vtk_module_add_header_tests)
3661  if (NOT BUILD_TESTING)
3662  return ()
3663  endif ()
3664 
3665  get_property(_vtk_add_header_tests_is_third_party GLOBAL
3666  PROPERTY "_vtk_module_${_vtk_build_module}_third_party")
3667  if (_vtk_add_header_tests_is_third_party)
3668  return ()
3669  endif ()
3670 
3671  # TODO: Add test compiles which include each header file to ensure that
3672  # public headers have their includes satisfied by a public dependency.
3673 
3674  # Bad...
3675  if (NOT "Python${VTK_PYTHON_VERSION}_EXECUTABLE")
3676  return ()
3677  endif ()
3678 
3679  # Worse...
3680  if (NOT VTK_SOURCE_DIR)
3681  return ()
3682  endif ()
3683 
3684  add_test(
3685  NAME "${_vtk_build_module}-HeaderTest"
3686  COMMAND "${Python${VTK_PYTHON_VERSION}_EXECUTABLE}"
3687  # TODO: What to do when using this from a VTK install?
3688  "${VTK_SOURCE_DIR}/Testing/Core/HeaderTesting.py"
3689  "${CMAKE_CURRENT_SOURCE_DIR}"
3690  "${_vtk_add_module_EXPORT_MACRO}")
3691 endfunction ()
3692 
3693 #[==[
3694 @ingroup module
3695 @brief Install headers
3696 
3697 Installing headers is done for normal modules by the @ref vtk_module_add_module
3698 function already. However, sometimes header structures are more complicated and
3699 need to be installed manually. This is common for third party modules or
3700 projects which use more than a single directory of headers for a module.
3701 
3702 To facilitate the installation of headers in various ways, the this function is
3703 available. This function honors the `INSTALL_HEADERS`, `HEADERS_DESTINATION`,
3704 and `HEADERS_COMPONENT` arguments to @ref vtk_module_build.
3705 
3706 ~~~
3707 vtk_module_install_headers(
3708  [DIRECTORIES <directory>...]
3709  [FILES <file>...]
3710  [SUBDIR <subdir>])
3711 ~~~
3712 
3713 Installation of header directories follows CMake's `install` function semantics
3714 with respect to trailing slashes.
3715 #]==]
3716 function (vtk_module_install_headers)
3717  cmake_parse_arguments(_vtk_install_headers
3718  ""
3719  "SUBDIR"
3720  "FILES;DIRECTORIES"
3721  ${ARGN})
3722 
3723  if (_vtk_install_headers_UNPARSED_ARGUMENTS)
3724  message(FATAL_ERROR
3725  "Unparsed arguments for vtk_module_install_headers: "
3726  "${_vtk_install_headers_UNPARSED_ARGUMENTS}")
3727  endif ()
3728 
3729  if (NOT _vtk_build_INSTALL_HEADERS)
3730  return ()
3731  endif ()
3732 
3733  if (NOT _vtk_install_headers_FILES AND NOT _vtk_install_headers_DIRECTORIES)
3734  return ()
3735  endif ()
3736 
3737  set(_vtk_install_headers_destination
3738  "${_vtk_build_HEADERS_DESTINATION}/${_vtk_install_headers_SUBDIR}")
3739  if (_vtk_install_headers_FILES)
3740  install(
3741  FILES ${_vtk_install_headers_FILES}
3742  DESTINATION "${_vtk_install_headers_destination}"
3743  COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
3744  endif ()
3745  foreach (_vtk_install_headers_directory IN LISTS _vtk_install_headers_DIRECTORIES)
3746  install(
3747  DIRECTORY "${_vtk_install_headers_directory}"
3748  DESTINATION "${_vtk_install_headers_destination}"
3749  COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
3750  endforeach ()
3751 endfunction ()
3752 
3753 #[==[
3754 @ingroup module-internal
3755 @brief Apply properties to a module
3756 
3757 Apply build properties to a target. Generally only useful to wrapping code or
3758 other modules that cannot use @ref vtk_module_add_module for some reason.
3759 
3760 ~~~
3761 _vtk_module_apply_properties(<target>
3762  [BASENAME <basename>])
3763 ~~~
3764 
3765 If `BASENAME` is given, it will be used instead of the target name as the basis
3766 for `OUTPUT_NAME`. Full modules (as opposed to third party or other non-module
3767 libraries) always use the module's `LIBRARY_NAME` setting.
3768 
3769 The following target properties are set based on the arguments to the calling
3770 @ref vtk_module_build call:
3771 
3772  - `OUTPUT_NAME` (based on the module's `LIBRARY_NAME` and
3773  `vtk_module_build(LIBRARY_NAME_SUFFIX)`)
3774  - `VERSION` (based on `vtk_module_build(VERSION)`)
3775  - `SOVERSION` (based on `vtk_module_build(SOVERSION)`)
3776  - `DEBUG_POSTFIX` (on Windows)
3777 #]==]
3778 function (_vtk_module_apply_properties target)
3779  cmake_parse_arguments(_vtk_apply_properties
3780  ""
3781  "BASENAME"
3782  ""
3783  ${ARGN})
3784 
3785  if (_vtk_apply_properties_UNPARSED_ARGUMENTS)
3786  message(FATAL_ERROR
3787  "Unparsed arguments for _vtk_module_apply_properties: "
3788  "${_vtk_apply_properties_UNPARSED_ARGUMENTS}.")
3789  endif ()
3790 
3791  if (NOT DEFINED _vtk_apply_properties_BASENAME)
3792  set(_vtk_apply_properties_BASENAME "${target}")
3793  endif ()
3794 
3795  get_property(_vtk_add_module_type
3796  TARGET "${target}"
3797  PROPERTY TYPE)
3798  if (_vtk_add_module_type STREQUAL "OBJECT_LIBRARY" OR
3799  _vtk_add_module_type STREQUAL "INTERFACE_LIBRARY")
3800  return ()
3801  endif ()
3802 
3803  set(_vtk_add_module_library_name "${_vtk_apply_properties_BASENAME}")
3804  get_property(_vtk_add_module_target_name GLOBAL
3805  PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
3806  if (_vtk_add_module_target_name STREQUAL "${target}")
3807  get_property(_vtk_add_module_library_name GLOBAL
3808  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
3809  endif ()
3810  set(_vtk_add_module_output_name "${_vtk_add_module_library_name}${_vtk_add_module_LIBRARY_NAME_SUFFIX}")
3811  if (_vtk_build_LIBRARY_NAME_SUFFIX)
3812  string(APPEND _vtk_add_module_output_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}")
3813  endif ()
3814 
3815  set_target_properties("${target}"
3816  PROPERTIES
3817  OUTPUT_NAME "${_vtk_add_module_output_name}")
3818 
3819  if (_vtk_build_VERSION AND NOT _vtk_add_module_type STREQUAL "EXECUTABLE")
3820  set_target_properties("${target}"
3821  PROPERTIES
3822  VERSION "${_vtk_build_VERSION}")
3823  endif ()
3824 
3825  if (_vtk_build_SOVERSION)
3826  set_target_properties("${target}"
3827  PROPERTIES
3828  SOVERSION "${_vtk_build_SOVERSION}")
3829  endif ()
3830 
3831  if (WIN32)
3832  set_target_properties("${target}"
3833  PROPERTIES
3834  DEBUG_POSTFIX "d")
3835  endif ()
3836 endfunction ()
3837 
3838 #[==[
3839 @ingroup module-internal
3840 @brief Install a module target
3841 
3842 Install a target within the module context. Generally only useful to wrapping
3843 code, modules that cannot use @ref vtk_module_add_module for some reason, or
3844 modules which create utility targets that need installed.
3845 
3846 ~~~
3847 _vtk_module_install(<target>)
3848 ~~~
3849 
3850 This function uses the various installation options to @ref vtk_module_build
3851 function to keep the install uniform.
3852 #]==]
3853 function (_vtk_module_install target)
3854  set(_vtk_install_export)
3855  if (_vtk_build_INSTALL_EXPORT)
3856  set(_vtk_install_export
3857  EXPORT "${_vtk_build_INSTALL_EXPORT}")
3858  endif ()
3859 
3860  set(_vtk_install_namelink_args)
3861  if(NOT CMAKE_VERSION VERSION_LESS 3.12)
3862  list(APPEND _vtk_install_namelink_args
3863  NAMELINK_COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
3864  endif()
3865  install(
3866  TARGETS "${target}"
3867  ${_vtk_install_export}
3868  ${ARGN}
3869  ARCHIVE
3870  DESTINATION "${_vtk_build_ARCHIVE_DESTINATION}"
3871  COMPONENT "${_vtk_build_HEADERS_COMPONENT}"
3872  LIBRARY
3873  DESTINATION "${_vtk_build_LIBRARY_DESTINATION}"
3874  COMPONENT "${_vtk_build_TARGETS_COMPONENT}"
3875  ${_vtk_install_namelink_args}
3876  RUNTIME
3877  DESTINATION "${_vtk_build_RUNTIME_DESTINATION}"
3878  COMPONENT "${_vtk_build_TARGETS_COMPONENT}")
3879 endfunction ()
3880 
3881 #[==[
3882 @ingroup module
3883 @brief Create a module executable
3884 
3885 Some modules may have associated executables with them. By using this function,
3886 the target will be installed following the options given to the associated
3887 @ref vtk_module_build command. Its name will also be changed according to the
3888 `LIBRARY_NAME_SUFFIX` option.
3889 
3890 ~~~
3891 vtk_module_add_executable(<name>
3892  [NO_INSTALL]
3893  [DEVELOPMENT]
3894  [BASENAME <basename>]
3895  <source>...)
3896 ~~~
3897 
3898 If `NO_INSTALL` is specified, the executable will not be installed. If
3899 `BASENAME` is given, it will be used as the name of the executable rather than
3900 the target name.
3901 
3902 If `DEVELOPMENT` is given, it marks the executable as a development tool and
3903 will not be installed if `INSTALL_HEADERS` is not set for the associated
3904 @ref vtk_module_build command.
3905 
3906 If the executable being built is the module, its module properties are used
3907 rather than `BASENAME`. In addition, the dependencies of the module will be
3908 linked.
3909 #]==]
3910 function (vtk_module_add_executable name)
3911  cmake_parse_arguments(_vtk_add_executable
3912  "NO_INSTALL;DEVELOPMENT"
3913  "BASENAME"
3914  ""
3915  ${ARGN})
3916 
3917  if (NOT _vtk_add_executable_UNPARSED_ARGUMENTS)
3918  message(FATAL_ERROR
3919  "The ${name} executable must have at least one source file.")
3920  endif ()
3921 
3922  if (_vtk_add_executable_NO_INSTALL AND _vtk_add_executable_DEVELOPMENT)
3923  message(FATAL_ERROR
3924  "Both `NO_INSTALL` and `DEVELOPMENT` may not be specified.")
3925  endif ()
3926 
3927  set(_vtk_add_executable_target_name "${name}")
3928  set(_vtk_add_executable_library_name "${name}")
3929  if (name STREQUAL _vtk_build_module)
3930  if (_vtk_add_executable_NO_INSTALL)
3931  message(FATAL_ERROR
3932  "The executable ${_vtk_build_module} module may not use `NO_INSTALL`.")
3933  endif ()
3934  if (DEFINED _vtk_add_executable_BASENAME)
3935  message(FATAL_ERROR
3936  "The executable ${_vtk_build_module} module may not pass `BASENAME` "
3937  "when adding the executable; it is controlled via `LIBRARY_NAME` in "
3938  "the associated `vtk.module` file.")
3939  endif ()
3940  get_property(_vtk_add_executable_target_name GLOBAL
3941  PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
3942  get_property(_vtk_add_executable_library_name GLOBAL
3943  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
3944  endif ()
3945 
3946  if (_vtk_add_executable_DEVELOPMENT AND NOT _vtk_build_INSTALL_HEADERS)
3947  set(_vtk_add_executable_NO_INSTALL ON)
3948  endif ()
3949 
3950  # Set up rpaths
3951  set(CMAKE_BUILD_RPATH_USE_ORIGIN 1)
3952  if (UNIX)
3953  file(RELATIVE_PATH _vtk_add_executable_relpath
3954  "/prefix/${_vtk_build_RUNTIME_DESTINATION}"
3955  "/prefix/${_vtk_build_LIBRARY_DESTINATION}")
3956  if (APPLE)
3957  set(_vtk_add_executable_origin_rpath_prefix
3958  "@executable_path")
3959  else ()
3960  set(_vtk_add_executable_origin_rpath_prefix
3961  "$ORIGIN")
3962  endif ()
3963 
3964  list(APPEND CMAKE_INSTALL_RPATH
3965  "${_vtk_add_executable_origin_rpath_prefix}/${_vtk_add_executable_relpath}")
3966  endif ()
3967 
3968  add_executable("${_vtk_add_executable_target_name}"
3969  ${_vtk_add_executable_UNPARSED_ARGUMENTS})
3970 
3971  if (name STREQUAL _vtk_build_module AND NOT _vtk_add_executable_target_name STREQUAL _vtk_build_module)
3972  add_executable("${_vtk_build_module}" ALIAS
3973  "${_vtk_add_executable_target_name}")
3974  endif ()
3975 
3976  if (name STREQUAL _vtk_build_module)
3977  get_property(_vtk_real_target_kit GLOBAL
3978  PROPERTY "_vtk_module_${_vtk_build_module}_kit")
3979  if (_vtk_real_target_kit)
3980  message(FATAL_ERROR
3981  "Executable module ${_vtk_build_module} is declared to be part of a "
3982  "kit; this is not possible.")
3983  endif ()
3984 
3985  get_property(_vtk_add_executable_depends GLOBAL
3986  PROPERTY "_vtk_module_${_vtk_build_module}_depends")
3987  get_property(_vtk_add_executable_private_depends GLOBAL
3988  PROPERTY "_vtk_module_${_vtk_build_module}_private_depends")
3989  target_link_libraries("${_vtk_add_executable_target_name}"
3990  PUBLIC
3991  ${_vtk_add_executable_depends}
3992  PRIVATE
3993  ${_vtk_add_executable_private_depends})
3994  get_property(_vtk_add_executable_optional_depends GLOBAL
3995  PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
3996  foreach (_vtk_add_executable_optional_depend IN LISTS _vtk_add_executable_optional_depends)
3997  string(REPLACE "::" "_" _vtk_add_executable_optional_depend_safe "${_vtk_add_executable_optional_depend}")
3998  if (TARGET "${_vtk_add_executable_optional_depend}")
3999  set(_vtk_add_executable_have_optional_depend 1)
4000  else ()
4001  set(_vtk_add_executable_have_optional_depend 0)
4002  endif ()
4003  target_compile_definitions("${_vtk_add_executable_target_name}"
4004  PRIVATE
4005  "VTK_MODULE_ENABLE_${_vtk_add_executable_optional_depend_safe}=${_vtk_add_executable_have_optional_depend}")
4006  endforeach ()
4007 
4008  if (_vtk_module_warnings)
4009  if (_vtk_add_executable_depends)
4010  message(WARNING
4011  "Executable module ${_vtk_build_module} has public dependencies; this "
4012  "shouldn't be necessary.")
4013  endif ()
4014  endif ()
4015  endif ()
4016 
4017  set(_vtk_add_executable_property_args)
4018  if (DEFINED _vtk_add_executable_BASENAME)
4019  list(APPEND _vtk_add_executable_property_args
4020  BASENAME "${_vtk_add_executable_BASENAME}")
4021  endif ()
4022 
4023  _vtk_module_apply_properties("${_vtk_add_executable_target_name}"
4024  ${_vtk_add_executable_property_args})
4025  _vtk_module_standard_includes(TARGET "${_vtk_add_executable_target_name}")
4026 
4027  if (NOT _vtk_add_executable_NO_INSTALL)
4028  _vtk_module_install("${_vtk_add_executable_target_name}")
4029  endif ()
4030 endfunction ()
4031 
4032 #[==[
4033 @ingroup module
4034 @brief Find a package
4035 
4036 A wrapper around `find_package` that records information for use so that the
4037 same targets may be found when finding this package.
4038 
4039 Modules may need to find external dependencies. CMake often provides modules to
4040 find these dependencies, but when imported targets are involved, these.need to
4041 also be found from dependencies of the current project. Since the benefits of
4042 imported targets greatly outweighs not using them, it is preferred to use them.
4043 
4044 The module system provides the @ref vtk_module_find_package function in order
4045 to extend `find_package` support to include finding the dependencies from an
4046 install of the project.
4047 
4048 ~~~
4049 vtk_module_find_package(
4050  [PRIVATE] [CONFIG_MODE]
4051  PACKAGE <package>
4052  [VERSION <version>]
4053  [COMPONENTS <component>...]
4054  [OPTIONAL_COMPONENTS <component>...]
4055  [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4056  [VERSION_VAR <variable>])
4057 ~~~
4058 
4059  * `PACKAGE`: The name of the package to find.
4060  * `VERSION`: The minimum version of the package that is required.
4061  * `COMPONENTS`: Components of the package which are required.
4062  * `OPTIONAL_COMPONENTS`: Components of the package which may be missing.
4063  * `FORWARD_VERSION_REQ`: If provided, the found version will be promoted to
4064  the minimum version required matching the given version scheme.
4065  * `VERSION_VAR`: The variable to use as the provided version (defaults to
4066  `<PACKAGE>_VERSION`). It may contain `@` in which case it will be
4067  configured. This is useful for modules which only provide components of the
4068  actual version number.
4069  * `CONFIG_MODE`: If present, pass `CONFIG` to the underlying `find_package`
4070  call.
4071  * `PRIVATE`: The dependency should not be exported to the install.
4072 
4073 The `PACKAGE` argument is the only required argument. The rest are optional.
4074 
4075 Note that `PRIVATE` is *only* applicable for private dependencies on interface
4076 targets (basically, header libraries) because some platforms require private
4077 shared libraries dependencies to be present when linking dependent libraries
4078 and executables as well.
4079 #]==]
4080 macro (vtk_module_find_package)
4081  # This needs to be a macro because find modules typically set variables which
4082  # may need to be available in the calling scope. If we declare that it only
4083  # works with imported targets (which is the primary motivating factor behind
4084  # this function), we can instead make it a function at the cost of any
4085  # non-target variables a module might want to set being available. It is
4086  # unlikely that this will be the case for all callers.
4087  if (NOT _vtk_build_module)
4088  message(FATAL_ERROR
4089  "`vtk_module_find_package` may only be called when building a VTK "
4090  "module.")
4091  endif ()
4092 
4093  # Note: when adding arguments here, add them to the `unset` block at the end
4094  # of the function.
4095  cmake_parse_arguments(_vtk_find_package
4096  "PRIVATE;CONFIG_MODE"
4097  "PACKAGE;VERSION;FORWARD_VERSION_REQ;VERSION_VAR"
4098  "COMPONENTS;OPTIONAL_COMPONENTS"
4099  ${ARGN})
4100 
4101  if (_vtk_find_package_UNPARSED_ARGUMENTS)
4102  message(FATAL_ERROR
4103  "Unparsed arguments for vtk_module_find_package: "
4104  "${_vtk_find_package_UNPARSED_ARGUMENTS}")
4105  endif ()
4106 
4107  if (NOT DEFINED _vtk_find_package_PACKAGE)
4108  message(FATAL_ERROR
4109  "The `PACKAGE` argument is required.")
4110  endif ()
4111 
4112  if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4113  if (_vtk_find_package_PRIVATE)
4114  message(FATAL_ERROR
4115  "The `FORWARD_VERSION_REQ` argument is incompatible with the "
4116  "`PRIVATE` flag.")
4117  endif ()
4118 
4119  if (NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR" AND
4120  NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR" AND
4121  NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH" AND
4122  NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4123  message(FATAL_ERROR
4124  "The `FORWARD_VERSION_REQ` argument must be one of `MAJOR`, `MINOR`, "
4125  "`PATCH`, or `EXACT`.")
4126  endif ()
4127  endif ()
4128 
4129  if (NOT DEFINED _vtk_find_package_VERSION_VAR)
4130  set(_vtk_find_package_VERSION_VAR
4131  "${_vtk_find_package_PACKAGE}_VERSION")
4132  endif ()
4133 
4134  set(_vtk_find_package_config)
4135  if (_vtk_find_package_CONFIG_MODE)
4136  set(_vtk_find_package_config "CONFIG")
4137  endif ()
4138 
4139  find_package("${_vtk_find_package_PACKAGE}"
4140  ${_vtk_find_package_VERSION}
4141  ${_vtk_find_package_config}
4142  COMPONENTS ${_vtk_find_package_COMPONENTS}
4143  OPTIONAL_COMPONENTS ${_vtk_find_package_OPTIONAL_COMPONENTS})
4144  if (NOT ${_vtk_find_package_PACKAGE}_FOUND)
4145  message(FATAL_ERROR
4146  "Could not find the ${_vtk_find_package_PACKAGE} external dependency.")
4147  return ()
4148  endif ()
4149 
4150  set(_vtk_find_package_optional_components_found)
4151  foreach (_vtk_find_package_optional_component IN LISTS _vtk_find_package_OPTIONAL_COMPONENTS)
4152  if (${_vtk_find_package_PACKAGE}_${_vtk_find_package_optional_component}_FOUND)
4153  list(APPEND _vtk_find_package_optional_components_found
4154  "${_vtk_find_package_optional_component}")
4155  endif ()
4156  endforeach ()
4157 
4158  if (NOT _vtk_find_package_PRIVATE)
4159  set_property(GLOBAL APPEND
4160  PROPERTY
4161  "_vtk_module_find_packages_${_vtk_build_PACKAGE}" "${_vtk_find_package_PACKAGE}")
4162  set(_vtk_find_package_base "_vtk_module_find_package_${_vtk_build_module}")
4163  set_property(GLOBAL APPEND
4164  PROPERTY
4165  "${_vtk_find_package_base}" "${_vtk_find_package_PACKAGE}")
4166  set(_vtk_find_package_base_package "${_vtk_find_package_base}_${_vtk_find_package_PACKAGE}")
4167  set_property(GLOBAL
4168  PROPERTY
4169  "${_vtk_find_package_base_package}_version" "${_vtk_find_package_VERSION}")
4170  set_property(GLOBAL
4171  PROPERTY
4172  "${_vtk_find_package_base_package}_config" "${_vtk_find_package_CONFIG_MODE}")
4173  set_property(GLOBAL APPEND
4174  PROPERTY
4175  "${_vtk_find_package_base_package}_components" "${_vtk_find_package_COMPONENTS}")
4176  set_property(GLOBAL APPEND
4177  PROPERTY
4178  "${_vtk_find_package_base_package}_optional_components" "${_vtk_find_package_OPTIONAL_COMPONENTS}")
4179  set_property(GLOBAL APPEND
4180  PROPERTY
4181  "${_vtk_find_package_base_package}_optional_components_found" "${_vtk_find_package_optional_components_found}")
4182  set_property(GLOBAL
4183  PROPERTY
4184  "${_vtk_find_package_base_package}_exact" "0")
4185  if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4186  string(FIND "${_vtk_find_package_VERSION_VAR}" "@" _vtk_find_package_idx)
4187  if (_vtk_find_package_idx EQUAL -1)
4188  if (NOT DEFINED "${_vtk_find_package_VERSION_VAR}")
4189  message(FATAL_ERROR
4190  "The `${_vtk_find_package_VERSION_VAR}` variable is not defined.")
4191  endif ()
4192  set(_vtk_find_package_version "${${_vtk_find_package_VERSION_VAR}}")
4193  else ()
4194  string(CONFIGURE "${_vtk_find_package_VERSION_VAR}" _vtk_find_package_version)
4195  endif ()
4196  unset(_vtk_find_package_idx)
4197 
4198  if ("${_vtk_find_package_version}" STREQUAL "")
4199  message(FATAL_ERROR
4200  "The `${_vtk_find_package_PACKAGE}` version is empty.")
4201  endif ()
4202 
4203  if (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR")
4204  set(_vtk_find_package_version_regex "^\([^.]*\).*")
4205  elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR")
4206  set(_vtk_find_package_version_regex "^\([^.]*.[^.]*\).*")
4207  elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH")
4208  set(_vtk_find_package_version_regex "^\([^.]*.[^.]*.[^.]*\).*")
4209  elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4210  set(_vtk_find_package_version_regex "^\\(.*\\)$")
4211  set_property(GLOBAL
4212  PROPERTY
4213  "${_vtk_find_package_base_package}_exact" "1")
4214  endif ()
4215 
4216  string(REGEX REPLACE "${_vtk_find_package_version_regex}" "\\1"
4217  _vtk_find_package_found_version "${_vtk_find_package_version}")
4218  unset(_vtk_find_package_version_regex)
4219  unset(_vtk_find_package_version)
4220 
4221  set_property(GLOBAL
4222  PROPERTY
4223  "${_vtk_find_package_base_package}_version" "${_vtk_find_package_found_version}")
4224  unset(_vtk_find_package_found_version)
4225  endif ()
4226  endif ()
4227 
4228  unset(_vtk_find_package_base)
4229  unset(_vtk_find_package_base_package)
4230  unset(_vtk_find_package_COMPONENTS)
4231  unset(_vtk_find_package_FORWARD_VERSION_REQ)
4232  unset(_vtk_find_package_OPTIONAL_COMPONENTS)
4233  unset(_vtk_find_package_PACKAGE)
4234  unset(_vtk_find_package_PRIVATE)
4235  unset(_vtk_find_package_UNPARSED_ARGUMENTS)
4236  unset(_vtk_find_package_VERSION)
4237  unset(_vtk_find_package_VERSION_VAR)
4238 endmacro ()
4239 
4240 #[==[
4241 @ingroup module
4242 @brief Export find_package calls for dependencies
4243 
4244 When installing a project that is meant to be found via `find_package` from
4245 CMake, using imported targets in the build means that imported targets need to
4246 be created during the `find_package` as well. This function writes a file
4247 suitable for inclusion from a `<package>-config.cmake` file to satisfy
4248 dependencies. It assumes that the exported targets are named
4249 `${CMAKE_FIND_PACKAGE_NAME}::${component}`. Dependent packages will only be
4250 found if a requested component requires the package to be found either directly
4251 or transitively.
4252 
4253 ~~~
4254 vtk_module_export_find_packages(
4255  CMAKE_DESTINATION <directory>
4256  FILE_NAME <filename>
4257  [COMPONENT <component>]
4258  MODULES <module>...)
4259 ~~~
4260 
4261 The file will be named according to the `FILE_NAME` argument will be installed
4262 into `CMAKE_DESTINATION` in the build and install trees with the given
4263 filename. If not provided, the `development` component will be used.
4264 
4265 The `vtk_module_find_package` calls made by the modules listed in `MODULES`
4266 will be exported to this file.
4267 #]==]
4268 function (vtk_module_export_find_packages)
4269  cmake_parse_arguments(_vtk_export
4270  ""
4271  "CMAKE_DESTINATION;FILE_NAME;COMPONENT"
4272  "MODULES"
4273  ${ARGN})
4274 
4275  if (_vtk_export_UNPARSED_ARGUMENTS)
4276  message(FATAL_ERROR
4277  "Unparsed arguments for vtk_module_export_find_packages: "
4278  "${_vtk_export_UNPARSED_ARGUMENTS}")
4279  endif ()
4280 
4281  if (NOT DEFINED _vtk_export_CMAKE_DESTINATION)
4282  message(FATAL_ERROR
4283  "The `CMAKE_DESTINATION` is required.")
4284  endif ()
4285 
4286  if (NOT DEFINED _vtk_export_FILE_NAME)
4287  message(FATAL_ERROR
4288  "The `FILE_NAME` is required.")
4289  endif ()
4290 
4291  if (NOT DEFINED _vtk_export_COMPONENT)
4292  set(_vtk_export_COMPONENT "development")
4293  endif ()
4294 
4295  set(_vtk_export_output_file
4296  "${CMAKE_BINARY_DIR}/${_vtk_export_CMAKE_DESTINATION}/${_vtk_export_FILE_NAME}")
4297  file(WRITE "${_vtk_export_output_file}"
4298 "set(_vtk_module_find_package_quiet)
4299 if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4300  set(_vtk_module_find_package_quiet QUIET)
4301 endif ()
4302 
4303 set(_vtk_module_find_package_components_checked)
4304 set(_vtk_module_find_package_components_to_check
4305  \${\${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
4306 set(_vtk_module_find_package_components)
4307 set(_vtk_module_find_package_components_required)
4308 while (_vtk_module_find_package_components_to_check)
4309  list(GET _vtk_module_find_package_components_to_check 0 _vtk_module_component)
4310  list(REMOVE_AT _vtk_module_find_package_components_to_check 0)
4311  if (_vtk_module_component IN_LIST _vtk_module_find_package_components_checked)
4312  continue ()
4313  endif ()
4314  list(APPEND _vtk_module_find_package_components_checked
4315  \"\${_vtk_module_component}\")
4316 
4317  list(APPEND _vtk_module_find_package_components
4318  \"\${_vtk_module_component}\")
4319  if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_\${_vtk_module_component})
4320  list(APPEND _vtk_module_find_package_components_required
4321  \"\${_vtk_module_component}\")
4322  endif ()
4323 
4324  if (TARGET \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4325  set(_vtk_module_find_package_component_target \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4326  elseif (TARGET \"\${_vtk_module_component}\")
4327  set(_vtk_module_find_package_component_target \"\${_vtk_module_component}\")
4328  else ()
4329  # No such target for the component; skip.
4330  continue ()
4331  endif ()
4332  get_property(_vtk_module_find_package_depends
4333  TARGET \"\${_vtk_module_find_package_component_target}\"
4334  PROPERTY \"INTERFACE_vtk_module_depends\")
4335  string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4336  list(APPEND _vtk_module_find_package_components_to_check
4337  \${_vtk_module_find_package_depends})
4338  get_property(_vtk_module_find_package_depends
4339  TARGET \"\${_vtk_module_find_package_component_target}\"
4340  PROPERTY \"INTERFACE_vtk_module_private_depends\")
4341  string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4342  list(APPEND _vtk_module_find_package_components_to_check
4343  \${_vtk_module_find_package_depends})
4344  get_property(_vtk_module_find_package_depends
4345  TARGET \"\${_vtk_module_find_package_component_target}\"
4346  PROPERTY \"INTERFACE_vtk_module_optional_depends\")
4347  foreach (_vtk_module_find_package_depend IN LISTS _vtk_module_find_package_depends)
4348  if (TARGET \"\${_vtk_module_find_package_depend}\")
4349  string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depend \"\${_vtk_module_find_package_depend}\")
4350  list(APPEND _vtk_module_find_package_components_to_check
4351  \"\${_vtk_module_find_package_depend}\")
4352  endif ()
4353  endforeach ()
4354  get_property(_vtk_module_find_package_depends
4355  TARGET \"\${_vtk_module_find_package_component_target}\"
4356  PROPERTY \"INTERFACE_vtk_module_forward_link\")
4357  string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4358  list(APPEND _vtk_module_find_package_components_to_check
4359  \${_vtk_module_find_package_depends})
4360 
4361  get_property(_vtk_module_find_package_kit
4362  TARGET \"\${_vtk_module_find_package_component_target}\"
4363  PROPERTY \"INTERFACE_vtk_module_kit\")
4364  if (_vtk_module_find_package_kit)
4365  get_property(_vtk_module_find_package_kit_modules
4366  TARGET \"\${_vtk_module_find_package_kit}\"
4367  PROPERTY \"INTERFACE_vtk_kit_kit_modules\")
4368  string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_kit_modules \"\${_vtk_module_find_package_kit_modules}\")
4369  list(APPEND _vtk_module_find_package_components_to_check
4370  \${_vtk_module_find_package_kit_modules})
4371  endif ()
4372 endwhile ()
4373 unset(_vtk_module_find_package_component_target)
4374 unset(_vtk_module_find_package_components_to_check)
4375 unset(_vtk_module_find_package_components_checked)
4376 unset(_vtk_module_component)
4377 unset(_vtk_module_find_package_depend)
4378 unset(_vtk_module_find_package_depends)
4379 unset(_vtk_module_find_package_kit)
4380 unset(_vtk_module_find_package_kit_modules)
4381 
4382 if (_vtk_module_find_package_components)
4383  list(REMOVE_DUPLICATES _vtk_module_find_package_components)
4384 endif ()
4385 if (_vtk_module_find_package_components_required)
4386  list(REMOVE_DUPLICATES _vtk_module_find_package_components_required)
4387 endif ()\n\n")
4388 
4389  foreach (_vtk_export_module IN LISTS _vtk_export_MODULES)
4390  get_property(_vtk_export_target_name GLOBAL
4391  PROPERTY "_vtk_module_${_vtk_export_module}_target_name")
4392  set(_vtk_export_base "_vtk_module_find_package_${_vtk_export_module}")
4393  get_property(_vtk_export_packages GLOBAL
4394  PROPERTY "${_vtk_export_base}")
4395  if (NOT _vtk_export_packages)
4396  continue ()
4397  endif ()
4398 
4399  file(APPEND "${_vtk_export_output_file}"
4400 "set(_vtk_module_find_package_enabled OFF)
4401 set(_vtk_module_find_package_is_required OFF)
4402 set(_vtk_module_find_package_fail_if_not_found OFF)
4403 if (_vtk_module_find_package_components)
4404  if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components)
4405  set(_vtk_module_find_package_enabled ON)
4406  if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components_required)
4407  set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4408  set(_vtk_module_find_package_fail_if_not_found ON)
4409  endif ()
4410  endif ()
4411 else ()
4412  set(_vtk_module_find_package_enabled ON)
4413  set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4414  set(_vtk_module_find_package_fail_if_not_found ON)
4415 endif ()
4416 
4417 if (_vtk_module_find_package_enabled)
4418  set(_vtk_module_find_package_required)
4419  if (_vtk_module_find_package_is_required)
4420  set(_vtk_module_find_package_required REQUIRED)
4421  endif ()\n\n")
4422 
4423  list(REMOVE_DUPLICATES _vtk_export_packages)
4424  foreach (_vtk_export_package IN LISTS _vtk_export_packages)
4425  set(_vtk_export_base_package "${_vtk_export_base}_${_vtk_export_package}")
4426  get_property(_vtk_export_version GLOBAL
4427  PROPERTY "${_vtk_export_base_package}_version")
4428  get_property(_vtk_export_config GLOBAL
4429  PROPERTY "${_vtk_export_base_package}_config")
4430  get_property(_vtk_export_exact GLOBAL
4431  PROPERTY "${_vtk_export_base_package}_exact")
4432  get_property(_vtk_export_components GLOBAL
4433  PROPERTY "${_vtk_export_base_package}_components")
4434  get_property(_vtk_export_optional_components GLOBAL
4435  PROPERTY "${_vtk_export_base_package}_optional_components")
4436  get_property(_vtk_export_optional_components_found GLOBAL
4437  PROPERTY "${_vtk_export_base_package}_optional_components_found")
4438 
4439  # Assume that any found optional components end up being required.
4440  if (${_vtk_export_base_package}_optional_components_found)
4441  list(REMOVE_ITEM _vtk_export_optional_components
4442  ${_vtk_export_optional_components_found})
4443  list(APPEND _vtk_export_components
4444  ${_vtk_export_optional_components_found})
4445  endif ()
4446 
4447  set(_vtk_export_config_arg)
4448  if (_vtk_export_config)
4449  set(_vtk_export_config_arg CONFIG)
4450  endif ()
4451 
4452  set(_vtk_export_exact_arg)
4453  if (_vtk_export_exact)
4454  set(_vtk_export_exact_arg EXACT)
4455  endif ()
4456 
4457  file(APPEND "${_vtk_export_output_file}"
4458 " find_package(${_vtk_export_package}
4459  ${_vtk_export_version}
4460  ${_vtk_export_exact_arg}
4461  ${_vtk_export_config_arg}
4462  \${_vtk_module_find_package_quiet}
4463  \${_vtk_module_find_package_required}
4464  COMPONENTS ${_vtk_export_components}
4465  OPTIONAL_COMPONENTS ${_vtk_export_optional_components})
4466  if (NOT ${_vtk_export_package}_FOUND AND _vtk_module_find_package_fail_if_not_found)
4467  if (NOT \${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4468  message(STATUS
4469  \"Could not find the \${CMAKE_FIND_PACKAGE_NAME} package due to a \"
4470  \"missing dependency: ${_vtk_export_package}\")
4471  endif ()
4472  set(\"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_FOUND\" 0)
4473  list(APPEND \"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_NOT_FOUND_MESSAGE\"
4474  \"Failed to find the ${_vtk_export_package} package.\")
4475  endif ()\n")
4476  endforeach ()
4477 
4478  file(APPEND "${_vtk_export_output_file}"
4479 "endif ()
4480 
4481 unset(_vtk_module_find_package_fail_if_not_found)
4482 unset(_vtk_module_find_package_enabled)
4483 unset(_vtk_module_find_package_required)\n\n")
4484 
4485  endforeach ()
4486 
4487  file(APPEND "${_vtk_export_output_file}"
4488  "unset(_vtk_module_find_package_components)
4489 unset(_vtk_module_find_package_components_required)
4490 unset(_vtk_module_find_package_quiet)\n")
4491 
4492  install(
4493  FILES "${CMAKE_BINARY_DIR}/${_vtk_export_CMAKE_DESTINATION}/${_vtk_export_FILE_NAME}"
4494  DESTINATION "${_vtk_export_CMAKE_DESTINATION}"
4495  COMPONENT "${_vtk_export_COMPONENT}")
4496 endfunction ()
4497 
4498 #[==[
4499 @page module-overview
4500 
4501 @ingroup module
4502 @section module-third-party Third party support
4503 
4504 The module system acknowledges that third party support is a pain and offers
4505 APIs to help wrangle them. Sometimes third party code needs a shim introduced
4506 to make it behave better, so an `INTERFACE` library to add that in is very
4507 useful. Other times, third party code is hard to ensure that it exists
4508 everywhere, so it is bundled. When that happens, the ability to select between
4509 the bundled copy and an external copy is useful. All three (and more) of these
4510 are possible.
4511 
4512 The following functions are used to handle third party modules:
4513 
4514  - @ref vtk_module_third_party
4515  - @ref vtk_module_third_party_external
4516  - @ref vtk_module_third_party_internal
4517 #]==]
4518 
4519 #[==[
4520 @ingroup module
4521 @brief Third party module
4522 
4523 When a project has modules which represent third party packages, there are some
4524 convenience functions to help deal with them. First, there is the meta-wrapper:
4525 
4526 ~~~
4527 vtk_module_third_party(
4528  [INTERNAL <internal arguments>...]
4529  [EXTERNAL <external arguments>...])
4530 ~~~
4531 
4532 This offers a cache variable named `VTK_MODULE_USE_EXTERNAL_<module name>` that
4533 may be set to trigger between the internal copy and an externally provided
4534 copy. This is available as a local variable named
4535 `VTK_MODULE_USE_EXTERNAL_<library name>`. See the
4536 @ref vtk_module_third_party_external and @ref vtk_module_third_party_internal
4537 functions for the arguments supported by the `EXTERNAL` and `INTERNAL`
4538 arguments, respectively.
4539 #]==]
4540 function (vtk_module_third_party)
4541  cmake_parse_arguments(_vtk_third_party
4542  ""
4543  ""
4544  "INTERNAL;EXTERNAL"
4545  ${ARGN})
4546 
4547  if (_vtk_third_party_UNPARSED_ARGUMENTS)
4548  message(FATAL_ERROR
4549  "Unparsed arguments for vtk_module_third_party: "
4550  "${_vtk_third_party_UNPARSED_ARGUMENTS}")
4551  endif ()
4552 
4553  string(REPLACE "::" "_" _vtk_build_module_safe "${_vtk_build_module}")
4554  option("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}"
4555  "Use externally provided ${_vtk_build_module}"
4556  "${_vtk_build_USE_EXTERNAL}")
4557  mark_as_advanced("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}")
4558  get_property(_vtk_third_party_library_name GLOBAL
4559  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
4560  set("VTK_MODULE_USE_EXTERNAL_${_vtk_third_party_library_name}"
4561  "${VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}}"
4562  PARENT_SCOPE)
4563 
4564  if (VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe})
4565  # XXX(cmake): https://gitlab.kitware.com/cmake/cmake/issues/16364.
4566  # Unset a variable which CMake doesn't like when switching between real
4567  # libraries (internal) and interface libraries (external).
4568  unset("${_vtk_build_module}_LIB_DEPENDS" CACHE)
4569  vtk_module_third_party_external(${_vtk_third_party_EXTERNAL})
4570 
4571  # Bubble up variables again.
4572  foreach (_vtk_third_party_variable IN LISTS _vtk_third_party_variables)
4573  set("${_vtk_third_party_variable}"
4574  "${${_vtk_third_party_variable}}"
4575  PARENT_SCOPE)
4576  endforeach ()
4577  else ()
4578  set(_vtk_third_party_has_external_support 1)
4579  vtk_module_third_party_internal(${_vtk_third_party_INTERNAL})
4580  endif ()
4581 endfunction ()
4582 
4583 #[==[
4584 @ingroup module-impl
4585 @brief Mark a module as being third party
4586 
4587 Mark a module as being a third party module.
4588 
4589 ~~~
4591 ~~~
4592 #]==]
4594  # TODO: `_vtk_module_set_module_property` instead.
4595  set_target_properties("${target}"
4596  PROPERTIES
4597  "INTERFACE_vtk_module_exclude_wrap" 1
4598  "INTERFACE_vtk_module_third_party" 1)
4599 endfunction ()
4600 
4601 #[==[
4602 @ingroup module
4603 @brief External third party package
4604 
4605 A third party dependency may be expressed as a module using this function.
4606 Third party packages are found using CMake's `find_package` function. It is
4607 highly recommended that imported targets are used to make usage easier. The
4608 module itself will be created as an `INTERFACE` library which exposes the
4609 package.
4610 
4611 ~~~
4612 vtk_module_third_party_external(
4613  PACKAGE <package>
4614  [VERSION <version>]
4615  [COMPONENTS <component>...]
4616  [OPTIONAL_COMPONENTS <component>...]
4617  [INCLUDE_DIRS <path-or-variable>...]
4618  [LIBRARIES <target-or-variable>...]
4619  [DEFINITIONS <variable>...]
4620  [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4621  [VERSION_VAR <version-spec>]
4622  [USE_VARIABLES <variable>...]
4623  [CONFIG_MODE]
4624  [STANDARD_INCLUDE_DIRS])
4625 ~~~
4626 
4627 Only the `PACKAGE` argument is required. The arguments are as follows:
4628 
4629  * `PACKAGE`: (Required) The name of the package to find.
4630  * `VERSION`: If specified, the minimum version of the dependency that must be
4631  found.
4632  * `COMPONENTS`: The list of components to request from the package.
4633  * `OPTIONAL_COMPONENTS`: The list of optional components to request from the
4634  package.
4635  * `STANDARD_INCLUDE_DIRS`: If present, standard include directories will be
4636  added to the module target. This is usually only required if both internal
4637  and external are supported for a given dependency.
4638  * `INCLUDE_DIRS`: If specified, this is added as a `SYSTEM INTERFACE` include
4639  directory for the target. If a variable name is given, it will be
4640  dereferenced.
4641  * `LIBRARIES`: The libraries to link from the package. If a variable name is
4642  given, it will be dereferenced, however a warning that imported targets are
4643  not being used will be emitted.
4644  * `DEFINITIONS`: If specified, the given variables will be added to the
4645  target compile definitions interface.
4646  * `CONFIG_MODE`: Force `CONFIG` mode.
4647  * `FORWARD_VERSION_REQ` and `VERSION_VAR`: See documentation for
4648  @ref vtk_module_find_package.
4649  * `USE_VARIABLES`: List of variables from the `find_package` to make
4650  available to the caller.
4651 #]==]
4652 function (vtk_module_third_party_external)
4653  cmake_parse_arguments(_vtk_third_party_external
4654  "STANDARD_INCLUDE_DIRS;CONFIG_MODE"
4655  "VERSION;PACKAGE;FORWARD_VERSION_REQ;VERSION_VAR"
4656  "COMPONENTS;OPTIONAL_COMPONENTS;LIBRARIES;INCLUDE_DIRS;DEFINITIONS;TARGETS;USE_VARIABLES"
4657  ${ARGN})
4658 
4659  if (_vtk_third_party_external_UNPARSED_ARGUMENTS)
4660  message(FATAL_ERROR
4661  "Unparsed arguments for vtk_module_third_party_external: "
4662  "${_vtk_third_party_external_UNPARSED_ARGUMENTS}")
4663  endif ()
4664 
4665  get_property(_vtk_third_party_external_is_third_party GLOBAL
4666  PROPERTY "_vtk_module_${_vtk_build_module}_third_party")
4667  if (NOT _vtk_third_party_external_is_third_party)
4668  message(FATAL_ERROR
4669  "The ${_vtk_build_module} has not been declared as a third party "
4670  "module.")
4671  endif ()
4672 
4673  if (NOT DEFINED _vtk_third_party_external_PACKAGE)
4674  message(FATAL_ERROR
4675  "The `PACKAGE` argument is required.")
4676  endif ()
4677 
4678  set(_vtk_third_party_external_args)
4679  if (DEFINED _vtk_third_party_external_FORWARD_VERSION_REQ)
4680  list(APPEND _vtk_third_party_external_args
4681  FORWARD_VERSION_REQ "${_vtk_third_party_external_FORWARD_VERSION_REQ}")
4682  endif ()
4683  if (DEFINED _vtk_third_party_external_VERSION_VAR)
4684  list(APPEND _vtk_third_party_external_args
4685  VERSION_VAR "${_vtk_third_party_external_VERSION_VAR}")
4686  endif ()
4687 
4688  if (_vtk_third_party_external_TARGETS)
4689  set(_vtk_third_party_external_config_mode)
4690  if (_vtk_third_party_external_CONFIG_MODE)
4691  set(_vtk_third_party_external_config_mode "CONFIG_MODE")
4692  endif ()
4693 
4694  # If we have targets, they must be exported to the install as well.
4695  vtk_module_find_package(
4696  PACKAGE "${_vtk_third_party_external_PACKAGE}"
4697  VERSION "${_vtk_third_party_external_VERSION}"
4698  COMPONENTS ${_vtk_third_party_external_COMPONENTS}
4699  OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS}
4700  ${_vtk_third_party_external_config_mode}
4701  ${_vtk_third_party_external_args})
4702  else ()
4703  set(_vtk_third_party_external_config)
4704  if (_vtk_third_party_external_CONFIG_MODE)
4705  set(_vtk_third_party_external_config "CONFIG")
4706  endif ()
4707 
4708  # If there are no targets, the install uses strings and therefore does not
4709  # need to find the dependency again.
4710  find_package("${_vtk_third_party_external_PACKAGE}"
4711  ${_vtk_third_party_external_VERSION}
4712  ${_vtk_third_party_external_config}
4713  COMPONENTS ${_vtk_third_party_external_COMPONENTS}
4714  OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS})
4715  endif ()
4716 
4717  get_property(_vtk_third_party_external_target_name GLOBAL
4718  PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
4719 
4720  # Check if an imported target of the same name already exists.
4721  set(_vtk_third_party_external_real_target_name
4722  "${_vtk_third_party_external_target_name}")
4723  set(_vtk_third_party_external_using_mangled_name OFF)
4724  if (TARGET "${_vtk_third_party_external_target_name}")
4725  # Ensure that the target collision comes from an imported target.
4726  get_property(_vtk_third_party_external_is_imported
4727  TARGET "${_vtk_third_party_external_target_name}"
4728  PROPERTY IMPORTED)
4729  if (NOT _vtk_third_party_external_is_imported)
4730  message(FATAL_ERROR
4731  "It appears as though there is a conflicting target named "
4732  "`${_vtk_third_party_external_target_name}` expected to be used by "
4733  "the `${_vtk_build_module}` module already added to the build. This "
4734  "conflicts with the target name expected to be used by an external "
4735  "third party dependency.")
4736  endif ()
4737 
4738  # If it does, we need to have a module name that is not the same as this
4739  # one. Error out if this is detected.
4740  if (_vtk_build_module STREQUAL _vtk_third_party_external_target_name)
4741  message(FATAL_ERROR
4742  "An imported target has the same name used by the module system for "
4743  "the facade of the external dependency for `${_vtk_build_module}`. "
4744  "This module must be either renamed or placed into a namespace.")
4745  endif ()
4746 
4747  # Mangle the internal name. The alias is the expected use case anyways and
4748  # since this is an INTERFACE target, there's nothing to break with respect
4749  # to `make $target` anyways.
4750  string(APPEND _vtk_third_party_external_real_target_name
4751  "_vtk_module_mangle")
4752  set_property(GLOBAL APPEND_STRING
4753  PROPERTY "_vtk_module_${_vtk_build_module}_target_name"
4754  "_vtk_module_mangle")
4755  set(_vtk_third_party_external_using_mangled_name ON)
4756  endif ()
4757 
4758  add_library("${_vtk_third_party_external_real_target_name}" INTERFACE)
4759  if (_vtk_third_party_external_using_mangled_name)
4760  set_property(TARGET "${_vtk_third_party_external_real_target_name}"
4761  PROPERTY
4762  EXPORT_NAME "${_vtk_third_party_external_target_name}")
4763  endif ()
4764  if (NOT _vtk_build_module STREQUAL _vtk_third_party_external_target_name)
4765  add_library("${_vtk_build_module}" ALIAS
4766  "${_vtk_third_party_external_real_target_name}")
4767  endif ()
4768 
4769  if (_vtk_third_party_external_STANDARD_INCLUDE_DIRS)
4770  _vtk_module_standard_includes(TARGET "${_vtk_third_party_external_real_target_name}"
4771  SYSTEM INTERFACE)
4772  endif ()
4773 
4774  # Try to use targets if they're specified and available.
4775  set(_vtk_third_party_external_have_targets FALSE)
4776  set(_vtk_third_party_external_used_targets FALSE)
4777  if (_vtk_third_party_external_TARGETS)
4778  set(_vtk_third_party_external_have_targets TRUE)
4779  set(_vtk_third_party_external_all_targets_okay TRUE)
4780  foreach (_vtk_third_party_external_target IN LISTS _vtk_third_party_external_TARGETS)
4781  if (NOT TARGET "${_vtk_third_party_external_target}")
4782  set(_vtk_third_party_external_all_targets_okay FALSE)
4783  break ()
4784  endif ()
4785  endforeach ()
4786 
4787  if (_vtk_third_party_external_all_targets_okay)
4788  target_link_libraries("${_vtk_third_party_external_real_target_name}"
4789  INTERFACE
4790  ${_vtk_third_party_external_TARGETS})
4791  set(_vtk_third_party_external_used_targets TRUE)
4792  endif ()
4793  endif ()
4794 
4795  if (NOT _vtk_third_party_external_used_targets)
4796  if (NOT _vtk_third_party_external_have_targets)
4797  message(WARNING
4798  "A third party dependency for ${_vtk_build_module} was found externally "
4799  "using paths rather than targets; it is recommended to use imported "
4800  "targets rather than find_library and such.")
4801  endif ()
4802 
4803  set(_vtk_third_party_external_have_includes FALSE)
4804  foreach (_vtk_third_party_external_include_dir IN LISTS _vtk_third_party_external_INCLUDE_DIRS)
4805  if (DEFINED "${_vtk_third_party_external_include_dir}")
4806  if (${_vtk_third_party_external_include_dir})
4807  set(_vtk_third_party_external_have_includes TRUE)
4808  endif ()
4809  target_include_directories("${_vtk_third_party_external_real_target_name}" SYSTEM
4810  INTERFACE "${${_vtk_third_party_external_include_dir}}")
4811  endif ()
4812  endforeach ()
4813 
4814  if (_vtk_third_party_external_have_targets AND
4815  NOT _vtk_third_party_external_have_includes)
4816  message(WARNING
4817  "A third party dependency for ${_vtk_build_module} has external targets "
4818  "which were not found and no `INCLUDE_DIRS` were found either. "
4819  "Including this module may not work.")
4820  endif ()
4821 
4822  foreach (_vtk_third_party_external_define IN LISTS _vtk_third_party_external_DEFINITIONS)
4823  if (DEFINED "${_vtk_third_party_external_define}")
4824  target_compile_definitions("${_vtk_third_party_external_real_target_name}"
4825  INTERFACE "${${_vtk_third_party_external_define}}")
4826  endif ()
4827  endforeach ()
4828 
4829  set(_vtk_third_party_external_have_libraries FALSE)
4830  foreach (_vtk_third_party_external_library IN LISTS _vtk_third_party_external_LIBRARIES)
4831  if (DEFINED "${_vtk_third_party_external_library}")
4832  if (${_vtk_third_party_external_library})
4833  set(_vtk_third_party_external_have_libraries TRUE)
4834  endif ()
4835  target_link_libraries("${_vtk_third_party_external_real_target_name}"
4836  INTERFACE "${${_vtk_third_party_external_library}}")
4837  endif ()
4838  endforeach ()
4839 
4840  if (_vtk_third_party_external_have_targets AND
4841  NOT _vtk_third_party_external_have_libraries)
4842  message(WARNING
4843  "A third party dependency for ${_vtk_build_module} has external targets "
4844  "which were not found and no `LIBRARIES` were found either. Linking to "
4845  "this this module may not work.")
4846  endif ()
4847  endif ()
4848 
4849  if (DEFINED _vtk_third_party_external_USE_VARIABLES)
4850  # If we're called from `vtk_module_third_party`, the variables need bubbled
4851  # up again.
4852  if (DEFINED _vtk_third_party_EXTERNAL)
4853  set(_vtk_third_party_variables
4854  "${_vtk_third_party_external_USE_VARIABLES}"
4855  PARENT_SCOPE)
4856  endif ()
4857 
4858  foreach (_vtk_third_party_external_variable IN LISTS _vtk_third_party_external_USE_VARIABLES)
4859  if (NOT DEFINED "${_vtk_third_party_external_variable}")
4860  message(FATAL_ERROR
4861  "The variable `${_vtk_third_party_external_variable}` was expected "
4862  "to have been available, but was not defined.")
4863  endif ()
4864 
4865  set("${_vtk_third_party_external_variable}"
4866  "${${_vtk_third_party_external_variable}}"
4867  PARENT_SCOPE)
4868  endforeach ()
4869  endif ()
4870 
4871  _vtk_module_mark_third_party("${_vtk_third_party_external_real_target_name}")
4872  _vtk_module_install("${_vtk_third_party_external_real_target_name}")
4873 endfunction ()
4874 
4875 #[==[
4876 @ingroup module
4877 @brief Internal third party package
4878 
4879 Third party modules may also be bundled with the project itself. In this case,
4880 it is an internal third party dependency. The dependency is assumed to be in a
4881 subdirectory that will be used via `add_subdirectory`. Unless it is marked as
4882 `HEADERS_ONLY`, it is assumed that it will create a target with the name of the
4883 module.
4884 
4885 ~~~
4886 vtk_module_third_party_internal(
4887  [SUBDIRECTORY <path>]
4888  [HEADERS_SUBDIR <subdir>]
4889  [LICENSE_FILES <file>...]
4890  [VERSION <version>]
4891  [HEADER_ONLY]
4892  [INTERFACE]
4893  [STANDARD_INCLUDE_DIRS])
4894 ~~~
4895 
4896 All arguments are optional, however warnings are emitted if `LICENSE_FILES` or
4897 `VERSION` is not specified. They are as follows:
4898 
4899  * `SUBDIRECTORY`: (Defaults to the library name of the module) The
4900  subdirectory containing the `CMakeLists.txt` for the dependency.
4901  * `HEADERS_SUBDIR`: If non-empty, the subdirectory to use for installing
4902  headers.
4903  * `LICENSE_FILES`: A list of license files to install for the dependency. If
4904  not given, a warning will be emitted.
4905  * `VERSION`: The version of the library that is included.
4906  * `HEADER_ONLY`: The dependency is header only and will not create a target.
4907  * `INTERFACE`: The dependency is an `INTERFACE` library.
4908  * `STANDARD_INCLUDE_DIRS`: If present, module-standard include directories
4909  will be added to the module target.
4910 #]==]
4911 function (vtk_module_third_party_internal)
4912  # TODO: Support scanning for third-party modules which don't support an
4913  # external copy.
4914 
4915  cmake_parse_arguments(_vtk_third_party_internal
4916  "INTERFACE;HEADER_ONLY;STANDARD_INCLUDE_DIRS"
4917  "SUBDIRECTORY;HEADERS_SUBDIR;VERSION"
4918  "LICENSE_FILES"
4919  ${ARGN})
4920 
4921  if (_vtk_third_party_internal_UNPARSED_ARGUMENTS)
4922  message(FATAL_ERROR
4923  "Unparsed arguments for vtk_module_third_party_internal: "
4924  "${_vtk_third_party_internal_UNPARSED_ARGUMENTS}")
4925  endif ()
4926 
4927  get_property(_vtk_third_party_internal_is_third_party GLOBAL
4928  PROPERTY "_vtk_module_${_vtk_build_module}_third_party")
4929  if (NOT _vtk_third_party_internal_is_third_party)
4930  message(FATAL_ERROR
4931  "The ${_vtk_build_module} has not been declared as a third party "
4932  "module.")
4933  endif ()
4934 
4935  get_property(_vtk_third_party_internal_library_name GLOBAL
4936  PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
4937  if (NOT DEFINED _vtk_third_party_internal_SUBDIRECTORY)
4938  set(_vtk_third_party_internal_SUBDIRECTORY "${_vtk_third_party_internal_library_name}")
4939  endif ()
4940 
4941  if (NOT DEFINED _vtk_third_party_internal_LICENSE_FILES)
4942  message(WARNING
4943  "The ${_vtk_build_module} third party package is embedded, but does not "
4944  "specify any license files.")
4945  endif ()
4946 
4947  if (NOT DEFINED _vtk_third_party_internal_VERSION)
4948  message(WARNING
4949  "The ${_vtk_build_module} third party package is embedded, but does not "
4950  "specify the version it is based on.")
4951  endif ()
4952 
4953  get_property(_vtk_third_party_internal_target_name GLOBAL
4954  PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
4955  set(_vtk_third_party_internal_include_type)
4956  if (_vtk_third_party_internal_INTERFACE)
4957  set(_vtk_third_party_internal_include_type INTERFACE)
4958  elseif (_vtk_third_party_internal_HEADER_ONLY)
4959  add_library("${_vtk_third_party_internal_target_name}" INTERFACE)
4960  if (NOT _vtk_build_module STREQUAL _vtk_third_party_internal_target_name)
4961  add_library("${_vtk_build_module}" ALIAS
4962  "${_vtk_third_party_internal_target_name}")
4963  endif ()
4964  set(_vtk_third_party_internal_include_type INTERFACE)
4965  set(_vtk_third_party_internal_STANDARD_INCLUDE_DIRS 1)
4966  endif ()
4967 
4968  add_subdirectory("${_vtk_third_party_internal_SUBDIRECTORY}")
4969 
4970  if (NOT TARGET "${_vtk_build_module}")
4971  message(FATAL_ERROR
4972  "The ${_vtk_build_module} is being built as an internal third party "
4973  "library, but a matching target was not created.")
4974  endif ()
4975 
4976  if (_vtk_third_party_internal_STANDARD_INCLUDE_DIRS)
4977  _vtk_module_standard_includes(
4978  TARGET "${_vtk_third_party_internal_target_name}"
4979  SYSTEM ${_vtk_third_party_internal_include_type}
4980  HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}/${_vtk_third_party_internal_HEADERS_SUBDIR}")
4981  endif ()
4982 
4983  _vtk_module_apply_properties("${_vtk_third_party_internal_target_name}")
4984  if (_vtk_third_party_internal_INTERFACE)
4985  # Nothing.
4986  elseif (_vtk_third_party_internal_HEADER_ONLY)
4987  _vtk_module_install("${_vtk_third_party_internal_target_name}")
4988  endif ()
4989 
4990  if (_vtk_third_party_internal_LICENSE_FILES)
4991  install(
4992  FILES ${_vtk_third_party_internal_LICENSE_FILES}
4993  DESTINATION "${_vtk_build_LICENSE_DESTINATION}/${_vtk_third_party_internal_library_name}/"
4994  COMPONENT "license")
4995  endif ()
4996 
4997  _vtk_module_mark_third_party("${_vtk_third_party_internal_target_name}")
4998 endfunction ()
_vtk_module_debug
function _vtk_module_debug(domain, format)
Conditionally output debug statements.
Definition: vtkModule.cmake:57
VTK_MODULE_AUTOINIT
#define VTK_MODULE_AUTOINIT
Definition: vtkAutoInit.h:21
vtk_module_link_options
function vtk_module_link_options(module)
Add link options to a module.
Definition: vtkModule.cmake:1587
_vtk_module_export_properties
function _vtk_module_export_properties()
Export properties on modules and targets.
Definition: vtkModule.cmake:1921
global
Definition: UnstructuredGhostZonesCommon.h:30
vtkX3D::component
@ component
Definition: vtkX3D.h:181
vtk_module_compile_features
function vtk_module_compile_features(module)
Add compile features to a module.
Definition: vtkModule.cmake:1488
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkX3D::language
@ language
Definition: vtkX3D.h:396
vtkX3D::time
@ time
Definition: vtkX3D.h:503
_vtk_module_real_target
function _vtk_module_real_target(var, module)
The real target for a module.
Definition: vtkModule.cmake:1093
vtkX3D::on
@ on
Definition: vtkX3D.h:445
vtk_module_install_headers
function vtk_module_install_headers()
Install headers.
Definition: vtkModule.cmake:3716
vtkX3D::level
@ level
Definition: vtkX3D.h:401
target
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:965
_vtk_module_set_module_property
function _vtk_module_set_module_property(module)
Set a module property.
Definition: vtkModule.cmake:1689
vtk_module_compile_options
function vtk_module_compile_options(module)
Add compile options to a module.
Definition: vtkModule.cmake:1453
vtk_module_link
function vtk_module_link(module)
Add link libraries to a module.
Definition: vtkModule.cmake:1525
vtk_module_set_property
function vtk_module_set_property(module)
Set a property on a module.
Definition: vtkModule.cmake:1221
vtk_module_definitions
function vtk_module_definitions(module)
Add compile definitions to a module.
Definition: vtkModule.cmake:1418
vtk_module_build
function vtk_module_build()
Build modules and kits.
Definition: vtkModule.cmake:2154
vtk_module_third_party_external
function vtk_module_third_party_external()
External third party package.
Definition: vtkModule.cmake:4652
vtkX3D::enabled
@ enabled
Definition: vtkX3D.h:265
vtkX3D::name
@ name
Definition: vtkX3D.h:225
_vtk_module_real_target_kit
function _vtk_module_real_target_kit(var, kit)
The real target for a kit.
Definition: vtkModule.cmake:1158
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtk_module_get_property
function vtk_module_get_property(module)
Get a property from a module.
Definition: vtkModule.cmake:1282
vtk_module_third_party_internal
function vtk_module_third_party_internal()
Internal third party package.
Definition: vtkModule.cmake:4911
vtk_module_autoinit
function vtk_module_autoinit()
Linking to autoinit-using modules.
Definition: vtkModule.cmake:2828
impl
Definition: TestMotionFXCFGReaderCommon.h:36
vtkX3D::description
@ description
Definition: vtkX3D.h:328
vtk
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
Definition: vtkAtomicTypeConcepts.h:21
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
vtk_module_include
function vtk_module_include(module)
Add include directories to a module.
Definition: vtkModule.cmake:1377
_vtk_module_mark_third_party
function _vtk_module_mark_third_party(target)
Mark a module as being third party.
Definition: vtkModule.cmake:4593
_vtk_module_apply_properties
function _vtk_module_apply_properties(target)
Apply properties to a module.
Definition: vtkModule.cmake:3778
vtk_module_add_module
function vtk_module_add_module(name)
Create a module library.
Definition: vtkModule.cmake:3176
vtk_module_scan
function vtk_module_scan()
Scan modules and kits.
Definition: vtkModule.cmake:525