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
10 @page module-api-overview Module API
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.
17 All functions strictly check their arguments. Any unrecognized or invalid
18 values
for a
function cause errors to be raised.
22 @ingroup module-
internal
23 @page module-
internal-api Internal API
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.
33 @page module-
impl-api Implementation API
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.
41 @ingroup module-
internal
42 @brief Conditionally output debug statements
45 controlled by the `_vtk_module_log` variable which contains a list of
"domains"
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.
58 if (NOT _vtk_module_log STREQUAL
"ALL" AND
59 NOT domain IN_LIST _vtk_module_log)
63 string(CONFIGURE "${format}
" _vtk_module_debug_msg)
64 if (_vtk_module_debug_msg)
66 "VTK module debug ${domain}: ${_vtk_module_debug_msg}
")
70 # TODO: Support finding `vtk.module` and `vtk.kit` contents in the
71 # `CMakeLists.txt` files for the module via a comment header.
75 @brief Find `vtk.kit` files in a set of directories
78 vtk_module_find_kits(<output> [<directory>...])
81 This scans the given directories recursively for `vtk.kit` files and put the
82 paths into the output variable.
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})
92 set("${output}
" ${_vtk_find_kits_all} PARENT_SCOPE)
97 @brief Find `vtk.module` files in a set of directories
100 vtk_module_find_modules(<output> [<directory>...])
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.
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})
115 set("${output}
" ${_vtk_find_modules_all} PARENT_SCOPE)
119 @ingroup module-internal
120 @brief Split a module name into a namespace and target component
122 Module names may include a namespace. This function splits the name into a
123 namespace and target name part.
126 _vtk_module_split_module_name(<name> <prefix>)
129 The `<prefix>_NAMESPACE` and `<prefix>_TARGET_NAME` variables will be set in
132 function (_vtk_module_split_module_name name prefix)
133 string(FIND "${
name}
" "::
" namespace_pos)
134 if (namespace_pos EQUAL -1)
136 set(target_name "${
name}
")
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)
143 set("${prefix}_NAMESPACE
"
146 set("${prefix}_TARGET_NAME
"
153 @page module-overview Module overview
155 @section module-parse-module vtk.module file contents
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.
172 The base VTK library.
182 All values are optional unless otherwise noted. The following arguments are
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
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
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
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
209 * `IMPLEMENTS`: A list of modules for which this module needs to register
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
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
218 * `THIRD_PARTY`: If present, this module is a third party module.
223 @brief Parse `vtk.module` file contents
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
230 _vtk_module_parse_module_args(name_output <vtk.module args...>)
233 For example, this `vtk.module` file:
242 called with `_vtk_module_parse_module_args(name ...)` will set the following
243 variables in the calling scope:
245 - `name`: `Namespace::Target`
246 - `Namespace::Target_LIBRARY_NAME`: `nsTarget`
248 With namespace support for module names, the variable should instead be
249 referenced via `${${name}_LIBRARY_NAME}` instead.
251 macro (_vtk_module_parse_module_args name_output)
252 cmake_parse_arguments("_name
"
260 "A VTK module requires a
name (from ${_vtk_scan_module_file}).
")
262 set("${name_output}
" "${_name_NAME}
")
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
"
270 if (${_name_NAME}_UNPARSED_ARGUMENTS)
272 "Unparsed arguments
for ${_name_NAME}:
"
273 "${${_name_NAME}_UNPARSED_ARGUMENTS}
")
276 if (NOT ${_name_NAME}_DESCRIPTION AND _vtk_module_warnings)
277 message(WARNING "The ${_name_NAME} module should have a
description")
279 string(REPLACE ";
" " " "${_name_NAME}_DESCRIPTION
" "${${_name_NAME}_DESCRIPTION}
")
281 _vtk_module_split_module_name("${_name_NAME}
" "${_name_NAME}
")
283 if (NOT DEFINED "${_name_NAME}_LIBRARY_NAME
")
284 set("${_name_NAME}_LIBRARY_NAME
" "${${_name_NAME}_TARGET_NAME}
")
287 if (NOT ${_name_NAME}_LIBRARY_NAME)
288 message(FATAL_ERROR "The ${_name_NAME} module must have a non-empty `LIBRARY_NAME`.
")
291 list(APPEND "${_name_NAME}_TEST_LABELS
"
292 "${${_name_NAME}_NAME}
"
293 "${${_name_NAME}_LIBRARY_NAME}
")
297 @page module-overview
299 @section module-parse-kit vtk.kit file contents
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.
313 Core utilities for VTK.
316 All values are optional unless otherwise noted. The following arguments are
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.
328 @brief Parse `vtk.kit` file contents
330 Just like @ref _vtk_module_parse_module_args, but for kits.
332 macro (_vtk_module_parse_kit_args name_output)
333 cmake_parse_arguments("_name
"
341 "A VTK kit requires a
name (from ${_vtk_scan_kit_file}).
")
343 set("${name_output}
" "${_name_NAME}
")
345 cmake_parse_arguments("${_name_NAME}
"
351 if (${_name_NAME}_UNPARSED_ARGUMENTS)
353 "Unparsed arguments
for ${_name_NAME}:
"
354 "${${_name_NAME}_UNPARSED_ARGUMENTS}
")
357 _vtk_module_split_module_name("${_name_NAME}
" "${_name_NAME}
")
359 if (NOT DEFINED "${_name_NAME}_LIBRARY_NAME
")
360 set("${_name_NAME}_LIBRARY_NAME
" "${${_name_NAME}_TARGET_NAME}
")
363 if (NOT ${_name_NAME}_LIBRARY_NAME)
364 message(FATAL_ERROR "The ${_name_NAME} module must have a non-empty `LIBRARY_NAME`.
")
367 if (NOT ${_name_NAME}_DESCRIPTION AND _vtk_module_warnings)
368 message(WARNING "The ${_name_NAME} kit should have a
description")
370 string(REPLACE ";
" " " "${_name_NAME}_DESCRIPTION
" "${${_name_NAME}_DESCRIPTION}
")
374 @page module-overview
377 @section module-enable-status Enable status values
379 Modules and groups are enable and disable preferences are specified using a
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.,
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
392 If a `YES` module preference requires a module with a `NO` preference, an error
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.
402 @brief Verify enable values
404 Verifies that the variable named as the first parameter is a valid `enable
408 _vtk_module_verify_enable_value(var)
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
"))
418 "The `${var}` variable must be one of `YES`, `WANT`, `DONT_WANT`, `NO`,
"
419 "or `DEFAULT`. Found `${${var}}`.
")
423 include("${CMAKE_CURRENT_LIST_DIR}/vtkTopologicalSort.cmake
")
427 @brief Scan modules and kits
429 Once all of the modules and kits files have been found, they are "scanned
" to
430 determine what modules are enabled or required.
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>])
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:
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
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.
477 @section module-scanning-multiple Scanning multiple groups of modules
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:
487 # Scan our modules first because we need to know what of the other groups we
489 vtk_module_find_modules(our_modules "${CMAKE_CURRENT_SOURCE_DIR}/src
")
491 MODULE_FILES ${our_modules}
492 PROVIDES_MODULES our_enabled_modules
493 REQUIRES_MODULES required_modules)
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
")
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)
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
509 vtk_module_find_modules(utility_modules "${CMAKE_CURRENT_SOURCE_DIR}/utilities
")
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)
520 if (required_modules OR unrecognized_modules)
521 # Not all of the modules we required were found. This should probably error out.
525 function (vtk_module_scan)
526 cmake_parse_arguments(_vtk_scan
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
"
532 if (_vtk_scan_UNPARSED_ARGUMENTS)
535 "${_vtk_scan_UNPARSED_ARGUMENTS}
")
538 if (NOT DEFINED _vtk_scan_WANT_BY_DEFAULT)
539 set(_vtk_scan_WANT_BY_DEFAULT OFF)
542 if (NOT DEFINED _vtk_scan_HIDE_MODULES_FROM_CACHE)
543 set(_vtk_scan_HIDE_MODULES_FROM_CACHE OFF)
546 if (NOT DEFINED _vtk_scan_PROVIDES_MODULES)
548 "The `PROVIDES_MODULES` argument is required.
")
551 if (NOT DEFINED _vtk_scan_PROVIDES_KITS AND _vtk_scan_KIT_FILES)
553 "The `PROVIDES_KITS` argument is required.
")
556 if (NOT DEFINED _vtk_scan_ENABLE_TESTS)
557 set(_vtk_scan_ENABLE_TESTS "WANT
")
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
"))
565 "The `ENABLE_TESTS` argument must be one of `ON`, `OFF`, `WANT`, or
"
566 "`DEFAULT`.
" "Received `${_vtk_scan_ENABLE_TESTS}`.
")
569 if (NOT _vtk_scan_MODULE_FILES)
571 "No module files given to scan.
")
574 set(_vtk_scan_option_default_type STRING)
575 if (_vtk_scan_HIDE_MODULES_FROM_CACHE)
576 set(_vtk_scan_option_default_type INTERNAL)
579 set(_vtk_scan_all_kits)
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}
")
585 set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}
" APPEND
587 CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_kit_file}
")
589 file(READ "${_vtk_scan_kit_file}
" _vtk_scan_kit_args)
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
@")
597 list(APPEND _vtk_scan_all_kits
598 "${_vtk_scan_kit_name}
")
600 # Set properties for building.
603 "_vtk_kit_${_vtk_scan_kit_name}_namespace
" "${${_vtk_scan_kit_name}_NAMESPACE}
")
606 "_vtk_kit_${_vtk_scan_kit_name}_target_name
" "${${_vtk_scan_kit_name}_TARGET_NAME}
")
609 "_vtk_kit_${_vtk_scan_kit_name}_library_name
" "${${_vtk_scan_kit_name}_LIBRARY_NAME}
")
612 set(_vtk_scan_all_modules)
613 set(_vtk_scan_all_groups)
614 set(_vtk_scan_rejected_modules)
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}
")
621 set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}
" APPEND
623 CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_module_file}
")
625 file(READ "${_vtk_scan_module_file}
" _vtk_scan_module_args)
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}
")
634 if (${_vtk_scan_module_name}_THIRD_PARTY)
635 if (_vtk_module_warnings)
636 if (${_vtk_scan_module_name}_EXCLUDE_WRAP)
638 "The third party ${_vtk_scan_module_name} module does not need to
"
639 "declare `EXCLUDE_WRAP` also.
")
642 if (${_vtk_scan_module_name}_IMPLEMENTABLE)
644 "The third party ${_vtk_scan_module_name} module may not be
"
647 if (${_vtk_scan_module_name}_IMPLEMENTS)
649 "The third party ${_vtk_scan_module_name} module may not
"
650 "`IMPLEMENTS` another module.
")
652 if (${_vtk_scan_module_name}_KIT)
654 "The third party ${_vtk_scan_module_name} module may not be part of
"
655 "a kit (${${_vtk_scan_module_name}_KIT}).
")
659 if (${_vtk_scan_module_name}_KIT)
660 if (NOT ${_vtk_scan_module_name}_KIT IN_LIST _vtk_scan_all_kits)
662 "The ${_vtk_scan_module_name} belongs to the
"
663 "${${_vtk_scan_module_name}_KIT} kit, but it has not been scanned.
")
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}
"
676 _vtk_module_debug(module "@_vtk_scan_module_name@ hidden by its `CONDITION`
")
681 # Determine whether we should provide a user-visible option for this
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)
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)
694 "The ${_vtk_scan_module_name} module has been requested and rejected.
")
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}
")
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}
"
711 STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT
")
712 _vtk_module_verify_enable_value("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
")
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")
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}}
")
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}
"
730 STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT
")
731 set_property(CACHE "VTK_GROUP_ENABLE_${_vtk_scan_group}
"
733 TYPE "${_vtk_scan_option_default_type}
")
735 _vtk_module_verify_enable_value("VTK_GROUP_ENABLE_${_vtk_scan_group}
")
737 if (NOT VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT
")
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
@")
749 set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
"
751 TYPE "${_vtk_scan_option_default_type}
")
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
")
759 set("_vtk_scan_enable_${_vtk_scan_module_name}
" "DONT_WANT
")
761 _vtk_module_debug(enable "@_vtk_scan_module_name@ is DEFAULT,
using `WANT_BY_DEFAULT`: ${_vtk_scan_enable_${_vtk_scan_module_name}}
")
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})
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
")
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
")
780 # Set properties for building.
783 "_vtk_module_${_vtk_scan_module_name}_file
" "${_vtk_scan_module_file}
")
786 "_vtk_module_${_vtk_scan_module_name}_namespace
" "${${_vtk_scan_module_name}_NAMESPACE}
")
789 "_vtk_module_${_vtk_scan_module_name}_target_name
" "${${_vtk_scan_module_name}_TARGET_NAME}
")
792 "_vtk_module_${_vtk_scan_module_name}_library_name
" "${${_vtk_scan_module_name}_LIBRARY_NAME}
")
795 "_vtk_module_${_vtk_scan_module_name}_third_party
" "${${_vtk_scan_module_name}_THIRD_PARTY}
")
798 "_vtk_module_${_vtk_scan_module_name}_exclude_wrap
" "${${_vtk_scan_module_name}_EXCLUDE_WRAP}
")
801 "_vtk_module_${_vtk_scan_module_name}_kit
" "${${_vtk_scan_module_name}_KIT}
")
804 "_vtk_module_${_vtk_scan_module_name}_depends
" "${${_vtk_scan_module_name}_DEPENDS}
")
807 "_vtk_module_${_vtk_scan_module_name}_order_depends
" "${${_vtk_scan_module_name}_ORDER_DEPENDS}
")
810 "_vtk_module_${_vtk_scan_module_name}_private_depends
" "${${_vtk_scan_module_name}_PRIVATE_DEPENDS}
")
813 "_vtk_module_${_vtk_scan_module_name}_optional_depends
" "${${_vtk_scan_module_name}_OPTIONAL_DEPENDS}
")
816 "_vtk_module_${_vtk_scan_module_name}_test_depends
" "${${_vtk_scan_module_name}_TEST_DEPENDS}
")
819 "_vtk_module_${_vtk_scan_module_name}_test_optional_depends
" "${${_vtk_scan_module_name}_TEST_OPTIONAL_DEPENDS}
")
822 "_vtk_module_${_vtk_scan_module_name}_test_labels
" "${${_vtk_scan_module_name}_TEST_LABELS}
")
825 "_vtk_module_${_vtk_scan_module_name}_implements
" "${${_vtk_scan_module_name}_IMPLEMENTS}
")
828 "_vtk_module_${_vtk_scan_module_name}_implementable
" "${${_vtk_scan_module_name}_IMPLEMENTABLE}
")
831 set(_vtk_scan_current_modules "${_vtk_scan_all_modules}
")
832 vtk_topological_sort(_vtk_scan_all_modules "_vtk_scan_
" "_all_depends
")
834 set(_vtk_scan_provided_modules)
835 set(_vtk_scan_required_modules)
836 set(_vtk_scan_disabled_modules)
838 # Seed the `_vtk_scan_provide_` variables with modules requested and rejected
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`
")
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`
")
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
")
857 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module}
")
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}
")
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
@")
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
@")
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
")
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}
")
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}})
")
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)
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}
")
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
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
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
937 "_vtk_module_test_modules
" "${_vtk_scan_module}
")
938 elseif (_vtk_scan_ENABLE_TESTS STREQUAL "OFF
")
942 "Unrecognized option
for ENABLE_TESTS: ${_vtk_module_ENABLE_TESTS}.
")
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)
953 # Though we need to error if this would cause a disabled module to be
955 if (_vtk_scan_module_depend IN_LIST _vtk_scan_disabled_modules)
956 if (_vtk_scan_is_wanting)
960 "The ${_vtk_scan_module} module requires the disabled module ${_vtk_scan_module_depend}.
")
964 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}
")
965 if (NOT _vtk_scan_provide_${_vtk_scan_module_depend})
967 "The `${_vtk_scan_module_depend} should be provided, but is disabled.
")
971 set("_vtk_scan_provide_${_vtk_scan_module_depend}
" ON)
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
@")
977 list(APPEND _vtk_scan_required_modules
978 "${_vtk_scan_module_depend}
")
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}
")
988 if (_vtk_scan_provided_modules)
989 list(REMOVE_DUPLICATES _vtk_scan_provided_modules)
992 set(_vtk_scan_provided_kits)
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
1001 "_vtk_kit_${${_vtk_scan_provided_module}_KIT}_kit_modules
" "${_vtk_scan_provided_module}
")
1005 if (_vtk_scan_provided_kits)
1006 list(REMOVE_DUPLICATES _vtk_scan_provided_kits)
1009 if (_vtk_scan_required_modules)
1010 list(REMOVE_DUPLICATES _vtk_scan_required_modules)
1013 set(_vtk_scan_unrecognized_modules
1014 ${_vtk_scan_REQUEST_MODULES}
1015 ${_vtk_scan_REJECT_MODULES})
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})
1023 set("${_vtk_scan_PROVIDES_MODULES}
"
1024 ${_vtk_scan_provided_modules}
1027 if (DEFINED _vtk_scan_REQUIRES_MODULES)
1028 set("${_vtk_scan_REQUIRES_MODULES}
"
1029 ${_vtk_scan_required_modules}
1033 if (DEFINED _vtk_scan_UNRECOGNIZED_MODULES)
1034 set("${_vtk_scan_UNRECOGNIZED_MODULES}
"
1035 ${_vtk_scan_unrecognized_modules}
1039 if (DEFINED _vtk_scan_PROVIDES_KITS)
1040 set("${_vtk_scan_PROVIDES_KITS}
"
1041 ${_vtk_scan_provided_kits}
1047 @page module-overview
1049 @section module-target-functions Module-as-target functions
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.
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
1070 @page module-internal-api
1072 @section module-target-internals Module target internals
1074 When manipulating modules as targets, there are a few functions provided for
1075 use in wrapping code to more easily access them.
1077 - @ref _vtk_module_real_target
1078 - @ref _vtk_module_real_target_kit
1082 @ingroup module-internal
1083 @brief The real target for a module
1086 _vtk_module_real_target(<var> <module>)
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.
1093 function (_vtk_module_real_target var module)
1099 set(_vtk_real_target_res "")
1100 if (TARGET "${module}
")
1101 get_property(_vtk_real_target_imported
1104 if (_vtk_real_target_imported)
1105 set(_vtk_real_target_res "${module}
")
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
")
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
")
1125 if (NOT _vtk_real_target_res)
1126 get_target_property(_vtk_real_target_res "${module}
" NAME)
1129 if (NOT _vtk_real_target_res)
1130 set(_vtk_real_target_msg "")
1131 if (NOT TARGET "${module}
")
1132 if (DEFINED _vtk_build_module)
1133 set(_vtk_real_target_msg
1134 " Is a module dependency missing?
")
1136 set(_vtk_real_target_msg
1137 " Is a `find_package` missing a required
component?
")
1141 "Failed to determine the real
target for the `${module}`
"
1142 "module.${_vtk_real_target_msg}
")
1146 "${_vtk_real_target_res}
"
1151 @ingroup module-internal
1152 @brief The real target for a kit
1155 _vtk_module_real_target_kit(<var> <kit>)
1158 Sometimes the actual, core target for a module is required (e.g., setting
1159 CMake-level target properties or install rules). This function returns the real
1162 function (_vtk_module_real_target_kit var kit)
1168 set(_vtk_real_target_res "")
1169 if (TARGET "${kit}
")
1170 get_property(_vtk_real_target_imported
1173 if (_vtk_real_target_imported)
1174 set(_vtk_real_target_res "${kit}
")
1178 if (NOT _vtk_real_target_res)
1179 get_property(_vtk_real_target_res GLOBAL
1180 PROPERTY "_vtk_kit_${kit}_target_name
")
1183 if (NOT _vtk_real_target_res)
1185 "Failed to determine the real
target for the `${kit}` kit.
")
1189 "${_vtk_real_target_res}
"
1195 @brief Set multiple properties on a module
1197 A wrapper around `set_target_properties` that works for modules.
1200 vtk_module_set_properties(<module>
1201 [<property> <value>]...)
1204 function (vtk_module_set_properties module)
1205 _vtk_module_real_target(_vtk_set_properties_target "${module}
")
1207 set_target_properties("${_vtk_set_properties_target}
"
1214 @brief Set a property on a module
1216 A wrapper around `set_property(TARGET)` that works for modules.
1219 vtk_module_set_property(<module>
1220 [APPEND] [APPEND_STRING]
1225 function (vtk_module_set_property module)
1226 cmake_parse_arguments(_vtk_property
1227 "APPEND;APPEND_STRING
"
1232 if (_vtk_property_UNPARSED_ARGUMENTS)
1235 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1238 if (NOT DEFINED _vtk_property_PROPERTY)
1240 "The `PROPERTY` argument is required.
")
1243 if (NOT DEFINED _vtk_property_VALUE)
1245 "The `VALUE` argument is required.
")
1248 if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1250 "`APPEND` and `APPEND_STRING` may not be used at the same
time.
")
1253 set(_vtk_property_args)
1254 if (_vtk_property_APPEND)
1255 list(APPEND _vtk_property_args
1258 if (_vtk_property_APPEND_STRING)
1259 list(APPEND _vtk_property_args
1263 _vtk_module_real_target(_vtk_property_target "${module}
")
1265 set_property(TARGET "${_vtk_property_target}
"
1266 ${_vtk_property_args}
1268 "${_vtk_property_PROPERTY}
" "${_vtk_property_VALUE}
")
1273 @brief Get a property from a module
1275 A wrapper around `get_property(TARGET)` that works for modules.
1278 vtk_module_get_property(<module>
1280 VARIABLE <variable>)
1283 The variable name passed to the `VARIABLE` argument will be unset if the
1284 property is not set (rather than the empty string).
1286 function (vtk_module_get_property module)
1287 cmake_parse_arguments(_vtk_property
1293 if (_vtk_property_UNPARSED_ARGUMENTS)
1296 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1299 if (NOT DEFINED _vtk_property_PROPERTY)
1301 "The `PROPERTY` argument is required.
")
1304 if (NOT DEFINED _vtk_property_VARIABLE)
1306 "The `VARIABLE` argument is required.
")
1309 _vtk_module_real_target(_vtk_property_target "${module}
")
1311 get_property(_vtk_property_is_set
1312 TARGET "${_vtk_property_target}
"
1313 PROPERTY "${_vtk_property_PROPERTY}
"
1315 if (_vtk_property_is_set)
1316 get_property(_vtk_property_value
1317 TARGET "${_vtk_property_target}
"
1318 PROPERTY "${_vtk_property_PROPERTY}
")
1320 set("${_vtk_property_VARIABLE}
"
1321 "${_vtk_property_value}
"
1324 unset("${_vtk_property_VARIABLE}
"
1330 @ingroup module-impl
1331 @brief Generate arguments for target function wrappers
1333 Create the `INTERFACE`, `PUBLIC`, and `PRIVATE` arguments for a function
1334 wrapping CMake's `target_` functions to call the wrapped function.
1336 This is necessary because not all of the functions support empty lists given a
1339 function (_vtk_module_target_function prefix)
1340 foreach (visibility IN ITEMS INTERFACE PUBLIC PRIVATE)
1341 if (${prefix}_${visibility})
1342 set("${prefix}_${visibility}_args
"
1344 ${${prefix}_${visibility}}
1352 @brief Add dependencies to a module
1354 A wrapper around `add_dependencies` that works for modules.
1357 vtk_module_depend(<module> <depend>...)
1360 function (vtk_module_depend module)
1361 _vtk_module_real_target(_vtk_depend_target "${module}
")
1363 add_dependencies("${_vtk_depend_target}
"
1369 @brief Add include directories to a module
1371 A wrapper around `add_dependencies` that works for modules.
1374 vtk_module_include(<module>
1376 [PUBLIC <directory>...]
1377 [PRIVATE <directory>...]
1378 [INTERFACE <directory>...])
1381 function (vtk_module_include module)
1382 cmake_parse_arguments(_vtk_include
1385 "INTERFACE;PUBLIC;PRIVATE
"
1388 if (_vtk_include_UNPARSED_ARGUMENTS)
1391 "${_vtk_include_UNPARSED_ARGUMENTS}.
")
1394 _vtk_module_real_target(_vtk_include_target "${module}
")
1395 _vtk_module_target_function(_vtk_include)
1397 set(_vtk_include_system_arg)
1398 if (_vtk_include_SYSTEM)
1399 set(_vtk_include_system_arg SYSTEM)
1402 target_include_directories("${_vtk_include_target}
"
1403 ${_vtk_include_system_arg}
1404 ${_vtk_include_INTERFACE_args}
1405 ${_vtk_include_PUBLIC_args}
1406 ${_vtk_include_PRIVATE_args})
1411 @brief Add compile definitions to a module
1413 A wrapper around `target_compile_definitions` that works for modules.
1416 vtk_module_definitions(<module>
1417 [PUBLIC <directory>...]
1418 [PRIVATE <directory>...]
1419 [INTERFACE <directory>...])
1422 function (vtk_module_definitions module)
1423 cmake_parse_arguments(_vtk_definitions
1426 "INTERFACE;PUBLIC;PRIVATE
"
1429 if (_vtk_definitions_UNPARSED_ARGUMENTS)
1432 "${_vtk_definitions_UNPARSED_ARGUMENTS}.
")
1435 _vtk_module_real_target(_vtk_definitions_target "${module}
")
1436 _vtk_module_target_function(_vtk_definitions)
1438 target_compile_definitions("${_vtk_definitions_target}
"
1439 ${_vtk_definitions_INTERFACE_args}
1440 ${_vtk_definitions_PUBLIC_args}
1441 ${_vtk_definitions_PRIVATE_args})
1446 @brief Add compile options to a module
1448 A wrapper around `target_compile_options` that works for modules.
1451 vtk_module_compile_options(<module>
1452 [PUBLIC <directory>...]
1453 [PRIVATE <directory>...]
1454 [INTERFACE <directory>...])
1457 function (vtk_module_compile_options module)
1458 cmake_parse_arguments(_vtk_compile_options
1461 "INTERFACE;PUBLIC;PRIVATE
"
1464 if (_vtk_compile_options_UNPARSED_ARGUMENTS)
1467 "${_vtk_compile_options_UNPARSED_ARGUMENTS}.
")
1470 _vtk_module_real_target(_vtk_compile_options_target "${module}
")
1471 _vtk_module_target_function(_vtk_compile_options)
1473 target_compile_options("${_vtk_compile_options_target}
"
1474 ${_vtk_compile_options_INTERFACE_args}
1475 ${_vtk_compile_options_PUBLIC_args}
1476 ${_vtk_compile_options_PRIVATE_args})
1481 @brief Add compile features to a module
1483 A wrapper around `target_compile_features` that works for modules.
1486 vtk_module_compile_features(<module>
1487 [PUBLIC <directory>...]
1488 [PRIVATE <directory>...]
1489 [INTERFACE <directory>...])
1492 function (vtk_module_compile_features module)
1493 cmake_parse_arguments(_vtk_compile_features
1496 "INTERFACE;PUBLIC;PRIVATE
"
1499 if (_vtk_compile_features_UNPARSED_ARGUMENTS)
1502 "${_vtk_compile_features_UNPARSED_ARGUMENTS}.
")
1505 _vtk_module_real_target(_vtk_compile_features_target "${module}
")
1506 _vtk_module_target_function(_vtk_compile_features)
1508 target_compile_features("${_vtk_compile_features_target}
"
1509 ${_vtk_compile_features_INTERFACE_args}
1510 ${_vtk_compile_features_PUBLIC_args}
1511 ${_vtk_compile_features_PRIVATE_args})
1516 @brief Add link libraries to a module
1518 A wrapper around `target_link_libraries` that works for modules. Note that this
1519 function does extra work in kit builds, so circumventing it may break in kit
1523 vtk_module_link(<module>
1524 [PUBLIC <directory>...]
1525 [PRIVATE <directory>...]
1526 [INTERFACE <directory>...])
1529 function (vtk_module_link module)
1530 cmake_parse_arguments(_vtk_link
1533 "INTERFACE;PUBLIC;PRIVATE
"
1536 if (_vtk_link_UNPARSED_ARGUMENTS)
1539 "${_vtk_link_UNPARSED_ARGUMENTS}.
")
1542 _vtk_module_real_target(_vtk_link_target "${module}
")
1543 _vtk_module_target_function(_vtk_link)
1545 get_property(_vtk_link_kit GLOBAL
1546 PROPERTY "_vtk_module_${module}_kit
")
1547 if (_vtk_link_kit AND NOT CMAKE_VERSION VERSION_LESS "3.12
")
1548 foreach (_vtk_link_private IN LISTS _vtk_link_PRIVATE)
1549 if (NOT TARGET "${_vtk_link_private}
")
1553 get_property(_vtk_link_private_imported
1554 TARGET "${_vtk_link_private}
"
1556 if (_vtk_link_private_imported)
1557 get_property(_vtk_link_private_imported_global
1558 TARGET "${_vtk_link_private}
"
1559 PROPERTY IMPORTED_GLOBAL)
1560 if (NOT _vtk_link_private_imported_global)
1561 set_property(TARGET "${_vtk_link_private}
"
1563 IMPORTED_GLOBAL TRUE)
1567 set_property(GLOBAL APPEND
1569 "_vtk_kit_${_vtk_link_kit}_private_links
" ${_vtk_link_PRIVATE})
1572 target_link_libraries("${_vtk_link_target}
"
1573 ${_vtk_link_INTERFACE_args}
1574 ${_vtk_link_PUBLIC_args}
1575 ${_vtk_link_PRIVATE_args})
1580 @brief Add link options to a module
1582 A wrapper around `target_link_options` that works for modules.
1585 vtk_module_link_options(<module>
1586 [PUBLIC <directory>...]
1587 [PRIVATE <directory>...]
1588 [INTERFACE <directory>...])
1591 function (vtk_module_link_options module)
1592 cmake_parse_arguments(_vtk_link_options
1595 "INTERFACE;PUBLIC;PRIVATE
"
1598 if (_vtk_link_options_UNPARSED_ARGUMENTS)
1601 "${_vtk_link_options_UNPARSED_ARGUMENTS}.
")
1604 _vtk_module_real_target(_vtk_link_options_target "${module}
")
1605 _vtk_module_target_function(_vtk_link_options)
1607 target_link_options("${_vtk_link_options_target}
"
1608 ${_vtk_link_options_INTERFACE_args}
1609 ${_vtk_link_options_PUBLIC_args}
1610 ${_vtk_link_options_PRIVATE_args})
1614 @page module-internal-api
1616 @ingroup module-internal
1617 @section module-properties Module properties
1619 The VTK module system leverages CMake's target propagation and storage. As
1620 such, there are a number of properties added to the targets representing
1621 modules. These properties are intended for use by the module system and
1622 associated functionality. In particular, more properties may be available by
1625 @subsection module-properties-naming Naming properties
1627 When creating properties for use with the module system, they should be
1628 prefixed with `INTERFACE_vtk_module_`. The `INTERFACE_` portion is required in
1629 order to work with interface libraries. The `vtk_module_` portion is to avoid
1630 colliding with any other properties. This function assumes this naming scheme
1631 for some of its convenience features as well.
1633 Properties should be the same in the local build as well as when imported to
1636 @subsection module-properties-system VTK module system properties
1638 There are a number of properties that are used and expected by the core of the
1639 module system. These are generally module metadata (module dependencies,
1640 whether to wrap or not, etc.). The properties all have the
1641 `INTERFACE_vtk_module_` prefix mentioned in the previous section.
1643 * `third_party`: If set, the module represents a third party
1644 dependency and should be treated specially. Third party modules are very
1645 restricted and generally do not have any other properties set on them.
1646 * `exclude_wrap`: If set, the module should not be wrapped by an external
1648 * `depends`: The list of dependent modules. Language wrappers will generally
1649 require this to satisfy references to parent classes of the classes in the
1651 * `private_depends`: The list of privately dependent modules. Language
1652 wrappers may require this to satisfy references to parent classes of the
1653 classes in the module.
1654 * `optional_depends`: The list of optionally dependent modules. Language
1655 wrappers may require this to satisfy references to parent classes of the
1656 classes in the module.
1657 * `kit`: The kit the module is a member of. Only set if the module is
1658 actually a member of the kit (i.e., the module was built with
1659 `BUILD_WITH_KITS ON`).
1660 * `implements`: The list of modules for which this module registers to. This
1661 is used by the autoinit subsystem and generally is not required.
1662 * `implementable`: If set, this module provides registries which may be
1663 populated by dependent modules. It is used to check the `implements`
1664 property to help minimize unnecessary work from the autoinit subsystem.
1665 * `needs_autoinit`: If set, linking to this module requires the autoinit
1666 subsystem to ensure that registries in modules are fully populated.
1667 * `headers`: Paths to the public headers from the module. These are the
1668 headers which should be handled by language wrappers.
1669 * `hierarchy`: The path to the hierarchy file describing inheritance of the
1670 classes for use in language wrappers.
1671 * `forward_link`: Usage requirements that must be forwarded even though the
1672 module is linked to privately.
1674 Kits have the following properties available (but only if kits are enabled):
1676 * `kit_modules`: Modules which are compiled into the kit.
1680 @ingroup module-internal
1681 @brief Set a module property
1683 This function sets a [module property](@ref module-properties) on a module. The
1684 required prefix will automatically be added to the passed name.
1687 _vtk_module_set_module_property(<module>
1688 [APPEND] [APPEND_STRING]
1693 function (_vtk_module_set_module_property module)
1694 cmake_parse_arguments(_vtk_property
1695 "APPEND;APPEND_STRING
"
1700 if (_vtk_property_UNPARSED_ARGUMENTS)
1702 "Unparsed arguments
for vtk_module_set_module_property:
"
1703 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1706 if (NOT DEFINED _vtk_property_PROPERTY)
1708 "The `PROPERTY` argument is required.
")
1711 if (NOT DEFINED _vtk_property_VALUE)
1713 "The `VALUE` argument is required.
")
1716 if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1718 "`APPEND` and `APPEND_STRING` may not be used at the same
time.
")
1721 set(_vtk_property_args)
1722 if (_vtk_property_APPEND)
1723 list(APPEND _vtk_property_args
1726 if (_vtk_property_APPEND_STRING)
1727 list(APPEND _vtk_property_args
1731 get_property(_vtk_property_is_alias
1733 PROPERTY ALIASED_TARGET
1735 if (_vtk_property_is_alias)
1736 _vtk_module_real_target(_vtk_property_target "${module}
")
1738 set(_vtk_property_target "${module}
")
1741 set_property(TARGET "${_vtk_property_target}
"
1742 ${_vtk_property_args}
1744 "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
" "${_vtk_property_VALUE}
")
1748 @ingroup module-internal
1749 @brief Get a module property
1751 Get a [module property](@ref module-properties) from a module.
1754 _vtk_module_get_module_property(<module>
1756 VARIABLE <variable>)
1759 As with @ref vtk_module_get_property, the output variable will be unset if the
1760 property is not set. The property name is automatically prepended with the
1763 function (_vtk_module_get_module_property module)
1764 cmake_parse_arguments(_vtk_property
1770 if (_vtk_property_UNPARSED_ARGUMENTS)
1772 "Unparsed arguments
for vtk_module_get_module_property:
"
1773 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1776 if (NOT DEFINED _vtk_property_PROPERTY)
1778 "The `PROPERTY` argument is required.
")
1781 if (NOT DEFINED _vtk_property_VARIABLE)
1783 "The `VARIABLE` argument is required.
")
1786 get_property(_vtk_property_is_alias
1788 PROPERTY ALIASED_TARGET
1790 if (_vtk_property_is_alias)
1791 _vtk_module_real_target(_vtk_property_target "${module}
")
1793 set(_vtk_property_target "${module}
")
1796 get_property(_vtk_property_is_set
1797 TARGET "${_vtk_property_target}
"
1798 PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
"
1800 if (_vtk_property_is_set)
1801 get_property(_vtk_property_value
1802 TARGET "${_vtk_property_target}
"
1803 PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
")
1805 set("${_vtk_property_VARIABLE}
"
1806 "${_vtk_property_value}
"
1809 unset("${_vtk_property_VARIABLE}
"
1815 @ingroup module-internal
1816 @brief Check that destinations are valid
1818 All installation destinations are expected to be relative so that
1819 `CMAKE_INSTALL_PREFIX` can be relied upon in all code paths. This function may
1820 be used to verify that destinations are relative.
1823 _vtk_module_check_destinations(<prefix> [<suffix>...])
1826 For each `suffix`, `prefix` is prefixed to it and the resulting variable name
1827 is checked for validity as an install prefix. Raises an error if any is
1830 function (_vtk_module_check_destinations prefix)
1831 foreach (suffix IN LISTS ARGN)
1832 if (IS_ABSOLUTE "${${prefix}${suffix}}
")
1834 "The `${suffix}` must not be an absolute path. Use
"
1835 "`CMAKE_INSTALL_PREFIX` to keep everything in a single installation
"
1842 @ingroup module-internal
1843 @brief Write an import prefix statement
1845 CMake files, once installed, may need to construct paths to other locations
1846 within the install prefix. This function writes a prefix computation for file
1847 given its install destination.
1850 _vtk_module_write_import_prefix(<file> <destination>)
1853 The passed file is cleared so that it occurs at the top of the file. The prefix
1854 is available in the file as the `_vtk_module_import_prefix` variable. It is
1855 recommended to unset the variable at the end of the file.
1857 function (_vtk_module_write_import_prefix file destination)
1858 if (IS_ABSOLUTE "${destination}
")
1860 "An
import prefix cannot be determined from an absolute installation
"
1861 "destination. Use `CMAKE_INSTALL_PREFIX` to keep everything in a single
"
1862 "installation prefix.
")
1865 file(WRITE "${file}
"
1866 "set(_vtk_module_import_prefix \
"\${CMAKE_CURRENT_LIST_DIR}\")\n")
1868 get_filename_component(destination
"${destination}" DIRECTORY)
1869 file(APPEND
"${file}"
1870 "get_filename_component(_vtk_module_import_prefix \"\${_vtk_module_import_prefix}\" DIRECTORY)\n")
1875 @ingroup module-
internal
1876 @brief Export properties
on modules and targets
1878 This
function is intended
for use in support functions which leverage the
1879 module system, not by general system users. This
function supports exporting
1880 properties from the build into dependencies via
target properties which are
1881 loaded from a project
's config file which is loaded via CMake's `find_package`
1890 [PROPERTIES <property>...]
1891 [FROM_GLOBAL_PROPERTIES <property fragment>...]
1892 [SPLIT_INSTALL_PROPERTIES <property fragment>...])
1895 The `BUILD_FILE` and `INSTALL_FILE` arguments are required. Exactly one of
1896 `MODULE` and `KIT` is also required. The `MODULE` or `KIT` argument holds the
1897 name of the module or kit that will have properties exported. The `BUILD_FILE`
1898 and `INSTALL_FILE` paths are *appended to*. As such, when setting up these
1899 files, it should be preceded with:
1902 file(WRITE
"${build_file}")
1903 file(WRITE
"${install_file}")
1906 To avoid accidental usage of the install file from the build tree, it is
1907 recommended to store it under a `CMakeFiles/` directory in the build tree with
1908 an additional `.install` suffix and use `install(RENAME)` to rename it at
1911 The set of properties exported is computed as follows:
1913 * `PROPERTIES` queries the module
target for the given
property and exports
1914 its
value as-is to both the build and install files. In addition, these
1915 properties are set
on the
target directly as the same
name.
1916 * `FROM_GLOBAL_PROPERTIES` queries the
global
1917 `_vtk_module_<MODULE>_<fragment>`
property and exports it to both the build
1918 and install files as `INTERFACE_vtk_module_<fragment>`.
1919 * `SPLIT_INSTALL_PROPERTIES` queries the
target for
1920 `INTERFACE_vtk_module_<fragment>` and exports its
value to the build file
1921 and `INTERFACE_vtk_module_<fragment>_install` to the install file as the
1922 non-install
property name. This is generally useful
for properties which
1923 change between the build and installation.
1926 cmake_parse_arguments(_vtk_export_properties
1928 "BUILD_FILE;INSTALL_FILE;MODULE;KIT"
1929 "FROM_GLOBAL_PROPERTIES;PROPERTIES;SPLIT_INSTALL_PROPERTIES"
1932 if (_vtk_export_properties_UNPARSED_ARGUMENTS)
1934 "Unparsed arguments for _vtk_export_properties: "
1935 "${_vtk_export_properties_UNPARSED_ARGUMENTS}.")
1938 if (DEFINED _vtk_export_properties_MODULE)
1939 if (DEFINED _vtk_export_properties_KIT)
1941 "Only one of `MODULE` or `KIT` is required to export properties.")
1943 set(_vtk_export_properties_type "module")
1944 set(_vtk_export_properties_name "${_vtk_export_properties_MODULE}
")
1945 elseif (_vtk_export_properties_KIT)
1946 set(_vtk_export_properties_type "kit
")
1947 set(_vtk_export_properties_name "${_vtk_export_properties_KIT}
")
1950 "A module or kit is required to export properties.
")
1953 if (NOT _vtk_export_properties_BUILD_FILE)
1955 "Exporting properties requires a build file to write to.
")
1958 if (NOT _vtk_export_properties_INSTALL_FILE)
1960 "Exporting properties requires an install file to write to.
")
1963 if (_vtk_export_properties_type STREQUAL "module
")
1964 _vtk_module_real_target(_vtk_export_properties_target_name "${_vtk_export_properties_name}
")
1965 elseif (_vtk_export_properties_type STREQUAL "kit
")
1966 _vtk_module_real_target_kit(_vtk_export_properties_target_name "${_vtk_export_properties_name}
")
1969 foreach (_vtk_export_properties_global IN LISTS _vtk_export_properties_FROM_GLOBAL_PROPERTIES)
1970 get_property(_vtk_export_properties_is_set GLOBAL
1971 PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}
"
1973 if (NOT _vtk_export_properties_is_set)
1977 get_property(_vtk_export_properties_value GLOBAL
1978 PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}
")
1979 set(_vtk_export_properties_set_property
1980 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}\" \"${_vtk_export_properties_value}\")\n")
1982 set_property(TARGET
"${_vtk_export_properties_target_name}"
1984 "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}" "${_vtk_export_properties_value}")
1985 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
1986 "${_vtk_export_properties_set_property}")
1987 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
1988 "${_vtk_export_properties_set_property}")
1991 foreach (_vtk_export_properties_target IN LISTS _vtk_export_properties_PROPERTIES)
1992 get_property(_vtk_export_properties_is_set
1993 TARGET "${_vtk_export_properties_target_name}
"
1994 PROPERTY "${_vtk_export_properties_target}
"
1996 if (NOT _vtk_export_properties_is_set)
2000 get_property(_vtk_export_properties_value
2001 TARGET "${_vtk_export_properties_target_name}
"
2002 PROPERTY "${_vtk_export_properties_target}
")
2003 set(_vtk_export_properties_set_property
2004 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"${_vtk_export_properties_target}\" \"${_vtk_export_properties_value}\")\n")
2006 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
2007 "${_vtk_export_properties_set_property}")
2008 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
2009 "${_vtk_export_properties_set_property}")
2012 foreach (_vtk_export_properties_split IN LISTS _vtk_export_properties_SPLIT_INSTALL_PROPERTIES)
2013 get_property(_vtk_export_properties_is_set
2014 TARGET "${_vtk_export_properties_target_name}
"
2015 PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}
"
2017 if (NOT _vtk_export_properties_is_set)
2021 get_property(_vtk_export_properties_value
2022 TARGET "${_vtk_export_properties_target_name}
"
2023 PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}
")
2024 set(_vtk_export_properties_set_property
2025 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2026 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
2027 "${_vtk_export_properties_set_property}")
2029 get_property(_vtk_export_properties_value
2030 TARGET
"${_vtk_export_properties_target_name}"
2031 PROPERTY
"INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}_install")
2032 set(_vtk_export_properties_set_property
2033 "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2034 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
2035 "${_vtk_export_properties_set_property}")
2039 include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleTesting.cmake
")
2043 @brief Build modules and kits
2045 Once all of the modules have been scanned, they need to be built. Generally,
2046 there will be just one build necessary for a set of scans, though they may be
2047 built distinctly as well. If there are multiple calls to this function, they
2048 should generally in reverse order of their scans.
2055 [LIBRARY_NAME_SUFFIX <suffix>]
2057 [SOVERSION <soversion>]
2061 [BUILD_WITH_KITS <ON|OFF>]
2063 [ENABLE_WRAPPING <ON|OFF>]
2065 [USE_EXTERNAL <ON|OFF>]
2067 [INSTALL_HEADERS <ON|OFF>]
2068 [HEADERS_COMPONENT <component>]
2070 [TARGETS_COMPONENT <component>]
2071 [INSTALL_EXPORT <export>]
2073 [TEST_DIRECTORY_NAME <name>]
2074 [TEST_DATA_TARGET <target>]
2075 [TEST_INPUT_DATA_DIRECTORY <directory>]
2076 [TEST_OUTPUT_DATA_DIRECTORY <directory>]
2077 [TEST_OUTPUT_DIRECTORY <directory>]
2079 [ARCHIVE_DESTINATION <destination>]
2080 [HEADERS_DESTINATION <destination>]
2081 [LIBRARY_DESTINATION <destination>]
2082 [RUNTIME_DESTINATION <destination>]
2083 [CMAKE_DESTINATION <destination>]
2084 [LICENSE_DESTINATION <destination>]
2085 [HIERARCHY_DESTINATION <destination>])
2088 The only requirement of the function is the list of modules to build, the rest
2089 have reasonable defaults if not specified.
2091 * `MODULES`: (Required) The list of modules to build.
2092 * `KITS`: (Required if `BUILD_WITH_KITS` is `ON`) The list of kits to build.
2093 * `LIBRARY_NAME_SUFFIX`: (Defaults to `""`) A suffix to add to library names.
2094 If it is not empty, it is prefixed with `-` to separate it from the kit
2096 * `VERSION`: If specified, the `VERSION` property on built libraries will be
2098 * `SOVERSION`: If specified, the `SOVERSION` property on built libraries will
2099 be set to this value.
2100 * `PACKAGE`: (Defaults to `${CMAKE_PROJECT_NAME}`) The name the build is
2101 meant to be found as when using `find_package`. Note that separate builds
2102 will require distinct `PACKAGE` values.
2103 * `BUILD_WITH_KITS`: (Defaults to `OFF`) If enabled, kit libraries will be
2105 * `ENABLE_WRAPPING`: (Default depends on the existence of
2106 `VTK::WrapHierarchy` or `VTKCompileTools::WrapHierarchy` targets) If
2107 enabled, wrapping will be available to the modules built in this call.
2108 * `USE_EXTERNAL`: (Defaults to `OFF`) Whether third party modules should find
2109 external copies rather than building their own copy.
2110 * `INSTALL_HEADERS`: (Defaults to `ON`) Whether or not to install public headers.
2111 * `HEADERS_COMPONENT`: (Defaults to `development`) The install component to
2112 use for header installation. Note that other SDK-related bits use the same
2113 component (e.g., CMake module files).
2114 * `TARGETS_COMPONENT`: `Defaults to `runtime`) The install component to use
2115 for the libraries built.
2116 * `TARGET_NAMESPACE`: `Defaults to `<AUTO>`) The namespace for installed
2117 targets. All targets must have the same namespace. If set to `<AUTO>`,
2118 the namespace will be detected automatically.
2119 * `INSTALL_EXPORT`: (Defaults to `""`) If non-empty, targets will be added to
2120 the given export. The export will also be installed as part of this build
2122 * `TEST_DIRECTORY_NAME`: (Defaults to `Testing`) The name of the testing
2123 directory to look for in each module. Set to `NONE` to disable automatic
2125 * `TEST_DATA_TARGET`: (Defaults to `<PACKAGE>-data`) The target to add
2126 testing data download commands to.
2127 * `TEST_INPUT_DATA_DIRECTORY`: (Defaults to
2128 `${CMAKE_CURRENT_SOURCE_DIR}/Data`) The directory which will contain data
2130 * `TEST_OUTPUT_DATA_DIRECTORY`: (Defaults to
2131 `${CMAKE_CURRENT_BINARY_DIR}/Data`) The directory which will contain data
2133 * `TEST_OUTPUT_DIRECTORY`: (Defaults to
2134 `${CMAKE_BINARY_DIR}/<TEST_DIRECTORY_NAME>/Temporary`) The directory which
2135 tests may write any output files to.
2137 The remaining arguments control where to install files related to the build.
2138 See CMake documentation for the difference between `ARCHIVE`, `LIBRARY`, and
2141 * `ARCHIVE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2142 destination for archive files.
2143 * `HEADERS_DESTINATION`: (Defaults to `${CMAKE_INSTALL_INCLUDEDIR}`) The
2144 install destination for header files.
2145 * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2146 destination for library files.
2147 * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) The install
2148 destination for runtime files.
2149 * `CMAKE_DESTINATION`: (Defaults to `<library destination>/cmake/<package>`)
2150 The install destination for CMake files.
2151 * `LICENSE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}`)
2152 The install destination for license files (relevant for third party
2154 * `HIERARCHY_DESTINATION`: (Defaults to `<library
2155 destination>/vtk/hierarchy/<PACKAGE>`) The install destination
2156 for hierarchy files (used for language wrapping).
2158 function (vtk_module_build)
2159 set(_vtk_build_install_arguments
2176 HIERARCHY_DESTINATION)
2177 set(_vtk_build_test_arguments
2181 TEST_INPUT_DATA_DIRECTORY
2182 TEST_OUTPUT_DATA_DIRECTORY
2183 TEST_OUTPUT_DIRECTORY)
2185 # TODO: Add an option to build statically? Currently, `BUILD_SHARED_LIBS` is
2188 cmake_parse_arguments(_vtk_build
2190 "BUILD_WITH_KITS;USE_EXTERNAL;LIBRARY_NAME_SUFFIX;VERSION;SOVERSION;PACKAGE;ENABLE_WRAPPING;${_vtk_build_install_arguments};${_vtk_build_test_arguments}
"
2194 if (_vtk_build_UNPARSED_ARGUMENTS)
2197 "${_vtk_build_UNPARSED_ARGUMENTS}
")
2200 if (NOT DEFINED _vtk_build_USE_EXTERNAL)
2201 set(_vtk_build_USE_EXTERNAL OFF)
2204 if (NOT DEFINED _vtk_build_PACKAGE)
2205 set(_vtk_build_PACKAGE "${CMAKE_PROJECT_NAME}
")
2207 get_property(_vtk_build_package_exists GLOBAL
2208 PROPERTY "_vtk_module_package_${_vtk_build_PACKAGE}
"
2210 if (_vtk_build_package_exists)
2212 "A set of modules have already been built
using the
"
2213 "`${_vtk_build_PACKAGE}` package.
")
2217 "_vtk_module_package_${_vtk_build_PACKAGE}
" "ON
")
2220 if (NOT DEFINED _vtk_build_INSTALL_HEADERS)
2221 set(_vtk_build_INSTALL_HEADERS ON)
2224 if (NOT DEFINED _vtk_build_ENABLE_WRAPPING)
2225 if (TARGET "VTKCompileTools::WrapHierarchy
" OR
2226 TARGET "VTK::WrapHierarchy
")
2227 set(_vtk_build_ENABLE_WRAPPING ON)
2229 set(_vtk_build_ENABLE_WRAPPING OFF)
2233 if (NOT DEFINED _vtk_build_TARGET_NAMESPACE)
2234 set(_vtk_build_TARGET_NAMESPACE "<AUTO>
")
2237 if (NOT DEFINED _vtk_build_BUILD_WITH_KITS)
2238 set(_vtk_build_BUILD_WITH_KITS OFF)
2241 if (_vtk_build_BUILD_WITH_KITS AND CMAKE_VERSION VERSION_LESS "3.12
")
2243 "Building with kits
enabled requires CMake 3.12 which introduced
"
2244 "support
for OBJECT libraries to have and utilize usage requirements.
")
2247 if (_vtk_build_BUILD_WITH_KITS AND NOT DEFINED _vtk_build_KITS)
2249 "Building with kits was requested, but no kits were specified.
")
2252 if (NOT DEFINED _vtk_build_TEST_DIRECTORY_NAME)
2253 set(_vtk_build_TEST_DIRECTORY_NAME "Testing
")
2256 if (NOT DEFINED _vtk_build_TEST_DATA_TARGET)
2257 set(_vtk_build_TEST_DATA_TARGET "${_vtk_build_PACKAGE}-
data")
2260 if (NOT DEFINED _vtk_build_TEST_INPUT_DATA_DIRECTORY)
2261 set(_vtk_build_TEST_INPUT_DATA_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Data
")
2264 if (NOT DEFINED _vtk_build_TEST_OUTPUT_DATA_DIRECTORY)
2265 set(_vtk_build_TEST_OUTPUT_DATA_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Data
")
2268 if (NOT DEFINED _vtk_build_TEST_OUTPUT_DIRECTORY)
2269 set(_vtk_build_TEST_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_TEST_DIRECTORY_NAME}/Temporary
")
2272 if (NOT DEFINED _vtk_build_HEADERS_COMPONENT)
2273 set(_vtk_build_HEADERS_COMPONENT "development
")
2276 if (NOT DEFINED _vtk_build_ARCHIVE_DESTINATION)
2277 set(_vtk_build_ARCHIVE_DESTINATION "${CMAKE_INSTALL_LIBDIR}
")
2280 if (NOT DEFINED _vtk_build_HEADERS_DESTINATION)
2281 set(_vtk_build_HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}
")
2284 if (NOT DEFINED _vtk_build_LIBRARY_DESTINATION)
2285 set(_vtk_build_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}
")
2288 if (NOT DEFINED _vtk_build_RUNTIME_DESTINATION)
2289 set(_vtk_build_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}
")
2292 if (NOT DEFINED _vtk_build_CMAKE_DESTINATION)
2293 set(_vtk_build_CMAKE_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/cmake/${_vtk_build_PACKAGE}
")
2296 if (NOT DEFINED _vtk_build_LICENSE_DESTINATION)
2297 set(_vtk_build_LICENSE_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}
")
2300 if (NOT DEFINED _vtk_build_HIERARCHY_DESTINATION)
2301 set(_vtk_build_HIERARCHY_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/
vtk/hierarchy/${_vtk_build_PACKAGE}
")
2304 if (NOT DEFINED _vtk_build_TARGETS_COMPONENT)
2305 set(_vtk_build_TARGETS_COMPONENT "runtime
")
2308 if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
2309 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_ARCHIVE_DESTINATION}
")
2311 if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
2312 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_LIBRARY_DESTINATION}
")
2314 if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
2315 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_RUNTIME_DESTINATION}
")
2318 if (NOT _vtk_build_MODULES)
2320 "No modules given to build.
")
2323 _vtk_module_check_destinations(_vtk_build_
2329 HIERARCHY_DESTINATION)
2331 foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2332 get_property("_vtk_build_${_vtk_build_module}_depends
" GLOBAL
2333 PROPERTY "_vtk_module_${_vtk_build_module}_depends
")
2334 get_property("_vtk_build_${_vtk_build_module}_private_depends
" GLOBAL
2335 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends
")
2336 get_property("_vtk_build_${_vtk_build_module}_optional_depends
" GLOBAL
2337 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends
")
2338 get_property("_vtk_build_${_vtk_build_module}_order_depends
" GLOBAL
2339 PROPERTY "_vtk_module_${_vtk_build_module}_order_depends
")
2340 set("_vtk_build_${_vtk_build_module}_all_depends
"
2341 ${_vtk_build_${_vtk_build_module}_depends}
2342 ${_vtk_build_${_vtk_build_module}_private_depends}
2343 ${_vtk_build_${_vtk_build_module}_optional_depends}
2344 ${_vtk_build_${_vtk_build_module}_order_depends})
2347 set(_vtk_build_sorted_modules "${_vtk_build_MODULES}
")
2348 vtk_topological_sort(_vtk_build_sorted_modules "_vtk_build_
" "_all_depends
")
2350 foreach (_vtk_build_module IN LISTS _vtk_build_sorted_modules)
2351 if (NOT _vtk_build_module IN_LIST _vtk_build_MODULES)
2355 if (TARGET "${_vtk_build_module}
")
2356 get_property(_vtk_build_is_imported
2357 TARGET "${_vtk_build_module}
"
2360 # TODO: Is this right?
2361 if (NOT _vtk_build_is_imported)
2363 "The ${_vtk_build_module} module has been requested to be built, but
"
2364 "it is already built by
this project.
")
2370 foreach (_vtk_build_depend IN LISTS "_vtk_build_${_vtk_build_module}_depends
" "_vtk_build_${_vtk_build_module}_private_depends
")
2371 if (NOT TARGET "${_vtk_build_depend}
")
2373 "The ${_vtk_build_depend} dependency is missing
for ${_vtk_build_module}.
")
2377 get_property(_vtk_build_module_file GLOBAL
2378 PROPERTY "_vtk_module_${_vtk_build_module}_file
")
2379 if (NOT _vtk_build_module_file)
2381 "The requested ${_vtk_build_module} module is not a VTK module.
")
2384 _vtk_module_debug(building "@_vtk_build_module@ is being built
")
2386 get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}
" DIRECTORY)
2387 file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}
" "${_vtk_build_module_dir}
")
2389 "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}
"
2390 "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}
")
2392 if (NOT TARGET "${_vtk_build_module}
")
2394 "The ${_vtk_build_module} is being built, but a matching
target was
"
2399 if (_vtk_build_BUILD_WITH_KITS)
2400 foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2401 get_property(_vtk_build_target_name GLOBAL
2402 PROPERTY "_vtk_kit_${_vtk_build_kit}_target_name
")
2403 set(_vtk_kit_source_file
2404 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/vtk_module_kit_${_vtk_build_target_name}.c
")
2406 OUTPUT "${_vtk_kit_source_file}
"
2407 CONTENT "void vtk_module_kit_${_vtk_build_target_name}() {}\n
")
2408 add_library("${_vtk_build_target_name}
"
2409 "${_vtk_kit_source_file}
")
2410 get_property(_vtk_build_namespace GLOBAL
2411 PROPERTY "_vtk_kit_${_vtk_build_kit}_namespace
")
2412 if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>
")
2413 set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}
")
2415 if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2417 "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the
"
2418 "same as the ${_vtk_build_kit} kit
namespace "
2419 "(${_vtk_build_namespace}).
")
2421 if (NOT _vtk_build_kit STREQUAL _vtk_build_target_name)
2422 add_library("${_vtk_build_kit}
" ALIAS
2423 "${_vtk_build_target_name}
")
2425 _vtk_module_apply_properties("${_vtk_build_target_name}
")
2426 _vtk_module_install("${_vtk_build_target_name}
")
2428 set(_vtk_build_kit_modules_object_libraries)
2429 set(_vtk_build_kit_modules_private_depends)
2431 get_property(_vtk_build_kit_modules GLOBAL
2432 PROPERTY "_vtk_kit_${_vtk_build_kit}_kit_modules
")
2433 foreach (_vtk_build_kit_module IN LISTS _vtk_build_kit_modules)
2434 get_property(_vtk_build_kit_module_target_name GLOBAL
2435 PROPERTY "_vtk_module_${_vtk_build_kit_module}_target_name
")
2436 list(APPEND _vtk_build_kit_modules_object_libraries
2437 "${_vtk_build_kit_module_target_name}-objects
")
2439 # Since there is no link step for modules, we need to copy the private
2440 # dependencies of the constituent modules into the kit so that their
2441 # private dependencies are actually linked.
2442 get_property(_vtk_build_kit_module_private_depends GLOBAL
2443 PROPERTY "_vtk_module_${_vtk_build_kit_module}_private_depends
")
2444 # Also grab optional dependencies since they end up being private
2446 get_property(_vtk_build_kit_module_optional_depends GLOBAL
2447 PROPERTY "_vtk_module_${_vtk_build_kit_module}_optional_depends
")
2448 foreach (_vtk_build_kit_module_private_depend IN LISTS _vtk_build_kit_module_private_depends _vtk_build_kit_module_optional_depends)
2449 if (NOT TARGET "${_vtk_build_kit_module_private_depend}
")
2453 # But we don't need to link to modules that are part of the kit we are
2455 if (NOT _vtk_build_kit_module_private_depend IN_LIST _vtk_build_kit_modules)
2456 list(APPEND _vtk_build_kit_modules_private_depends
2457 "$<LINK_ONLY:${_vtk_build_kit_module_private_depend}>
")
2462 get_property(_vtk_build_kit_private_links GLOBAL
2463 PROPERTY "_vtk_kit_${_vtk_build_kit}_private_links
")
2465 if (_vtk_build_kit_modules_private_depends)
2466 list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_depends)
2468 if (_vtk_build_kit_modules_private_links)
2469 list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_links)
2472 target_link_libraries("${_vtk_build_target_name}
"
2474 ${_vtk_build_kit_modules_object_libraries}
2475 ${_vtk_build_kit_modules_private_depends}
2476 ${_vtk_build_kit_private_links})
2477 get_property(_vtk_build_kit_library_name GLOBAL
2478 PROPERTY "_vtk_kit_${_vtk_build_kit}_library_name
")
2479 if (_vtk_build_LIBRARY_NAME_SUFFIX)
2480 string(APPEND _vtk_build_kit_library_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}
")
2482 set_target_properties("${_vtk_build_target_name}
"
2484 OUTPUT_NAME "${_vtk_build_kit_library_name}
")
2488 set(_vtk_build_properties_filename "${_vtk_build_PACKAGE}-
vtk-module-properties.cmake
")
2489 set(_vtk_build_properties_install_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_build_properties_filename}.install
")
2490 set(_vtk_build_properties_build_file "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_properties_filename}
")
2492 file(WRITE "${_vtk_build_properties_build_file}
")
2494 _vtk_module_write_import_prefix(
2495 "${_vtk_build_properties_install_file}
"
2496 "${_vtk_build_CMAKE_DESTINATION}
")
2498 foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2499 get_property(_vtk_build_namespace GLOBAL
2500 PROPERTY "_vtk_module_${_vtk_build_module}_namespace
")
2501 if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>
")
2502 set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}
")
2504 if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2506 "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the
"
2507 "same as the ${_vtk_build_module} module
namespace "
2508 "(${_vtk_build_namespace}).
")
2511 get_property(_vtk_build_is_third_party
2512 TARGET "${_vtk_build_module}
"
2513 PROPERTY "INTERFACE_vtk_module_third_party
")
2514 if (_vtk_build_is_third_party)
2515 _vtk_module_export_properties(
2516 BUILD_FILE "${_vtk_build_properties_build_file}
"
2517 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2518 MODULE "${_vtk_build_module}
"
2519 FROM_GLOBAL_PROPERTIES
2520 # Export the dependencies of a module.
2524 # The library name of the module.
2527 # Export whether a module is third party or not.
2528 INTERFACE_vtk_module_third_party
2529 INTERFACE_vtk_module_exclude_wrap)
2533 set(_vtk_build_split_properties)
2534 get_property(_vtk_build_exclude_wrap
2535 TARGET "${_vtk_build_module}
"
2536 PROPERTY "INTERFACE_vtk_module_${_vtk_build_module}_exclude_wrap
")
2537 if (NOT _vtk_build_exclude_wrap)
2538 list(APPEND _vtk_build_split_properties
2540 if (_vtk_build_ENABLE_WRAPPING)
2541 list(APPEND _vtk_build_split_properties
2546 set(_vtk_build_properties_kit_properties)
2547 if (_vtk_build_BUILD_WITH_KITS)
2548 list(APPEND _vtk_build_properties_kit_properties
2549 # Export the kit membership of a module.
2553 _vtk_module_export_properties(
2554 BUILD_FILE "${_vtk_build_properties_build_file}
"
2555 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2556 MODULE "${_vtk_build_module}
"
2557 FROM_GLOBAL_PROPERTIES
2558 # Export whether the module should be excluded from wrapping or not.
2560 # Export the dependencies of a module.
2564 # Export what modules are implemented by the module.
2566 # Export whether the module contains autoinit logic.
2568 # The library name of the module.
2570 ${_vtk_build_properties_kit_properties}
2572 # Export whether the module needs autoinit logic handled.
2573 INTERFACE_vtk_module_needs_autoinit
2574 # Forward private usage requirements with global effects.
2575 INTERFACE_vtk_module_forward_link
2576 SPLIT_INSTALL_PROPERTIES
2577 # Set the properties which differ between build and install trees.
2578 ${_vtk_build_split_properties})
2581 if (_vtk_build_BUILD_WITH_KITS)
2582 foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2583 _vtk_module_export_properties(
2584 BUILD_FILE "${_vtk_build_properties_build_file}
"
2585 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2586 KIT "${_vtk_build_kit}
"
2587 FROM_GLOBAL_PROPERTIES
2588 # Export the list of modules in the kit.
2593 if (_vtk_build_INSTALL_EXPORT AND _vtk_build_INSTALL_HEADERS)
2594 set(_vtk_build_namespace)
2595 if (_vtk_build_TARGET_NAMESPACE)
2596 set(_vtk_build_namespace
2597 NAMESPACE "${_vtk_build_TARGET_NAMESPACE}::
")
2601 EXPORT "${_vtk_build_INSTALL_EXPORT}
"
2602 ${_vtk_build_namespace}
2603 FILE "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_PACKAGE}-targets.cmake
")
2605 EXPORT "${_vtk_build_INSTALL_EXPORT}
"
2606 DESTINATION "${_vtk_build_CMAKE_DESTINATION}
"
2607 ${_vtk_build_namespace}
2608 FILE "${_vtk_build_PACKAGE}-targets.cmake
"
2609 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
2611 if (_vtk_build_INSTALL_HEADERS)
2612 file(APPEND "${_vtk_build_properties_install_file}
"
2613 "unset(_vtk_module_import_prefix)\n
")
2616 FILES "${_vtk_build_properties_install_file}
"
2617 DESTINATION "${_vtk_build_CMAKE_DESTINATION}
"
2618 RENAME "${_vtk_build_properties_filename}
"
2619 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
2623 get_property(_vtk_build_test_modules GLOBAL
2624 PROPERTY "_vtk_module_test_modules
")
2625 set(_vtk_build_tests_handled)
2626 foreach (_vtk_build_test IN LISTS _vtk_build_test_modules)
2627 if (NOT _vtk_build_test IN_LIST _vtk_build_MODULES)
2630 list(APPEND _vtk_build_tests_handled
2631 "${_vtk_build_test}
")
2633 get_property(_vtk_build_test_depends GLOBAL
2634 PROPERTY "_vtk_module_${_vtk_build_test}_test_depends
")
2636 set(_vtk_build_test_has_depends TRUE)
2637 foreach (_vtk_build_test_depend IN LISTS _vtk_build_test_depends)
2638 if (NOT TARGET "${_vtk_build_test_depend}
")
2639 set(_vtk_build_test_has_depends FALSE)
2640 _vtk_module_debug(testing "@_vtk_build_test@ testing disabled due to missing @_vtk_build_test_depend
@")
2643 if (NOT _vtk_build_test_has_depends)
2647 get_property(_vtk_build_module_file GLOBAL
2648 PROPERTY "_vtk_module_${_vtk_build_test}_file
")
2650 if (NOT _vtk_build_TEST_DIRECTORY_NAME STREQUAL "NONE
")
2651 get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}
" DIRECTORY)
2652 file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}
" "${_vtk_build_module_dir}
")
2653 if (EXISTS "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
")
2654 get_property(_vtk_build_test_labels GLOBAL
2655 PROPERTY "_vtk_module_${_vtk_build_test}_test_labels
")
2657 "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
"
2658 "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
")
2663 if (_vtk_build_test_modules AND _vtk_build_tests_handled)
2664 list(REMOVE_ITEM _vtk_build_test_modules
2665 ${_vtk_build_tests_handled})
2668 _vtk_module_test_modules "${_vtk_build_test_modules}
")
2673 @ingroup module-impl
2674 @brief Add "standard
" include directories to a module
2676 Add the "standard
" includes for a module to its interface. These are the source
2677 and build directories for the module itself. They are always either `PUBLIC` or
2678 `INTERFACE` (depending on the module's target type).
2681 _vtk_module_standard_includes(
2685 [HEADERS_DESTINATION <destination>])
2688 function (_vtk_module_standard_includes)
2689 cmake_parse_arguments(_vtk_standard_includes
2691 "TARGET;HEADERS_DESTINATION
"
2695 if (NOT _vtk_standard_includes_TARGET)
2697 "The `TARGET` argument is required.
")
2699 if (NOT TARGET "${_vtk_standard_includes_TARGET}
")
2701 "The `TARGET` argument is not a
target.
")
2704 if (_vtk_standard_includes_UNPARSED_ARGUMENTS)
2706 "Unparsed arguments
for vtk_module_standard_includes:
"
2707 "${_vtk_standard_includes_UNPARSED_ARGUMENTS}
")
2710 set(_vtk_standard_includes_system)
2711 if (_vtk_standard_includes_SYSTEM)
2712 set(_vtk_standard_includes_system SYSTEM)
2715 set(_vtk_standard_includes_visibility PUBLIC)
2716 if (_vtk_standard_includes_INTERFACE)
2717 set(_vtk_standard_includes_visibility INTERFACE)
2720 target_include_directories("${_vtk_standard_includes_TARGET}
"
2721 ${_vtk_standard_includes_system}
2722 "${_vtk_standard_includes_visibility}
"
2723 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
2724 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
2726 if (_vtk_build_INSTALL_HEADERS AND _vtk_standard_includes_HEADERS_DESTINATION)
2727 target_include_directories("${_vtk_standard_includes_TARGET}
"
2728 ${_vtk_standard_includes_system}
2729 "${_vtk_standard_includes_visibility}
"
2730 $<INSTALL_INTERFACE:${_vtk_standard_includes_HEADERS_DESTINATION}>)
2735 @ingroup module-impl
2736 @brief Determine the default export macro for a module
2738 Determines the export macro to be used for a module from its metadata. Assumes
2739 it is called from within a @ref vtk_module_build call.
2742 _vtk_module_default_library_name(<varname>)
2745 function (_vtk_module_default_export_macro_prefix varname)
2746 get_property(_vtk_module_default_library_name GLOBAL
2747 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
2748 string(TOUPPER "${_vtk_module_default_library_name}
" _vtk_default_export_macro_upper)
2750 "${_vtk_default_export_macro_upper}
"
2754 # TODO: It would be nice to support `USE_LINK_PROPERTIES` instead of listing
2755 # the modules again here. However, the format of the `LINK_LIBRARIES` property
2756 # value may not be easy to handle.
2759 @page module-overview
2762 @section module-autoinit Autoinit
2764 When a module contains a factory which may be populated by other modules, these
2765 factories need to be populated when the modules are loaded by the dynamic linker
2766 (for shared builds) or program load time (for static builds). To provide for
2767 this, the module system contains an autoinit "subsystem
".
2769 @subsection module-autoinit-leverage Leveraging the autoinit subsystem
2771 The subsystem provides the following hooks for use by projects:
2773 * In modules which `IMPLEMENTS` other modules, in the generated
2774 `<module>Module.h` header (which provides export symbols as well) will
2775 include the modules which are implemented.
2776 * In modules which are `IMPLEMENTABLE` or `IMPLEMENTS` another module, the
2777 generated `<module>Module.h` file will include the following block:
2780 #ifdef <module>_AUTOINIT_INCLUDE
2781 #include <module>_AUTOINIT_INCLUDE
2783 #ifdef <module>_AUTOINIT
2785 VTK_MODULE_AUTOINIT(<module>)
2789 The @ref vtk_module_autoinit function will generate an include file and provide
2790 its path via the `<module>_AUTOINIT_INCLUDE` define. once it has been included,
2791 if the `<module>_AUTOINIT` symbol is defined, a header is included which is
2792 intended to provide the `VTK_MODULE_AUTOINIT` macro. This macro is given the
2793 module name and should use `<module>_AUTOINIT` to fill in the factories in the
2794 module with those from the `IMPLEMENTS` modules listed in that symbol.
2796 The `<module>_AUTOINIT` symbol's value is:
2799 <count>(<module1>,<module2>,<module3>)
2802 where `<count>` is the number of modules in the parentheses and each module
2803 listed need to register something to `<module>`.
2805 If not provided via the `AUTOINIT_INCLUDE` argument to the
2806 @ref vtk_module_add_module function, the header to use is fetched from the
2807 `_vtk_module_autoinit_include` global property. This only needs to be managed
2808 in modules that `IMPLEMENTS` or are `IMPLEMENTABLE`. This should be provided by
2809 projects using the module system at its lowest level. Projects not implementing
2810 the `VTK_MODULE_AUTOINIT` macro should have its value provided by
2811 `find_package` dependencies in some way.
2816 @brief Linking to autoinit-using modules
2818 When linking to modules, in order for the autoinit system to work, modules need
2819 to declare their registration. In order to do this, defines may need to be
2820 provided to targets in order to trigger registration. These defines may be
2821 added to targets by using this function.
2824 vtk_module_autoinit(
2826 MODULES <module>...)
2829 After this call, the targets given to the `TARGETS` argument will gain the
2830 preprocessor definitions to trigger registrations properly.
2832 function (vtk_module_autoinit)
2833 cmake_parse_arguments(_vtk_autoinit
2839 if (_vtk_autoinit_UNRECOGNIZED_ARGUMENTS)
2842 "${_vtk_autoinit_UNRECOGNIZED_ARGUMENTS}.
")
2845 if (NOT _vtk_autoinit_TARGETS)
2847 "The `TARGETS` argument is required.
")
2850 if (NOT _vtk_autoinit_MODULES)
2851 message(AUTHOR_WARNING
2852 "No `MODULES` passed to `vtk_modules_autoinit`.
")
2855 set(_vtk_autoinit_module_stack
2856 ${_vtk_autoinit_TARGETS})
2858 set(_vtk_autoinit_needs_implements)
2859 set(_vtk_autoinit_seen)
2860 while (_vtk_autoinit_module_stack)
2861 list(GET _vtk_autoinit_module_stack 0 _vtk_autoinit_current_module)
2862 list(REMOVE_AT _vtk_autoinit_module_stack 0)
2863 if (_vtk_autoinit_current_module IN_LIST _vtk_autoinit_seen)
2866 list(APPEND _vtk_autoinit_seen
2867 "${_vtk_autoinit_current_module}
")
2869 set(_vtk_autoinit_current_target "${_vtk_autoinit_current_module}
")
2870 get_property(_vtk_autoinit_implements
2871 TARGET "${_vtk_autoinit_current_target}
"
2872 PROPERTY "INTERFACE_vtk_module_implements
")
2874 list(APPEND _vtk_autoinit_needs_implements
2875 ${_vtk_autoinit_current_target})
2876 foreach (_vtk_autoinit_implement IN LISTS _vtk_autoinit_implements)
2877 _vtk_module_real_target(_vtk_autoinit_implements_target "${_vtk_autoinit_implement}
")
2878 get_property(_vtk_autoinit_implementable
2879 TARGET "${_vtk_autoinit_implements_target}
"
2880 PROPERTY "INTERFACE_vtk_module_implementable
")
2882 if (NOT _vtk_autoinit_implementable)
2884 "The `${_vtk_autoinit_current_module}` module says that it
"
2885 "implements the `${_vtk_autoinit_implement}` module, but it is not
"
2889 list(APPEND "_vtk_autoinit_implements_${_vtk_autoinit_current_target}
"
2890 "${_vtk_autoinit_current_module}
")
2894 if (NOT _vtk_autoinit_needs_implements)
2897 list(REMOVE_DUPLICATES _vtk_autoinit_needs_implements)
2898 list(SORT _vtk_autoinit_needs_implements)
2900 set(_vtk_autoinit_hash_content)
2901 foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
2902 if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
2905 list(SORT "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
")
2907 string(APPEND _vtk_autoinit_hash_content
2908 "${_vtk_autoinit_need_implements}: ${_vtk_autoinit_implements_${_vtk_autoinit_need_implements}}\n
")
2910 string(MD5 _vtk_autoinit_header_tag "${_vtk_autoinit_hash_content}
")
2911 set(_vtk_autoinit_header
2912 "${CMAKE_BINARY_DIR}/CMakeFiles/vtkModuleAutoInit_${_vtk_autoinit_header_tag}.h
")
2914 get_property(_vtk_autoinit_header_generated GLOBAL
2915 PROPERTY "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}
")
2917 set(_vtk_autoinit_defines)
2918 set(_vtk_autoinit_header_content)
2919 foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
2920 if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
2924 get_property(_vtk_autoinit_implements_library_name
2925 TARGET "${_vtk_autoinit_need_implements}
"
2926 PROPERTY "INTERFACE_vtk_module_library_name
")
2928 if (NOT _vtk_autoinit_header_generated)
2929 list(LENGTH "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
"
2930 _vtk_autoinit_length)
2931 set(_vtk_autoinit_args)
2932 foreach (_vtk_autoinit_arg IN LISTS "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
")
2933 get_property(_vtk_autoinit_arg_library_name
2934 TARGET "${_vtk_autoinit_arg}
"
2935 PROPERTY "INTERFACE_vtk_module_library_name
")
2936 list(APPEND _vtk_autoinit_args
2937 "${_vtk_autoinit_arg_library_name}
")
2939 string(REPLACE ";
" ",
" _vtk_autoinit_args "${_vtk_autoinit_args}
")
2940 string(APPEND _vtk_autoinit_header_content
2941 "#define ${_vtk_autoinit_implements_library_name}_AUTOINIT ${_vtk_autoinit_length}(${_vtk_autoinit_args})\n
")
2944 list(APPEND _vtk_autoinit_defines
2945 "${_vtk_autoinit_implements_library_name}_AUTOINIT_INCLUDE=\
"${_vtk_autoinit_header}\"")
2948 if (NOT _vtk_autoinit_header_generated)
2950 OUTPUT "${_vtk_autoinit_header}
"
2951 CONTENT "${_vtk_autoinit_header_content}
")
2955 "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}
" TRUE)
2958 foreach (_vtk_autoinit_target IN LISTS _vtk_autoinit_TARGETS)
2959 get_property(_vtk_autoinit_target_type
2960 TARGET "${_vtk_autoinit_target}
"
2962 if (_vtk_autoinit_target_type STREQUAL "INTERFACE_LIBRARY
")
2966 _vtk_module_real_target(_vtk_autoinit_real_target "${_vtk_autoinit_target}
")
2968 target_compile_definitions("${_vtk_autoinit_real_target}
"
2970 ${_vtk_autoinit_defines})
2975 @ingroup module-impl
2976 @brief Generate the hierarchy for a module
2978 Write wrap hierarchy files for the module currently being built. This also
2979 installs the hierarchy file for use by dependent projects if `INSTALL_HEADERS`
2983 _vtk_module_write_wrap_hierarchy()
2986 function (_vtk_module_write_wrap_hierarchy)
2987 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}
")
2989 get_property(_vtk_hierarchy_library_name GLOBAL
2990 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
2991 set(_vtk_hierarchy_filename "${_vtk_hierarchy_library_name}-hierarchy.txt
")
2992 set(_vtk_hierarchy_file "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}
")
2993 set(_vtk_hierarchy_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.$<CONFIGURATION>.args
")
2994 set(_vtk_hierarchy_data_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.data
")
2995 set(_vtk_hierarchy_depends_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.depends.args
")
2997 set_property(TARGET "${_vtk_add_module_real_target}
"
2999 "INTERFACE_vtk_module_hierarchy
" "${_vtk_hierarchy_file}
")
3001 set(_vtk_add_module_target_name_iface "${_vtk_add_module_target_name}
")
3002 if (_vtk_add_module_build_with_kit)
3003 set(_vtk_add_module_target_name_iface "${_vtk_add_module_target_name}-objects
")
3005 set(_vtk_hierarchy_genex_compile_definitions
3006 "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},COMPILE_DEFINITIONS>
")
3007 set(_vtk_hierarchy_genex_include_directories
3008 "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},INCLUDE_DIRECTORIES>
")
3010 OUTPUT "${_vtk_hierarchy_args_file}
"
3011 CONTENT "$<$<BOOL:${_vtk_hierarchy_genex_compile_definitions}>:\n-D\
'$<JOIN:${_vtk_hierarchy_genex_compile_definitions},\'\n-D\'>\'>\n
3012 $<$<BOOL:${_vtk_hierarchy_genex_include_directories}>:\n-I\'$<JOIN:${_vtk_hierarchy_genex_include_directories},\'\n-I\'>\'>\n")
3014 get_property(_vtk_hierarchy_depends_is_global GLOBAL
3015 PROPERTY "_vtk_module_${_vtk_build_module}_depends"
3017 if (_vtk_hierarchy_depends_is_global)
3018 get_property(_vtk_hierarchy_depends GLOBAL
3019 PROPERTY "_vtk_module_${_vtk_build_module}_depends")
3021 get_property(_vtk_hierarchy_depends GLOBAL
3022 TARGET "${_vtk_add_module_real_target}"
3023 PROPERTY "INTERFACE_vtk_module_depends")
3026 set(_vtk_hierarchy_depends_files)
3027 set(_vtk_hierarchy_depends_targets)
3028 foreach (_vtk_hierarchy_depend IN LISTS _vtk_hierarchy_depends)
3029 _vtk_module_get_module_property("${_vtk_hierarchy_depend}"
3030 PROPERTY "hierarchy"
3031 VARIABLE _vtk_hierarchy_depend_hierarchy)
3032 if (NOT DEFINED _vtk_hierarchy_depend_hierarchy)
3036 list(APPEND _vtk_hierarchy_depends_files
3037 "${_vtk_hierarchy_depend_hierarchy}")
3039 # Find the hierarchy target of the module.
3040 get_property(_vtk_hierarchy_module_is_imported
3041 TARGET "${_vtk_hierarchy_depend}"
3043 # Imported target modules are external and should already have their file
3045 if (_vtk_hierarchy_module_is_imported)
3049 get_property(_vtk_hierarchy_depend_library_name GLOBAL
3050 PROPERTY "_vtk_module_${_vtk_hierarchy_depend}_library_name")
3051 if (TARGET "${_vtk_hierarchy_depend_library_name}-hierarchy")
3052 list(APPEND _vtk_hierarchy_depends_targets
3053 "${_vtk_hierarchy_depend_library_name}-hierarchy")
3057 set(_vtk_hierarchy_depends_files_arg)
3058 if (_vtk_hierarchy_depends_files)
3060 OUTPUT "${_vtk_hierarchy_depends_args_file}"
3061 CONTENT "\"$<JOIN:${_vtk_hierarchy_depends_files},\"\n\">\"\n")
3064 OUTPUT "${_vtk_hierarchy_depends_args_file}"
3068 _vtk_module_get_module_property("${_vtk_build_module}"
3070 VARIABLE _vtk_hierarchy_headers)
3071 set(_vtk_hierarchy_data_content "")
3072 foreach (_vtk_hierarchy_header IN LISTS _vtk_hierarchy_headers)
3073 string(APPEND _vtk_hierarchy_data_content
3074 "${_vtk_hierarchy_header};${_vtk_hierarchy_library_name}\n")
3077 OUTPUT "${_vtk_hierarchy_data_file}"
3078 CONTENT "${_vtk_hierarchy_data_content}")
3080 if (CMAKE_GENERATOR MATCHES "Ninja")
3081 set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_files})
3083 set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_targets})
3086 set(_vtk_hierarchy_tool_target "VTK::WrapHierarchy")
3087 set(_vtk_hierarchy_macros_args)
3088 if (TARGET VTKCompileTools::WrapHierarchy)
3089 set(_vtk_hierarchy_tool_target "VTKCompileTools::WrapHierarchy")
3090 if (TARGET VTKCompileTools_macros)
3091 list(APPEND _vtk_hierarchy_command_depends
3092 "VTKCompileTools_macros")
3093 list(APPEND _vtk_hierarchy_macros_args
3095 -imacros "${_VTKCompileTools_macros_file}")
3100 OUTPUT "${_vtk_hierarchy_file}"
3101 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
3102 "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>"
3103 "@${_vtk_hierarchy_args_file}"
3104 -o "${_vtk_hierarchy_file}"
3105 "${_vtk_hierarchy_data_file}"
3106 "@${_vtk_hierarchy_depends_args_file}"
3107 ${_vtk_hierarchy_macros_args}
3108 COMMENT "Generating the wrap hierarchy for ${_vtk_build_module}"
3110 ${_vtk_hierarchy_headers}
3111 "${_vtk_hierarchy_args_file}"
3112 "${_vtk_hierarchy_data_file}"
3113 "${_vtk_hierarchy_depends_args_file}"
3114 ${_vtk_hierarchy_command_depends})
3115 add_custom_target("${_vtk_add_module_library_name}-hierarchy" ALL
3117 "${_vtk_hierarchy_file}"
3118 "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>")
3119 set_property(TARGET "${_vtk_add_module_real_target}"
3121 "INTERFACE_vtk_module_hierarchy" "${_vtk_hierarchy_file}")
3123 if (_vtk_build_INSTALL_HEADERS)
3124 set_property(TARGET "${_vtk_add_module_real_target}"
3126 "INTERFACE_vtk_module_hierarchy_install" "\${_vtk_module_import_prefix}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}")
3128 FILES "${_vtk_hierarchy_file}"
3129 DESTINATION "${_vtk_build_HIERARCHY_DESTINATION}"
3130 RENAME "${_vtk_hierarchy_filename}"
3131 COMPONENT "${_vtk_build_HEADERS_COMPONENT}")
3135 include(GenerateExportHeader)
3139 @brief Create a module library
3142 vtk_module_add_module(<name>
3143 [FORCE_STATIC] [HEADER_ONLY]
3144 [EXPORT_MACRO_PREFIX <prefix>]
3145 [HEADERS_SUBDIR <subdir>]
3146 [LIBRARY_NAME_SUFFIX <suffix>]
3147 [CLASSES <class>...]
3148 [TEMPLATE_CLASSES <template class>...]
3149 [SOURCES <source>...]
3150 [HEADERS <header>...]
3151 [TEMPLATES <template>...]
3152 [PRIVATE_CLASSES <class>...]
3153 [PRIVATE_TEMPLATE_CLASSES <template class>...]
3154 [PRIVATE_HEADERS <header>...]
3155 [PRIVATE_TEMPLATES <template>...])
3158 The `PRIVATE_` arguments are analogous to their non-`PRIVATE_` arguments, but
3159 the associated files are not installed or available for wrapping (`SOURCES` are
3160 always private, so there is no `PRIVATE_` variant for that argument).
3162 * `FORCE_STATIC`: For a static library to be created. If not provided,
3163 `BUILD_SHARED_LIBS` will control the library type.
3164 * `HEADER_ONLY`: The module only contains headers (or templates) and contains
3165 no compilation steps. Mutually exclusive with `FORCE_STATIC`.
3166 * `EXPORT_MACRO_PREFIX`: The prefix for the export macro definitions.
3167 Defaults to the library name of the module in all uppercase.
3168 * `HEADERS_SUBDIR`: The subdirectory to install headers into in the install
3170 * `LIBRARY_NAME_SUFFIX`: The suffix to the module's library
name if
3171 additional information is required.
3172 * `CLASSES`: A list of classes in the module. This is a shortcut
for adding
3173 `<
class>.cxx` to `SOURCES` and `<
class>.h` to `HEADERS`.
3174 * `TEMPLATE_CLASSES`: A list of
template classes in the module. This is a
3175 shortcut
for adding `<
class>.txx` to `TEMPLATES` and `<
class>.h` to
3177 * `SOURCES`: A list of
source files which require compilation.
3178 * `HEADERS`: A list of header files which will be available
for wrapping and
3180 * `TEMPLATES`: A list of
template files which will be installed.
3183 if (NOT
name STREQUAL _vtk_build_module)
3185 "The ${_vtk_build_module}'s CMakeLists.txt may not add the ${name} module.")
3188 set(_vtk_add_module_source_keywords)
3189 foreach (_vtk_add_module_kind IN ITEMS CLASSES TEMPLATE_CLASSES HEADERS TEMPLATES)
3190 list(APPEND _vtk_add_module_source_keywords
3191 "${_vtk_add_module_kind}
"
3192 "PRIVATE_${_vtk_add_module_kind}
")
3195 cmake_parse_arguments(_vtk_add_module
3196 "FORCE_STATIC;HEADER_ONLY
"
3197 "EXPORT_MACRO_PREFIX;HEADERS_SUBDIR;LIBRARY_NAME_SUFFIX
"
3198 "${_vtk_add_module_source_keywords};SOURCES
"
3201 if (_vtk_add_module_UNPARSED_ARGUMENTS)
3204 "${_vtk_add_module_UNPARSED_ARGUMENTS}
")
3207 if (NOT DEFINED _vtk_add_module_EXPORT_MACRO_PREFIX)
3208 _vtk_module_default_export_macro_prefix(_vtk_add_module_EXPORT_MACRO_PREFIX)
3211 if (_vtk_add_module_HEADER_ONLY AND _vtk_add_module_FORCE_STATIC)
3213 "The ${_vtk_build_module} module cannot be header only yet forced
"
3217 foreach (_vtk_add_module_class IN LISTS _vtk_add_module_CLASSES)
3218 list(APPEND _vtk_add_module_SOURCES
3219 "${_vtk_add_module_class}.cxx
")
3220 list(APPEND _vtk_add_module_HEADERS
3221 "${_vtk_add_module_class}.h
")
3224 foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_TEMPLATE_CLASSES)
3225 list(APPEND _vtk_add_module_TEMPLATES
3226 "${_vtk_add_module_template_class}.txx
")
3227 list(APPEND _vtk_add_module_HEADERS
3228 "${_vtk_add_module_template_class}.h
")
3231 foreach (_vtk_add_module_class IN LISTS _vtk_add_module_PRIVATE_CLASSES)
3232 list(APPEND _vtk_add_module_SOURCES
3233 "${_vtk_add_module_class}.cxx
")
3234 list(APPEND _vtk_add_module_PRIVATE_HEADERS
3235 "${_vtk_add_module_class}.h
")
3238 foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_PRIVATE_TEMPLATE_CLASSES)
3239 list(APPEND _vtk_add_module_PRIVATE_TEMPLATES
3240 "${_vtk_add_module_template_class}.txx
")
3241 list(APPEND _vtk_add_module_PRIVATE_HEADERS
3242 "${_vtk_add_module_template_class}.h
")
3245 if (NOT _vtk_add_module_SOURCES AND NOT _vtk_add_module_HEADER_ONLY)
3247 "The ${_vtk_build_module} module has no
source files.
")
3250 get_property(_vtk_add_module_third_party GLOBAL
3251 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
3253 get_property(_vtk_add_module_library_name GLOBAL
3254 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
3255 set(_vtk_add_module_module_header_name
3256 "${_vtk_add_module_library_name}Module.h
")
3257 if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3258 set(_vtk_add_module_generated_header
3259 "${CMAKE_CURRENT_BINARY_DIR}/${_vtk_add_module_module_header_name}
")
3260 list(APPEND _vtk_add_module_HEADERS
3261 "${_vtk_add_module_generated_header}
")
3264 vtk_module_install_headers(
3265 FILES ${_vtk_add_module_HEADERS}
3266 ${_vtk_add_module_TEMPLATES}
3267 SUBDIR "${_vtk_add_module_HEADERS_SUBDIR}
")
3269 set(_vtk_add_module_type)
3270 if (_vtk_add_module_FORCE_STATIC)
3271 set(_vtk_add_module_type STATIC)
3274 set(_vtk_add_module_build_with_kit)
3275 if (_vtk_build_BUILD_WITH_KITS)
3276 get_property(_vtk_add_module_build_with_kit GLOBAL
3277 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
3280 get_property(_vtk_add_module_namespace GLOBAL
3281 PROPERTY "_vtk_module_${_vtk_build_module}_namespace
")
3282 get_property(_vtk_add_module_target_name GLOBAL
3283 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
3284 set(_vtk_add_module_real_target "${_vtk_add_module_target_name}
")
3285 if (_vtk_add_module_HEADER_ONLY)
3286 if (_vtk_add_module_build_with_kit)
3288 "The module ${_vtk_build_module} is header-only, but is part of the
"
3289 "${_vtk_add_module_build_with_kit} kit. Header-only modules
do not
"
3293 # XXX(cmake-3.12.0): This unset is no longer necessary when 3.12.0 is required.
3294 unset("${_vtk_build_module}_LIB_DEPENDS
" CACHE)
3295 add_library("${_vtk_add_module_real_target}
" INTERFACE)
3297 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3298 add_library("${_vtk_build_module}
" ALIAS
3299 "${_vtk_add_module_real_target}
")
3302 if (_vtk_add_module_build_with_kit)
3303 add_library("${_vtk_add_module_real_target}
" INTERFACE)
3304 target_link_libraries("${_vtk_add_module_real_target}
"
3306 # For usage requirements.
3307 "${_vtk_add_module_real_target}-objects
"
3308 # For the implementation.
3309 "$<LINK_ONLY:${_vtk_add_module_build_with_kit}>
")
3311 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3312 add_library("${_vtk_build_module}
" ALIAS
3313 "${_vtk_add_module_real_target}
")
3316 # Set up properties necessary for other infrastructure.
3317 set_property(TARGET "${_vtk_add_module_real_target}
"
3319 "INTERFACE_vtk_module_library_name
" "${_vtk_add_module_library_name}
")
3321 # XXX(cmake-3.12.0): This unset is no longer necessary when 3.12.0 is required.
3322 unset("${_vtk_build_module}_LIB_DEPENDS
" CACHE)
3323 add_library("${_vtk_add_module_real_target}-objects
" OBJECT
3324 ${_vtk_add_module_SOURCES}
3325 ${_vtk_add_module_TEMPLATES}
3326 ${_vtk_add_module_PRIVATE_TEMPLATES}
3327 ${_vtk_add_module_HEADERS}
3328 ${_vtk_add_module_PRIVATE_HEADERS})
3329 set_target_properties("${_vtk_add_module_real_target}-objects
"
3331 # Emulate the regular library as much as possible.
3332 DEFINE_SYMBOL "${_vtk_add_module_real_target}_EXPORT
"
3333 POSITION_INDEPENDENT_CODE ON)
3334 target_compile_definitions("${_vtk_add_module_real_target}-objects
"
3336 "${_vtk_add_module_real_target}_EXPORT
")
3337 set(_vtk_add_module_real_target "${_vtk_add_module_real_target}-objects
")
3339 add_library("${_vtk_add_module_real_target}
" ${_vtk_add_module_type}
3340 ${_vtk_add_module_SOURCES}
3341 ${_vtk_add_module_TEMPLATES}
3342 ${_vtk_add_module_HEADERS}
3343 ${_vtk_add_module_PRIVATE_HEADERS})
3345 set_property(TARGET "${_vtk_add_module_real_target}
"
3347 POSITION_INDEPENDENT_CODE ON)
3349 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3350 add_library("${_vtk_build_module}
" ALIAS
3351 "${_vtk_add_module_real_target}
")
3356 set_property(TARGET "${_vtk_add_module_real_target}
"
3358 "INTERFACE_vtk_module_library_name
" "${_vtk_add_module_library_name}
")
3360 get_property(_vtk_add_module_depends GLOBAL
3361 PROPERTY "_vtk_module_${_vtk_build_module}_depends
")
3362 set_property(TARGET "${_vtk_add_module_real_target}
"
3364 "INTERFACE_vtk_module_depends
" "${_vtk_add_module_depends}
")
3365 set(_vtk_add_module_includes_interface)
3366 if (_vtk_add_module_HEADER_ONLY)
3367 target_link_libraries("${_vtk_add_module_real_target}
"
3369 ${_vtk_add_module_depends})
3370 set(_vtk_add_module_includes_interface INTERFACE)
3372 get_property(_vtk_add_module_private_depends GLOBAL
3373 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends
")
3375 # XXX(cmake#18484): Linking dependencies directly currently creates
3376 # circular dependencies. This logic should be removed once the minimum for
3377 # kits contains a fix for the mentioned issue.
3379 # When two modules are part of the same kit, we can get this problem:
3381 # A - iface -> A-objects <- tll - K
3384 # B - iface -> B-objects <- tll -/
3386 # If B depends on A, it ends up with a circular dependency since A has a
3387 # `$<LINK_ONLY:K>` link. instead, munge up dependencies of intra-kit
3388 # dependencies to link to the `-objects` target instead.
3389 if (_vtk_add_module_build_with_kit)
3390 set(_vtk_add_module_depends_link)
3391 set(_vtk_add_module_private_depends_link)
3392 foreach (_vtk_add_module_depend IN LISTS _vtk_add_module_depends)
3393 get_property(_vtk_add_module_depend_kit GLOBAL
3394 PROPERTY "_vtk_module_${_vtk_add_module_depend}_kit
")
3395 if (_vtk_add_module_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3396 # We're in the same kit; depend on the `-objects` library of the
3398 get_property(_vtk_add_module_depend_target_name GLOBAL
3399 PROPERTY "_vtk_module_${_vtk_add_module_depend}_target_name
")
3400 list(APPEND _vtk_add_module_depends_link
3401 "${_vtk_add_module_depend_target_name}-objects
")
3403 # Different kit, just use as normal.
3404 list(APPEND _vtk_add_module_depends_link
3405 "${_vtk_add_module_depend}
")
3408 foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_private_depends)
3409 get_property(_vtk_add_module_private_depend_kit GLOBAL
3410 PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_kit
")
3411 if (_vtk_add_module_private_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3412 # We're in the same kit; depend on the `-objects` library of the
3414 get_property(_vtk_add_module_private_depend_target_name GLOBAL
3415 PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_target_name
")
3416 list(APPEND _vtk_add_module_private_depends_link
3417 "${_vtk_add_module_private_depend_target_name}-objects
")
3419 # Different kit, just use as normal.
3420 list(APPEND _vtk_add_module_private_depends_link
3421 "${_vtk_add_module_private_depend}
")
3425 # Add the `DEFINE_SYMBOL` for all other modules within the same kit which
3426 # have already been processed because the direct dependencies are not
3427 # sufficient: export symbols from any included header needs to be
3428 # correct. Since modules are built in topological order, a module can
3429 # only possibly include modules in the kit which have already been built.
3430 get_property(_vtk_add_module_kit_modules GLOBAL
3431 PROPERTY "_vtk_kit_${_vtk_add_module_build_with_kit}_kit_modules
")
3432 list(REMOVE_ITEM _vtk_add_module_kit_modules "${_vtk_build_module}
")
3433 foreach (_vtk_add_module_kit_module IN LISTS _vtk_add_module_kit_modules)
3434 get_property(_vtk_add_module_kit_module_target_name GLOBAL
3435 PROPERTY "_vtk_module_${_vtk_add_module_kit_module}_target_name
")
3436 if (TARGET "${_vtk_add_module_kit_module_target_name}-objects
")
3437 get_property(_vtk_add_module_kit_module_define_symbol
3438 TARGET "${_vtk_add_module_kit_module_target_name}-objects
"
3439 PROPERTY DEFINE_SYMBOL)
3440 target_compile_definitions("${_vtk_add_module_real_target}
"
3442 "${_vtk_add_module_kit_module_define_symbol}
")
3446 set(_vtk_add_module_depends_link ${_vtk_add_module_depends})
3447 set(_vtk_add_module_private_depends_link ${_vtk_add_module_private_depends})
3449 target_link_libraries("${_vtk_add_module_real_target}
"
3451 ${_vtk_add_module_depends_link}
3453 ${_vtk_add_module_private_depends_link})
3455 set(_vtk_add_module_private_depends_forward_link)
3456 foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_depends_link _vtk_add_module_private_depends)
3457 _vtk_module_get_module_property("${_vtk_add_module_private_depend}
"
3458 PROPERTY "forward_link
"
3459 VARIABLE _vtk_add_module_forward_link)
3460 list(APPEND _vtk_add_module_private_depends_forward_link
3461 ${_vtk_add_module_forward_link})
3464 get_property(_vtk_add_module_optional_depends GLOBAL
3465 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends
")
3466 foreach (_vtk_add_module_optional_depend IN LISTS _vtk_add_module_optional_depends)
3467 if (TARGET "${_vtk_add_module_optional_depend}
")
3468 set(_vtk_add_module_have_optional_depend 1)
3469 set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend}
")
3470 if (_vtk_add_module_build_with_kit)
3471 get_property(_vtk_add_module_optional_depend_kit GLOBAL
3472 PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_kit
")
3473 if (_vtk_add_module_optional_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3474 # We're in the same kit; depend on the `-objects` library of the
3475 # module to avoid circular dependency (see explanation earlier)
3476 get_property(_vtk_add_module_optional_depend_target_name GLOBAL
3477 PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_target_name
")
3478 set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend_target_name}-objects
")
3481 _vtk_module_get_module_property("${_vtk_add_module_optional_depend_link}
"
3482 PROPERTY "forward_link
"
3483 VARIABLE _vtk_add_module_forward_link)
3484 list(APPEND _vtk_add_module_private_depends_forward_link
3485 ${_vtk_add_module_forward_link})
3486 target_link_libraries("${_vtk_add_module_real_target}
"
3488 "${_vtk_add_module_optional_depend_link}
")
3490 set(_vtk_add_module_have_optional_depend 0)
3492 string(REPLACE "::
" "_
" _vtk_add_module_optional_depend_safe "${_vtk_add_module_optional_depend}
")
3493 target_compile_definitions("${_vtk_add_module_real_target}
"
3495 "VTK_MODULE_ENABLE_${_vtk_add_module_optional_depend_safe}=${_vtk_add_module_have_optional_depend}
")
3498 if (_vtk_add_module_private_depends_forward_link)
3499 list(REMOVE_DUPLICATES _vtk_add_module_private_depends_forward_link)
3500 _vtk_module_set_module_property("${_vtk_build_module}
" APPEND
3501 PROPERTY "forward_link
"
3502 VALUE "${_vtk_add_module_private_depends_forward_link}
")
3503 target_link_libraries("${_vtk_add_module_real_target}
"
3505 "${_vtk_add_module_private_depends_forward_link}
")
3508 _vtk_module_standard_includes(
3509 TARGET "${_vtk_add_module_real_target}
"
3510 ${_vtk_add_module_includes_interface}
3511 HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}
")
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}
")
3522 list(APPEND _vtk_add_module_headers_build
3523 "${CMAKE_CURRENT_SOURCE_DIR}/${_vtk_add_module_header}
")
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}
")
3531 set_property(TARGET "${_vtk_add_module_real_target}
"
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}
"
3537 "INTERFACE_vtk_module_headers_install
" "${_vtk_add_module_headers_install}
")
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}
"
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()
3549 set(_vtk_add_module_module_content)
3551 if (NOT _vtk_add_module_AUTOINIT_INCLUDE)
3552 get_property(_vtk_add_module_AUTOINIT_INCLUDE GLOBAL
3553 PROPERTY "_vtk_module_autoinit_include
")
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}
")
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
")
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
")
3577 if (NOT _vtk_add_module_depends_needs_autoinit)
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
")
3584 string(APPEND _vtk_add_module_autoinit_depends_includes
3585 "#include \
"${_vtk_add_module_depends_library_name}Module.h\"\n")
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}\n${_vtk_add_module_autoinit_depends_includes}\n
")
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}
"
3601 "INTERFACE_vtk_module_implementable
" 1)
3604 if (_vtk_add_module_implementable OR _vtk_add_module_implements)
3605 set_property(TARGET "${_vtk_add_module_real_target}
"
3607 "INTERFACE_vtk_module_implements
" "${_vtk_add_module_implements}
")
3608 set_property(TARGET "${_vtk_add_module_real_target}
"
3610 "INTERFACE_vtk_module_needs_autoinit
" 1)
3612 set(_vtk_add_module_autoinit_content
3613 "${_vtk_add_module_autoinit_content}
3615 #if !defined(__VTK_WRAP__)
3616 #ifdef ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3617 #include ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3619 #ifdef ${_vtk_add_module_library_name}_AUTOINIT
3620 ${_vtk_add_module_autoinit_include_header}
3626 set(_vtk_add_module_module_content
3627 "${_vtk_add_module_module_content}${_vtk_add_module_autoinit_content}
")
3630 vtk_module_autoinit(
3631 MODULES ${_vtk_add_module_depends}
3632 ${_vtk_add_module_private_depends}
3633 "${_vtk_build_module}
"
3634 TARGETS "${_vtk_build_module}
")
3636 if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3637 generate_export_header("${_vtk_add_module_real_target}
"
3638 EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_EXPORT
"
3639 NO_EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_EXPORT
"
3640 DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_DEPRECATED
"
3641 NO_DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_DEPRECATED
"
3642 STATIC_DEFINE "${_vtk_add_module_EXPORT_MACRO_PREFIX}_STATIC_DEFINE
"
3643 EXPORT_FILE_NAME "${_vtk_add_module_module_header_name}
"
3644 CUSTOM_CONTENT_FROM_VARIABLE _vtk_add_module_module_content)
3647 _vtk_module_apply_properties("${_vtk_add_module_target_name}
")
3648 _vtk_module_install("${_vtk_add_module_target_name}
")
3649 _vtk_module_add_header_tests()
3651 if (_vtk_add_module_build_with_kit)
3652 _vtk_module_install("${_vtk_add_module_target_name}-objects
")
3657 @ingroup module-impl
3658 @brief Add header tests for a module
3660 @todo Move this function out to be VTK-specific, probably into
3661 `vtkModuleTesting.cmake`. Each module would then need to manually call this
3662 function. It currently assumes it is in VTK itself.
3665 _vtk_module_add_header_tests()
3668 function (_vtk_module_add_header_tests)
3669 if (NOT BUILD_TESTING)
3673 get_property(_vtk_add_header_tests_is_third_party GLOBAL
3674 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
3675 if (_vtk_add_header_tests_is_third_party)
3679 # TODO: Add test compiles which include each header file to ensure that
3680 # public headers have their includes satisfied by a public dependency.
3683 if (NOT "Python${VTK_PYTHON_VERSION}_EXECUTABLE
")
3688 if (NOT VTK_SOURCE_DIR)
3693 NAME "${_vtk_build_module}-HeaderTest
"
3694 COMMAND "${Python${VTK_PYTHON_VERSION}_EXECUTABLE}
"
3695 # TODO: What to do when using this from a VTK install?
3696 "${VTK_SOURCE_DIR}/Testing/Core/HeaderTesting.py
"
3697 "${CMAKE_CURRENT_SOURCE_DIR}
"
3698 "${_vtk_add_module_EXPORT_MACRO}
")
3703 @brief Install headers
3705 Installing headers is done for normal modules by the @ref vtk_module_add_module
3706 function already. However, sometimes header structures are more complicated and
3707 need to be installed manually. This is common for third party modules or
3708 projects which use more than a single directory of headers for a module.
3710 To facilitate the installation of headers in various ways, the this function is
3711 available. This function honors the `INSTALL_HEADERS`, `HEADERS_DESTINATION`,
3712 and `HEADERS_COMPONENT` arguments to @ref vtk_module_build.
3715 vtk_module_install_headers(
3716 [DIRECTORIES <directory>...]
3721 Installation of header directories follows CMake's `install` function semantics
3722 with respect to trailing slashes.
3724 function (vtk_module_install_headers)
3725 cmake_parse_arguments(_vtk_install_headers
3731 if (_vtk_install_headers_UNPARSED_ARGUMENTS)
3734 "${_vtk_install_headers_UNPARSED_ARGUMENTS}
")
3737 if (NOT _vtk_build_INSTALL_HEADERS)
3741 if (NOT _vtk_install_headers_FILES AND NOT _vtk_install_headers_DIRECTORIES)
3745 set(_vtk_install_headers_destination
3746 "${_vtk_build_HEADERS_DESTINATION}/${_vtk_install_headers_SUBDIR}
")
3747 if (_vtk_install_headers_FILES)
3749 FILES ${_vtk_install_headers_FILES}
3750 DESTINATION "${_vtk_install_headers_destination}
"
3751 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
3753 foreach (_vtk_install_headers_directory IN LISTS _vtk_install_headers_DIRECTORIES)
3755 DIRECTORY "${_vtk_install_headers_directory}
"
3756 DESTINATION "${_vtk_install_headers_destination}
"
3757 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
3762 @ingroup module-internal
3763 @brief Apply properties to a module
3765 Apply build properties to a target. Generally only useful to wrapping code or
3766 other modules that cannot use @ref vtk_module_add_module for some reason.
3769 _vtk_module_apply_properties(<target>
3770 [BASENAME <basename>])
3773 If `BASENAME` is given, it will be used instead of the target name as the basis
3774 for `OUTPUT_NAME`. Full modules (as opposed to third party or other non-module
3775 libraries) always use the module's `LIBRARY_NAME` setting.
3777 The following target properties are set based on the arguments to the calling
3778 @ref vtk_module_build call:
3780 - `OUTPUT_NAME` (based on the module's `LIBRARY_NAME` and
3781 `vtk_module_build(LIBRARY_NAME_SUFFIX)`)
3782 - `VERSION` (based on `vtk_module_build(VERSION)`)
3783 - `SOVERSION` (based on `vtk_module_build(SOVERSION)`)
3784 - `DEBUG_POSTFIX` (on Windows)
3786 function (_vtk_module_apply_properties target)
3787 cmake_parse_arguments(_vtk_apply_properties
3793 if (_vtk_apply_properties_UNPARSED_ARGUMENTS)
3796 "${_vtk_apply_properties_UNPARSED_ARGUMENTS}.
")
3799 if (NOT DEFINED _vtk_apply_properties_BASENAME)
3800 set(_vtk_apply_properties_BASENAME "${
target}
")
3803 get_property(_vtk_add_module_type
3806 if (_vtk_add_module_type STREQUAL "OBJECT_LIBRARY
" OR
3807 _vtk_add_module_type STREQUAL "INTERFACE_LIBRARY
")
3811 set(_vtk_add_module_library_name "${_vtk_apply_properties_BASENAME}
")
3812 get_property(_vtk_add_module_target_name GLOBAL
3813 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
3814 if (_vtk_add_module_target_name STREQUAL "${
target}
")
3815 get_property(_vtk_add_module_library_name GLOBAL
3816 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
3818 set(_vtk_add_module_output_name "${_vtk_add_module_library_name}${_vtk_add_module_LIBRARY_NAME_SUFFIX}
")
3819 if (_vtk_build_LIBRARY_NAME_SUFFIX)
3820 string(APPEND _vtk_add_module_output_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}
")
3823 set_target_properties("${
target}
"
3825 OUTPUT_NAME "${_vtk_add_module_output_name}
")
3827 if (_vtk_build_VERSION AND NOT _vtk_add_module_type STREQUAL "EXECUTABLE
")
3828 set_target_properties("${
target}
"
3830 VERSION "${_vtk_build_VERSION}
")
3833 if (_vtk_build_SOVERSION)
3834 set_target_properties("${
target}
"
3836 SOVERSION "${_vtk_build_SOVERSION}
")
3840 set_target_properties("${
target}
"
3847 @ingroup module-internal
3848 @brief Install a module target
3850 Install a target within the module context. Generally only useful to wrapping
3851 code, modules that cannot use @ref vtk_module_add_module for some reason, or
3852 modules which create utility targets that need installed.
3855 _vtk_module_install(<target>)
3858 This function uses the various installation options to @ref vtk_module_build
3859 function to keep the install uniform.
3861 function (_vtk_module_install target)
3862 set(_vtk_install_export)
3863 if (_vtk_build_INSTALL_EXPORT)
3864 set(_vtk_install_export
3865 EXPORT "${_vtk_build_INSTALL_EXPORT}
")
3868 set(_vtk_install_namelink_args)
3869 if(NOT CMAKE_VERSION VERSION_LESS 3.12)
3870 list(APPEND _vtk_install_namelink_args
3871 NAMELINK_COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
3875 ${_vtk_install_export}
3878 DESTINATION "${_vtk_build_ARCHIVE_DESTINATION}
"
3879 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
"
3881 DESTINATION "${_vtk_build_LIBRARY_DESTINATION}
"
3882 COMPONENT "${_vtk_build_TARGETS_COMPONENT}
"
3883 ${_vtk_install_namelink_args}
3885 DESTINATION "${_vtk_build_RUNTIME_DESTINATION}
"
3886 COMPONENT "${_vtk_build_TARGETS_COMPONENT}
")
3891 @brief Create a module executable
3893 Some modules may have associated executables with them. By using this function,
3894 the target will be installed following the options given to the associated
3895 @ref vtk_module_build command. Its name will also be changed according to the
3896 `LIBRARY_NAME_SUFFIX` option.
3899 vtk_module_add_executable(<name>
3902 [BASENAME <basename>]
3906 If `NO_INSTALL` is specified, the executable will not be installed. If
3907 `BASENAME` is given, it will be used as the name of the executable rather than
3910 If `DEVELOPMENT` is given, it marks the executable as a development tool and
3911 will not be installed if `INSTALL_HEADERS` is not set for the associated
3912 @ref vtk_module_build command.
3914 If the executable being built is the module, its module properties are used
3915 rather than `BASENAME`. In addition, the dependencies of the module will be
3918 function (vtk_module_add_executable name)
3919 cmake_parse_arguments(_vtk_add_executable
3920 "NO_INSTALL;DEVELOPMENT
"
3925 if (NOT _vtk_add_executable_UNPARSED_ARGUMENTS)
3927 "The ${
name} executable must have at least one
source file.
")
3930 if (_vtk_add_executable_NO_INSTALL AND _vtk_add_executable_DEVELOPMENT)
3932 "Both `NO_INSTALL` and `DEVELOPMENT` may not be specified.
")
3935 set(_vtk_add_executable_target_name "${
name}
")
3936 set(_vtk_add_executable_library_name "${
name}
")
3937 if (name STREQUAL _vtk_build_module)
3938 if (_vtk_add_executable_NO_INSTALL)
3940 "The executable ${_vtk_build_module} module may not use `NO_INSTALL`.
")
3942 if (DEFINED _vtk_add_executable_BASENAME)
3944 "The executable ${_vtk_build_module} module may not pass `BASENAME`
"
3945 "when adding the executable; it is controlled via `LIBRARY_NAME` in
"
3946 "the associated `
vtk.module` file.
")
3948 get_property(_vtk_add_executable_target_name GLOBAL
3949 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
3950 get_property(_vtk_add_executable_library_name GLOBAL
3951 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
3954 if (_vtk_add_executable_DEVELOPMENT AND NOT _vtk_build_INSTALL_HEADERS)
3955 set(_vtk_add_executable_NO_INSTALL ON)
3959 set(CMAKE_BUILD_RPATH_USE_ORIGIN 1)
3961 file(RELATIVE_PATH _vtk_add_executable_relpath
3962 "/prefix/${_vtk_build_RUNTIME_DESTINATION}
"
3963 "/prefix/${_vtk_build_LIBRARY_DESTINATION}
")
3965 set(_vtk_add_executable_origin_rpath_prefix
3968 set(_vtk_add_executable_origin_rpath_prefix
3972 list(APPEND CMAKE_INSTALL_RPATH
3973 "${_vtk_add_executable_origin_rpath_prefix}/${_vtk_add_executable_relpath}
")
3976 add_executable("${_vtk_add_executable_target_name}
"
3977 ${_vtk_add_executable_UNPARSED_ARGUMENTS})
3979 if (name STREQUAL _vtk_build_module AND NOT _vtk_add_executable_target_name STREQUAL _vtk_build_module)
3980 add_executable("${_vtk_build_module}
" ALIAS
3981 "${_vtk_add_executable_target_name}
")
3984 if (name STREQUAL _vtk_build_module)
3985 get_property(_vtk_real_target_kit GLOBAL
3986 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
3987 if (_vtk_real_target_kit)
3989 "Executable module ${_vtk_build_module} is declared to be part of a
"
3990 "kit;
this is not possible.
")
3993 get_property(_vtk_add_executable_depends GLOBAL
3994 PROPERTY "_vtk_module_${_vtk_build_module}_depends
")
3995 get_property(_vtk_add_executable_private_depends GLOBAL
3996 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends
")
3997 target_link_libraries("${_vtk_add_executable_target_name}
"
3999 ${_vtk_add_executable_depends}
4001 ${_vtk_add_executable_private_depends})
4002 get_property(_vtk_add_executable_optional_depends GLOBAL
4003 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends
")
4004 foreach (_vtk_add_executable_optional_depend IN LISTS _vtk_add_executable_optional_depends)
4005 string(REPLACE "::
" "_
" _vtk_add_executable_optional_depend_safe "${_vtk_add_executable_optional_depend}
")
4006 if (TARGET "${_vtk_add_executable_optional_depend}
")
4007 set(_vtk_add_executable_have_optional_depend 1)
4009 set(_vtk_add_executable_have_optional_depend 0)
4011 target_compile_definitions("${_vtk_add_executable_target_name}
"
4013 "VTK_MODULE_ENABLE_${_vtk_add_executable_optional_depend_safe}=${_vtk_add_executable_have_optional_depend}
")
4016 if (_vtk_module_warnings)
4017 if (_vtk_add_executable_depends)
4019 "Executable module ${_vtk_build_module} has
public dependencies;
this "
4020 "shouldn
't be necessary.")
4025 set(_vtk_add_executable_property_args)
4026 if (DEFINED _vtk_add_executable_BASENAME)
4027 list(APPEND _vtk_add_executable_property_args
4028 BASENAME "${_vtk_add_executable_BASENAME}")
4031 _vtk_module_apply_properties("${_vtk_add_executable_target_name}"
4032 ${_vtk_add_executable_property_args})
4033 _vtk_module_standard_includes(TARGET "${_vtk_add_executable_target_name}")
4035 if (NOT _vtk_add_executable_NO_INSTALL)
4036 _vtk_module_install("${_vtk_add_executable_target_name}")
4042 @brief Find a package
4044 A wrapper around `find_package` that records information for use so that the
4045 same targets may be found when finding this package.
4047 Modules may need to find external dependencies. CMake often provides modules to
4048 find these dependencies, but when imported targets are involved, these.need to
4049 also be found from dependencies of the current project. Since the benefits of
4050 imported targets greatly outweighs not using them, it is preferred to use them.
4052 The module system provides the @ref vtk_module_find_package function in order
4053 to extend `find_package` support to include finding the dependencies from an
4054 install of the project.
4057 vtk_module_find_package(
4058 [PRIVATE] [CONFIG_MODE]
4061 [COMPONENTS <component>...]
4062 [OPTIONAL_COMPONENTS <component>...]
4063 [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4064 [VERSION_VAR <variable>])
4067 * `PACKAGE`: The name of the package to find.
4068 * `VERSION`: The minimum version of the package that is required.
4069 * `COMPONENTS`: Components of the package which are required.
4070 * `OPTIONAL_COMPONENTS`: Components of the package which may be missing.
4071 * `FORWARD_VERSION_REQ`: If provided, the found version will be promoted to
4072 the minimum version required matching the given version scheme.
4073 * `VERSION_VAR`: The variable to use as the provided version (defaults to
4074 `<PACKAGE>_VERSION`). It may contain `@` in which case it will be
4075 configured. This is useful for modules which only provide components of the
4076 actual version number.
4077 * `CONFIG_MODE`: If present, pass `CONFIG` to the underlying `find_package`
4079 * `PRIVATE`: The dependency should not be exported to the install.
4081 The `PACKAGE` argument is the only required argument. The rest are optional.
4083 Note that `PRIVATE` is *only* applicable for private dependencies on interface
4084 targets (basically, header libraries) because some platforms require private
4085 shared libraries dependencies to be present when linking dependent libraries
4086 and executables as well.
4088 macro (vtk_module_find_package)
4089 # This needs to be a macro because find modules typically set variables which
4090 # may need to be available in the calling scope. If we declare that it only
4091 # works with imported targets (which is the primary motivating factor behind
4092 # this function), we can instead make it a function at the cost of any
4093 # non-target variables a module might want to set being available. It is
4094 # unlikely that this will be the case for all callers.
4095 if (NOT _vtk_build_module)
4097 "`vtk_module_find_package` may only be called when building a VTK "
4101 # Note: when adding arguments here, add them to the `unset` block at the end
4103 cmake_parse_arguments(_vtk_find_package
4104 "PRIVATE;CONFIG_MODE"
4105 "PACKAGE;VERSION;FORWARD_VERSION_REQ;VERSION_VAR"
4106 "COMPONENTS;OPTIONAL_COMPONENTS"
4109 if (_vtk_find_package_UNPARSED_ARGUMENTS)
4111 "Unparsed arguments for vtk_module_find_package: "
4112 "${_vtk_find_package_UNPARSED_ARGUMENTS}")
4115 if (NOT DEFINED _vtk_find_package_PACKAGE)
4117 "The `PACKAGE` argument is required.")
4120 if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4121 if (_vtk_find_package_PRIVATE)
4123 "The `FORWARD_VERSION_REQ` argument is incompatible with the "
4127 if (NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR" AND
4128 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR" AND
4129 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH" AND
4130 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4132 "The `FORWARD_VERSION_REQ` argument must be one of `MAJOR`, `MINOR`, "
4133 "`PATCH`, or `EXACT`.")
4137 if (NOT DEFINED _vtk_find_package_VERSION_VAR)
4138 set(_vtk_find_package_VERSION_VAR
4139 "${_vtk_find_package_PACKAGE}_VERSION")
4142 set(_vtk_find_package_config)
4143 if (_vtk_find_package_CONFIG_MODE)
4144 set(_vtk_find_package_config "CONFIG")
4147 find_package("${_vtk_find_package_PACKAGE}"
4148 ${_vtk_find_package_VERSION}
4149 ${_vtk_find_package_config}
4150 COMPONENTS ${_vtk_find_package_COMPONENTS}
4151 OPTIONAL_COMPONENTS ${_vtk_find_package_OPTIONAL_COMPONENTS})
4152 if (NOT ${_vtk_find_package_PACKAGE}_FOUND)
4154 "Could not find the ${_vtk_find_package_PACKAGE} external dependency.")
4158 set(_vtk_find_package_optional_components_found)
4159 foreach (_vtk_find_package_optional_component IN LISTS _vtk_find_package_OPTIONAL_COMPONENTS)
4160 if (${_vtk_find_package_PACKAGE}_${_vtk_find_package_optional_component}_FOUND)
4161 list(APPEND _vtk_find_package_optional_components_found
4162 "${_vtk_find_package_optional_component}")
4166 if (NOT _vtk_find_package_PRIVATE)
4167 set_property(GLOBAL APPEND
4169 "_vtk_module_find_packages_${_vtk_build_PACKAGE}" "${_vtk_find_package_PACKAGE}")
4170 set(_vtk_find_package_base "_vtk_module_find_package_${_vtk_build_module}")
4171 set_property(GLOBAL APPEND
4173 "${_vtk_find_package_base}" "${_vtk_find_package_PACKAGE}")
4174 set(_vtk_find_package_base_package "${_vtk_find_package_base}_${_vtk_find_package_PACKAGE}")
4177 "${_vtk_find_package_base_package}_version" "${_vtk_find_package_VERSION}")
4180 "${_vtk_find_package_base_package}_config" "${_vtk_find_package_CONFIG_MODE}")
4181 set_property(GLOBAL APPEND
4183 "${_vtk_find_package_base_package}_components" "${_vtk_find_package_COMPONENTS}")
4184 set_property(GLOBAL APPEND
4186 "${_vtk_find_package_base_package}_optional_components" "${_vtk_find_package_OPTIONAL_COMPONENTS}")
4187 set_property(GLOBAL APPEND
4189 "${_vtk_find_package_base_package}_optional_components_found" "${_vtk_find_package_optional_components_found}")
4192 "${_vtk_find_package_base_package}_exact" "0")
4193 if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4194 string(FIND "${_vtk_find_package_VERSION_VAR}" "@" _vtk_find_package_idx)
4195 if (_vtk_find_package_idx EQUAL -1)
4196 if (NOT DEFINED "${_vtk_find_package_VERSION_VAR}")
4198 "The `${_vtk_find_package_VERSION_VAR}` variable is not defined.")
4200 set(_vtk_find_package_version "${${_vtk_find_package_VERSION_VAR}}")
4202 string(CONFIGURE "${_vtk_find_package_VERSION_VAR}" _vtk_find_package_version)
4204 unset(_vtk_find_package_idx)
4206 if ("${_vtk_find_package_version}" STREQUAL "")
4208 "The `${_vtk_find_package_PACKAGE}` version is empty.")
4211 if (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR")
4212 set(_vtk_find_package_version_regex "^\([^.]*\).*")
4213 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR")
4214 set(_vtk_find_package_version_regex "^\([^.]*.[^.]*\).*")
4215 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH")
4216 set(_vtk_find_package_version_regex "^\([^.]*.[^.]*.[^.]*\).*")
4217 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4218 set(_vtk_find_package_version_regex "^\\(.*\\)$")
4221 "${_vtk_find_package_base_package}_exact" "1")
4224 string(REGEX REPLACE "${_vtk_find_package_version_regex}" "\\1"
4225 _vtk_find_package_found_version "${_vtk_find_package_version}")
4226 unset(_vtk_find_package_version_regex)
4227 unset(_vtk_find_package_version)
4231 "${_vtk_find_package_base_package}_version" "${_vtk_find_package_found_version}")
4232 unset(_vtk_find_package_found_version)
4236 unset(_vtk_find_package_base)
4237 unset(_vtk_find_package_base_package)
4238 unset(_vtk_find_package_COMPONENTS)
4239 unset(_vtk_find_package_FORWARD_VERSION_REQ)
4240 unset(_vtk_find_package_OPTIONAL_COMPONENTS)
4241 unset(_vtk_find_package_PACKAGE)
4242 unset(_vtk_find_package_PRIVATE)
4243 unset(_vtk_find_package_UNPARSED_ARGUMENTS)
4244 unset(_vtk_find_package_VERSION)
4245 unset(_vtk_find_package_VERSION_VAR)
4250 @brief Export find_package calls for dependencies
4252 When installing a project that is meant to be found via `find_package` from
4253 CMake, using imported targets in the build means that imported targets need to
4254 be created during the `find_package` as well. This function writes a file
4255 suitable for inclusion from a `<package>-config.cmake` file to satisfy
4256 dependencies. It assumes that the exported targets are named
4257 `${CMAKE_FIND_PACKAGE_NAME}::${component}`. Dependent packages will only be
4258 found if a requested component requires the package to be found either directly
4262 vtk_module_export_find_packages(
4263 CMAKE_DESTINATION <directory>
4264 FILE_NAME <filename>
4265 [COMPONENT <component>]
4266 MODULES <module>...)
4269 The file will be named according to the `FILE_NAME` argument will be installed
4270 into `CMAKE_DESTINATION` in the build and install trees with the given
4271 filename. If not provided, the `development` component will be used.
4273 The `vtk_module_find_package` calls made by the modules listed in `MODULES`
4274 will be exported to this file.
4276 function (vtk_module_export_find_packages)
4277 cmake_parse_arguments(_vtk_export
4279 "CMAKE_DESTINATION;FILE_NAME;COMPONENT"
4283 if (_vtk_export_UNPARSED_ARGUMENTS)
4285 "Unparsed arguments for vtk_module_export_find_packages: "
4286 "${_vtk_export_UNPARSED_ARGUMENTS}")
4289 if (NOT DEFINED _vtk_export_CMAKE_DESTINATION)
4291 "The `CMAKE_DESTINATION` is required.")
4294 if (NOT DEFINED _vtk_export_FILE_NAME)
4296 "The `FILE_NAME` is required.")
4299 if (NOT DEFINED _vtk_export_COMPONENT)
4300 set(_vtk_export_COMPONENT "development")
4303 set(_vtk_export_output_file
4304 "${CMAKE_BINARY_DIR}/${_vtk_export_CMAKE_DESTINATION}/${_vtk_export_FILE_NAME}")
4305 file(WRITE "${_vtk_export_output_file}"
4306 "set(_vtk_module_find_package_quiet)
4307 if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4308 set(_vtk_module_find_package_quiet QUIET)
4311 set(_vtk_module_find_package_components_checked)
4312 set(_vtk_module_find_package_components_to_check
4313 \${\${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
4314 set(_vtk_module_find_package_components)
4315 set(_vtk_module_find_package_components_required)
4316 while (_vtk_module_find_package_components_to_check)
4317 list(GET _vtk_module_find_package_components_to_check 0 _vtk_module_component)
4318 list(REMOVE_AT _vtk_module_find_package_components_to_check 0)
4319 if (_vtk_module_component IN_LIST _vtk_module_find_package_components_checked)
4322 list(APPEND _vtk_module_find_package_components_checked
4323 \"\${_vtk_module_component}\")
4325 list(APPEND _vtk_module_find_package_components
4326 \"\${_vtk_module_component}\")
4327 if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_\${_vtk_module_component})
4328 list(APPEND _vtk_module_find_package_components_required
4329 \"\${_vtk_module_component}\")
4332 if (TARGET \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4333 set(_vtk_module_find_package_component_target \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4334 elseif (TARGET \"\${_vtk_module_component}\")
4335 set(_vtk_module_find_package_component_target \"\${_vtk_module_component}\")
4337 # No such target for the component; skip.
4340 get_property(_vtk_module_find_package_depends
4341 TARGET \"\${_vtk_module_find_package_component_target}\"
4342 PROPERTY \"INTERFACE_vtk_module_depends\")
4343 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4344 list(APPEND _vtk_module_find_package_components_to_check
4345 \${_vtk_module_find_package_depends})
4346 get_property(_vtk_module_find_package_depends
4347 TARGET \"\${_vtk_module_find_package_component_target}\"
4348 PROPERTY \"INTERFACE_vtk_module_private_depends\")
4349 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4350 list(APPEND _vtk_module_find_package_components_to_check
4351 \${_vtk_module_find_package_depends})
4352 get_property(_vtk_module_find_package_depends
4353 TARGET \"\${_vtk_module_find_package_component_target}\"
4354 PROPERTY \"INTERFACE_vtk_module_optional_depends\")
4355 foreach (_vtk_module_find_package_depend IN LISTS _vtk_module_find_package_depends)
4356 if (TARGET \"\${_vtk_module_find_package_depend}\")
4357 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depend \"\${_vtk_module_find_package_depend}\")
4358 list(APPEND _vtk_module_find_package_components_to_check
4359 \"\${_vtk_module_find_package_depend}\")
4362 get_property(_vtk_module_find_package_depends
4363 TARGET \"\${_vtk_module_find_package_component_target}\"
4364 PROPERTY \"INTERFACE_vtk_module_forward_link\")
4365 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4366 list(APPEND _vtk_module_find_package_components_to_check
4367 \${_vtk_module_find_package_depends})
4369 get_property(_vtk_module_find_package_kit
4370 TARGET \"\${_vtk_module_find_package_component_target}\"
4371 PROPERTY \"INTERFACE_vtk_module_kit\")
4372 if (_vtk_module_find_package_kit)
4373 get_property(_vtk_module_find_package_kit_modules
4374 TARGET \"\${_vtk_module_find_package_kit}\"
4375 PROPERTY \"INTERFACE_vtk_kit_kit_modules\")
4376 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_kit_modules \"\${_vtk_module_find_package_kit_modules}\")
4377 list(APPEND _vtk_module_find_package_components_to_check
4378 \${_vtk_module_find_package_kit_modules})
4381 unset(_vtk_module_find_package_component_target)
4382 unset(_vtk_module_find_package_components_to_check)
4383 unset(_vtk_module_find_package_components_checked)
4384 unset(_vtk_module_component)
4385 unset(_vtk_module_find_package_depend)
4386 unset(_vtk_module_find_package_depends)
4387 unset(_vtk_module_find_package_kit)
4388 unset(_vtk_module_find_package_kit_modules)
4390 if (_vtk_module_find_package_components)
4391 list(REMOVE_DUPLICATES _vtk_module_find_package_components)
4393 if (_vtk_module_find_package_components_required)
4394 list(REMOVE_DUPLICATES _vtk_module_find_package_components_required)
4397 foreach (_vtk_export_module IN LISTS _vtk_export_MODULES)
4398 get_property(_vtk_export_target_name GLOBAL
4399 PROPERTY "_vtk_module_${_vtk_export_module}_target_name")
4400 set(_vtk_export_base "_vtk_module_find_package_${_vtk_export_module}")
4401 get_property(_vtk_export_packages GLOBAL
4402 PROPERTY "${_vtk_export_base}")
4403 if (NOT _vtk_export_packages)
4407 file(APPEND "${_vtk_export_output_file}"
4408 "set(_vtk_module_find_package_enabled OFF)
4409 set(_vtk_module_find_package_is_required OFF)
4410 set(_vtk_module_find_package_fail_if_not_found OFF)
4411 if (_vtk_module_find_package_components)
4412 if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components)
4413 set(_vtk_module_find_package_enabled ON)
4414 if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components_required)
4415 set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4416 set(_vtk_module_find_package_fail_if_not_found ON)
4420 set(_vtk_module_find_package_enabled ON)
4421 set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4422 set(_vtk_module_find_package_fail_if_not_found ON)
4425 if (_vtk_module_find_package_enabled)
4426 set(_vtk_module_find_package_required)
4427 if (_vtk_module_find_package_is_required)
4428 set(_vtk_module_find_package_required REQUIRED)
4431 list(REMOVE_DUPLICATES _vtk_export_packages)
4432 foreach (_vtk_export_package IN LISTS _vtk_export_packages)
4433 set(_vtk_export_base_package "${_vtk_export_base}_${_vtk_export_package}")
4434 get_property(_vtk_export_version GLOBAL
4435 PROPERTY "${_vtk_export_base_package}_version")
4436 get_property(_vtk_export_config GLOBAL
4437 PROPERTY "${_vtk_export_base_package}_config")
4438 get_property(_vtk_export_exact GLOBAL
4439 PROPERTY "${_vtk_export_base_package}_exact")
4440 get_property(_vtk_export_components GLOBAL
4441 PROPERTY "${_vtk_export_base_package}_components")
4442 get_property(_vtk_export_optional_components GLOBAL
4443 PROPERTY "${_vtk_export_base_package}_optional_components")
4444 get_property(_vtk_export_optional_components_found GLOBAL
4445 PROPERTY "${_vtk_export_base_package}_optional_components_found")
4447 # Assume that any found optional components end up being required.
4448 if (${_vtk_export_base_package}_optional_components_found)
4449 list(REMOVE_ITEM _vtk_export_optional_components
4450 ${_vtk_export_optional_components_found})
4451 list(APPEND _vtk_export_components
4452 ${_vtk_export_optional_components_found})
4455 set(_vtk_export_config_arg)
4456 if (_vtk_export_config)
4457 set(_vtk_export_config_arg CONFIG)
4460 set(_vtk_export_exact_arg)
4461 if (_vtk_export_exact)
4462 set(_vtk_export_exact_arg EXACT)
4465 file(APPEND "${_vtk_export_output_file}"
4466 " find_package(${_vtk_export_package}
4467 ${_vtk_export_version}
4468 ${_vtk_export_exact_arg}
4469 ${_vtk_export_config_arg}
4470 \${_vtk_module_find_package_quiet}
4471 \${_vtk_module_find_package_required}
4472 COMPONENTS ${_vtk_export_components}
4473 OPTIONAL_COMPONENTS ${_vtk_export_optional_components})
4474 if (NOT ${_vtk_export_package}_FOUND AND _vtk_module_find_package_fail_if_not_found)
4475 if (NOT \${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4477 \"Could not find the \${CMAKE_FIND_PACKAGE_NAME} package due to a \"
4478 \"missing dependency: ${_vtk_export_package}\")
4480 set(\"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_FOUND\" 0)
4481 list(APPEND \"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_NOT_FOUND_MESSAGE\"
4482 \"Failed to find the ${_vtk_export_package} package.\")
4486 file(APPEND "${_vtk_export_output_file}"
4489 unset(_vtk_module_find_package_fail_if_not_found)
4490 unset(_vtk_module_find_package_enabled)
4491 unset(_vtk_module_find_package_required)\n\n")
4495 file(APPEND "${_vtk_export_output_file}"
4496 "unset(_vtk_module_find_package_components)
4497 unset(_vtk_module_find_package_components_required)
4498 unset(_vtk_module_find_package_quiet)\n")
4501 FILES "${CMAKE_BINARY_DIR}/${_vtk_export_CMAKE_DESTINATION}/${_vtk_export_FILE_NAME}"
4502 DESTINATION "${_vtk_export_CMAKE_DESTINATION}"
4503 COMPONENT "${_vtk_export_COMPONENT}")
4507 @page module-overview
4510 @section module-third-party Third party support
4512 The module system acknowledges that third party support is a pain and offers
4513 APIs to help wrangle them. Sometimes third party code needs a shim introduced
4514 to make it behave better, so an `INTERFACE` library to add that in is very
4515 useful. Other times, third party code is hard to ensure that it exists
4516 everywhere, so it is bundled. When that happens, the ability to select between
4517 the bundled copy and an external copy is useful. All three (and more) of these
4520 The following functions are used to handle third party modules:
4522 - @ref vtk_module_third_party
4523 - @ref vtk_module_third_party_external
4524 - @ref vtk_module_third_party_internal
4529 @brief Third party module
4531 When a project has modules which represent third party packages, there are some
4532 convenience functions to help deal with them. First, there is the meta-wrapper:
4535 vtk_module_third_party(
4536 [INTERNAL <internal arguments>...]
4537 [EXTERNAL <external arguments>...])
4540 This offers a cache variable named `VTK_MODULE_USE_EXTERNAL_<module name>` that
4541 may be set to trigger between the internal copy and an externally provided
4542 copy. This is available as a local variable named
4543 `VTK_MODULE_USE_EXTERNAL_<library name>`. See the
4544 @ref vtk_module_third_party_external and @ref vtk_module_third_party_internal
4545 functions for the arguments supported by the `EXTERNAL` and `INTERNAL`
4546 arguments, respectively.
4548 function (vtk_module_third_party)
4549 cmake_parse_arguments(_vtk_third_party
4555 if (_vtk_third_party_UNPARSED_ARGUMENTS)
4557 "Unparsed arguments for vtk_module_third_party: "
4558 "${_vtk_third_party_UNPARSED_ARGUMENTS}")
4561 string(REPLACE "::" "_" _vtk_build_module_safe "${_vtk_build_module}")
4562 option("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}"
4563 "Use externally provided ${_vtk_build_module}"
4564 "${_vtk_build_USE_EXTERNAL}")
4565 mark_as_advanced("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}")
4566 get_property(_vtk_third_party_library_name GLOBAL
4567 PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
4568 set("VTK_MODULE_USE_EXTERNAL_${_vtk_third_party_library_name}"
4569 "${VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}}"
4572 if (VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe})
4573 # XXX(cmake): https://gitlab.kitware.com/cmake/cmake/issues/16364.
4574 # Unset a variable which CMake doesn't like when switching between real
4575 # libraries (internal) and interface libraries (external).
4576 unset(
"${_vtk_build_module}_LIB_DEPENDS" CACHE)
4579 # Bubble up variables again.
4580 foreach (_vtk_third_party_variable IN LISTS _vtk_third_party_variables)
4581 set(
"${_vtk_third_party_variable}"
4582 "${${_vtk_third_party_variable}}"
4586 set(_vtk_third_party_has_external_support 1)
4592 @ingroup module-
impl
4593 @brief Mark a module as being third party
4595 Mark a module as being a third party module.
4603 set_target_properties(
"${target}"
4605 "INTERFACE_vtk_module_exclude_wrap" 1
4606 "INTERFACE_vtk_module_third_party" 1)
4611 @brief External third party
package
4613 A third party dependency may be expressed as a module using this function.
4614 Third party packages are found using CMake's `find_package` function. It is
4615 highly recommended that imported targets are used to make usage easier. The
4616 module itself will be created as an `INTERFACE` library which exposes the
4620 vtk_module_third_party_external(
4623 [COMPONENTS <component>...]
4624 [OPTIONAL_COMPONENTS <component>...]
4625 [INCLUDE_DIRS <path-or-variable>...]
4626 [LIBRARIES <target-or-variable>...]
4627 [DEFINITIONS <variable>...]
4628 [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4629 [VERSION_VAR <version-spec>]
4630 [USE_VARIABLES <variable>...]
4632 [STANDARD_INCLUDE_DIRS])
4635 Only the `PACKAGE` argument is required. The arguments are as follows:
4637 * `PACKAGE`: (Required) The name of the package to find.
4638 * `VERSION`: If specified, the minimum version of the dependency that must be
4640 * `COMPONENTS`: The list of components to request from the package.
4641 * `OPTIONAL_COMPONENTS`: The list of optional components to request from the
4643 * `STANDARD_INCLUDE_DIRS`: If present, standard include directories will be
4644 added to the module target. This is usually only required if both internal
4645 and external are supported for a given dependency.
4646 * `INCLUDE_DIRS`: If specified, this is added as a `SYSTEM INTERFACE` include
4647 directory for the target. If a variable name is given, it will be
4649 * `LIBRARIES`: The libraries to link from the package. If a variable name is
4650 given, it will be dereferenced, however a warning that imported targets are
4651 not being used will be emitted.
4652 * `DEFINITIONS`: If specified, the given variables will be added to the
4653 target compile definitions interface.
4654 * `CONFIG_MODE`: Force `CONFIG` mode.
4655 * `FORWARD_VERSION_REQ` and `VERSION_VAR`: See documentation for
4656 @ref vtk_module_find_package.
4657 * `USE_VARIABLES`: List of variables from the `find_package` to make
4658 available to the caller.
4660 function (vtk_module_third_party_external)
4661 cmake_parse_arguments(_vtk_third_party_external
4662 "STANDARD_INCLUDE_DIRS;CONFIG_MODE
"
4663 "VERSION;PACKAGE;FORWARD_VERSION_REQ;VERSION_VAR
"
4664 "COMPONENTS;OPTIONAL_COMPONENTS;LIBRARIES;INCLUDE_DIRS;DEFINITIONS;TARGETS;USE_VARIABLES
"
4667 if (_vtk_third_party_external_UNPARSED_ARGUMENTS)
4670 "${_vtk_third_party_external_UNPARSED_ARGUMENTS}
")
4673 get_property(_vtk_third_party_external_is_third_party GLOBAL
4674 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
4675 if (NOT _vtk_third_party_external_is_third_party)
4677 "The ${_vtk_build_module} has not been declared as a third party
"
4681 if (NOT DEFINED _vtk_third_party_external_PACKAGE)
4683 "The `PACKAGE` argument is required.
")
4686 set(_vtk_third_party_external_args)
4687 if (DEFINED _vtk_third_party_external_FORWARD_VERSION_REQ)
4688 list(APPEND _vtk_third_party_external_args
4689 FORWARD_VERSION_REQ "${_vtk_third_party_external_FORWARD_VERSION_REQ}
")
4691 if (DEFINED _vtk_third_party_external_VERSION_VAR)
4692 list(APPEND _vtk_third_party_external_args
4693 VERSION_VAR "${_vtk_third_party_external_VERSION_VAR}
")
4696 if (_vtk_third_party_external_TARGETS)
4697 set(_vtk_third_party_external_config_mode)
4698 if (_vtk_third_party_external_CONFIG_MODE)
4699 set(_vtk_third_party_external_config_mode "CONFIG_MODE
")
4702 # If we have targets, they must be exported to the install as well.
4703 vtk_module_find_package(
4704 PACKAGE "${_vtk_third_party_external_PACKAGE}
"
4705 VERSION "${_vtk_third_party_external_VERSION}
"
4706 COMPONENTS ${_vtk_third_party_external_COMPONENTS}
4707 OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS}
4708 ${_vtk_third_party_external_config_mode}
4709 ${_vtk_third_party_external_args})
4711 set(_vtk_third_party_external_config)
4712 if (_vtk_third_party_external_CONFIG_MODE)
4713 set(_vtk_third_party_external_config "CONFIG
")
4716 # If there are no targets, the install uses strings and therefore does not
4717 # need to find the dependency again.
4718 find_package("${_vtk_third_party_external_PACKAGE}
"
4719 ${_vtk_third_party_external_VERSION}
4720 ${_vtk_third_party_external_config}
4721 COMPONENTS ${_vtk_third_party_external_COMPONENTS}
4722 OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS})
4725 get_property(_vtk_third_party_external_target_name GLOBAL
4726 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
4728 # Check if an imported target of the same name already exists.
4729 set(_vtk_third_party_external_real_target_name
4730 "${_vtk_third_party_external_target_name}
")
4731 set(_vtk_third_party_external_using_mangled_name OFF)
4732 if (TARGET "${_vtk_third_party_external_target_name}
")
4733 # Ensure that the target collision comes from an imported target.
4734 get_property(_vtk_third_party_external_is_imported
4735 TARGET "${_vtk_third_party_external_target_name}
"
4737 if (NOT _vtk_third_party_external_is_imported)
4739 "It appears as though there is a conflicting
target named
"
4740 "`${_vtk_third_party_external_target_name}` expected to be used by
"
4741 "the `${_vtk_build_module}` module already added to the build. This
"
4742 "conflicts with the
target name expected to be used by an external
"
4743 "third party dependency.
")
4746 # If it does, we need to have a module name that is not the same as this
4747 # one. Error out if this is detected.
4748 if (_vtk_build_module STREQUAL _vtk_third_party_external_target_name)
4750 "An imported
target has the same
name used by the module system
for "
4751 "the facade of the external dependency
for `${_vtk_build_module}`.
"
4752 "This module must be either renamed or placed into a
namespace.
")
4755 # Mangle the internal name. The alias is the expected use case anyways and
4756 # since this is an INTERFACE target, there's nothing to break with respect
4757 # to `make $target` anyways.
4758 string(APPEND _vtk_third_party_external_real_target_name
4759 "_vtk_module_mangle
")
4760 set_property(GLOBAL APPEND_STRING
4761 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
"
4762 "_vtk_module_mangle
")
4763 set(_vtk_third_party_external_using_mangled_name ON)
4766 add_library("${_vtk_third_party_external_real_target_name}
" INTERFACE)
4767 if (_vtk_third_party_external_using_mangled_name)
4768 set_property(TARGET "${_vtk_third_party_external_real_target_name}
"
4770 EXPORT_NAME "${_vtk_third_party_external_target_name}
")
4772 if (NOT _vtk_build_module STREQUAL _vtk_third_party_external_target_name)
4773 add_library("${_vtk_build_module}
" ALIAS
4774 "${_vtk_third_party_external_real_target_name}
")
4777 if (_vtk_third_party_external_STANDARD_INCLUDE_DIRS)
4778 _vtk_module_standard_includes(TARGET "${_vtk_third_party_external_real_target_name}
"
4782 # Try to use targets if they're specified and available.
4783 set(_vtk_third_party_external_have_targets FALSE)
4784 set(_vtk_third_party_external_used_targets FALSE)
4785 if (_vtk_third_party_external_TARGETS)
4786 set(_vtk_third_party_external_have_targets TRUE)
4787 set(_vtk_third_party_external_all_targets_okay TRUE)
4788 foreach (_vtk_third_party_external_target IN LISTS _vtk_third_party_external_TARGETS)
4789 if (NOT TARGET "${_vtk_third_party_external_target}
")
4790 set(_vtk_third_party_external_all_targets_okay FALSE)
4795 if (_vtk_third_party_external_all_targets_okay)
4796 target_link_libraries("${_vtk_third_party_external_real_target_name}
"
4798 ${_vtk_third_party_external_TARGETS})
4799 set(_vtk_third_party_external_used_targets TRUE)
4803 if (NOT _vtk_third_party_external_used_targets)
4804 if (NOT _vtk_third_party_external_have_targets)
4806 "A third party dependency
for ${_vtk_build_module} was found externally
"
4807 "using paths rather than targets; it is recommended to use imported
"
4808 "targets rather than find_library and such.
")
4811 set(_vtk_third_party_external_have_includes FALSE)
4812 foreach (_vtk_third_party_external_include_dir IN LISTS _vtk_third_party_external_INCLUDE_DIRS)
4813 if (DEFINED "${_vtk_third_party_external_include_dir}
")
4814 if (${_vtk_third_party_external_include_dir})
4815 set(_vtk_third_party_external_have_includes TRUE)
4817 target_include_directories("${_vtk_third_party_external_real_target_name}
" SYSTEM
4818 INTERFACE "${${_vtk_third_party_external_include_dir}}
")
4822 if (_vtk_third_party_external_have_targets AND
4823 NOT _vtk_third_party_external_have_includes)
4825 "A third party dependency
for ${_vtk_build_module} has external targets
"
4826 "which were not found and no `INCLUDE_DIRS` were found either.
"
4827 "Including
this module may not work.
")
4830 foreach (_vtk_third_party_external_define IN LISTS _vtk_third_party_external_DEFINITIONS)
4831 if (DEFINED "${_vtk_third_party_external_define}
")
4832 target_compile_definitions("${_vtk_third_party_external_real_target_name}
"
4833 INTERFACE "${${_vtk_third_party_external_define}}
")
4837 set(_vtk_third_party_external_have_libraries FALSE)
4838 foreach (_vtk_third_party_external_library IN LISTS _vtk_third_party_external_LIBRARIES)
4839 if (DEFINED "${_vtk_third_party_external_library}
")
4840 if (${_vtk_third_party_external_library})
4841 set(_vtk_third_party_external_have_libraries TRUE)
4843 target_link_libraries("${_vtk_third_party_external_real_target_name}
"
4844 INTERFACE "${${_vtk_third_party_external_library}}
")
4848 if (_vtk_third_party_external_have_targets AND
4849 NOT _vtk_third_party_external_have_libraries)
4851 "A third party dependency
for ${_vtk_build_module} has external targets
"
4852 "which were not found and no `LIBRARIES` were found either. Linking to
"
4853 "this this module may not work.
")
4857 if (DEFINED _vtk_third_party_external_USE_VARIABLES)
4858 # If we're called from `vtk_module_third_party`, the variables need bubbled
4860 if (DEFINED _vtk_third_party_EXTERNAL)
4861 set(_vtk_third_party_variables
4862 "${_vtk_third_party_external_USE_VARIABLES}
"
4866 foreach (_vtk_third_party_external_variable IN LISTS _vtk_third_party_external_USE_VARIABLES)
4867 if (NOT DEFINED "${_vtk_third_party_external_variable}
")
4869 "The variable `${_vtk_third_party_external_variable}` was expected
"
4870 "to have been available, but was not defined.
")
4873 set("${_vtk_third_party_external_variable}
"
4874 "${${_vtk_third_party_external_variable}}
"
4879 _vtk_module_mark_third_party("${_vtk_third_party_external_real_target_name}
")
4880 _vtk_module_install("${_vtk_third_party_external_real_target_name}
")
4885 @brief Internal third party package
4887 Third party modules may also be bundled with the project itself. In this case,
4888 it is an internal third party dependency. The dependency is assumed to be in a
4889 subdirectory that will be used via `add_subdirectory`. Unless it is marked as
4890 `HEADERS_ONLY`, it is assumed that it will create a target with the name of the
4894 vtk_module_third_party_internal(
4895 [SUBDIRECTORY <path>]
4896 [HEADERS_SUBDIR <subdir>]
4897 [LICENSE_FILES <file>...]
4901 [STANDARD_INCLUDE_DIRS])
4904 All arguments are optional, however warnings are emitted if `LICENSE_FILES` or
4905 `VERSION` is not specified. They are as follows:
4907 * `SUBDIRECTORY`: (Defaults to the library name of the module) The
4908 subdirectory containing the `CMakeLists.txt` for the dependency.
4909 * `HEADERS_SUBDIR`: If non-empty, the subdirectory to use for installing
4911 * `LICENSE_FILES`: A list of license files to install for the dependency. If
4912 not given, a warning will be emitted.
4913 * `VERSION`: The version of the library that is included.
4914 * `HEADER_ONLY`: The dependency is header only and will not create a target.
4915 * `INTERFACE`: The dependency is an `INTERFACE` library.
4916 * `STANDARD_INCLUDE_DIRS`: If present, module-standard include directories
4917 will be added to the module target.
4919 function (vtk_module_third_party_internal)
4920 # TODO: Support scanning for third-party modules which don't support an
4923 cmake_parse_arguments(_vtk_third_party_internal
4924 "INTERFACE;HEADER_ONLY;STANDARD_INCLUDE_DIRS
"
4925 "SUBDIRECTORY;HEADERS_SUBDIR;VERSION
"
4929 if (_vtk_third_party_internal_UNPARSED_ARGUMENTS)
4932 "${_vtk_third_party_internal_UNPARSED_ARGUMENTS}
")
4935 get_property(_vtk_third_party_internal_is_third_party GLOBAL
4936 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
4937 if (NOT _vtk_third_party_internal_is_third_party)
4939 "The ${_vtk_build_module} has not been declared as a third party
"
4943 get_property(_vtk_third_party_internal_library_name GLOBAL
4944 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
4945 if (NOT DEFINED _vtk_third_party_internal_SUBDIRECTORY)
4946 set(_vtk_third_party_internal_SUBDIRECTORY "${_vtk_third_party_internal_library_name}
")
4949 if (NOT DEFINED _vtk_third_party_internal_LICENSE_FILES)
4951 "The ${_vtk_build_module} third party
package is embedded, but does not "
4952 "specify any license files.")
4955 if (NOT DEFINED _vtk_third_party_internal_VERSION)
4957 "The ${_vtk_build_module} third party package is embedded, but does not "
4958 "specify the version it is based on.")
4961 get_property(_vtk_third_party_internal_target_name GLOBAL
4962 PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
4963 set(_vtk_third_party_internal_include_type)
4964 if (_vtk_third_party_internal_INTERFACE)
4965 set(_vtk_third_party_internal_include_type INTERFACE)
4966 elseif (_vtk_third_party_internal_HEADER_ONLY)
4967 add_library("${_vtk_third_party_internal_target_name}" INTERFACE)
4968 if (NOT _vtk_build_module STREQUAL _vtk_third_party_internal_target_name)
4969 add_library("${_vtk_build_module}" ALIAS
4970 "${_vtk_third_party_internal_target_name}")
4972 set(_vtk_third_party_internal_include_type INTERFACE)
4973 set(_vtk_third_party_internal_STANDARD_INCLUDE_DIRS 1)
4976 add_subdirectory("${_vtk_third_party_internal_SUBDIRECTORY}")
4978 if (NOT TARGET "${_vtk_build_module}")
4980 "The ${_vtk_build_module} is being built as an internal third party "
4981 "library, but a matching target was not created.")
4984 if (_vtk_third_party_internal_STANDARD_INCLUDE_DIRS)
4985 _vtk_module_standard_includes(
4986 TARGET "${_vtk_third_party_internal_target_name}"
4987 SYSTEM ${_vtk_third_party_internal_include_type}
4988 HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}/${_vtk_third_party_internal_HEADERS_SUBDIR}")
4991 _vtk_module_apply_properties("${_vtk_third_party_internal_target_name}")
4992 if (_vtk_third_party_internal_INTERFACE)
4994 elseif (_vtk_third_party_internal_HEADER_ONLY)
4995 _vtk_module_install("${_vtk_third_party_internal_target_name}")
4998 if (_vtk_third_party_internal_LICENSE_FILES)
5000 FILES ${_vtk_third_party_internal_LICENSE_FILES}
5001 DESTINATION "${_vtk_build_LICENSE_DESTINATION}/${_vtk_third_party_internal_library_name}/"
5002 COMPONENT "license")
5005 _vtk_module_mark_third_party("${_vtk_third_party_internal_target_name}")