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
12This module includes functions to find and build VTK modules. A module is a set
13of related functionality. These are then compiled together into libraries at
14the
"kit" level. Each module may be
enabled or disabled individually and its
15dependencies will be built as needed.
17All functions strictly check their arguments.
Any unrecognized or invalid
18values
for a
function cause errors to be raised.
23@page module-
internal-api Internal API
25The VTK module system provides some API functions
for use by other code which
26consumes VTK modules (primarily language wrappers). This file documents these
27APIs. They may start with `_vtk_module`, but they are intended
for use in cases
28of
language wrappers or dealing with trickier third party packages.
33@page module-
impl-api Implementation API
35These functions are purely
internal implementation
details. No guarantees are
36made
for them and they may change at any
time (including wrapping code calls).
37Note that these functions are usually very lax in their argument parsing.
42@brief Conditionally output debug statements
45controlled by the `_vtk_module_log` variable which contains a list of
"domains"
49_vtk_module_debug(<domain> <format>)
52If the `domain` is
enabled for debugging, the `format` argument is configured
53and printed. It should contain `@` variable expansions to replace rather than
54it being done outside. This helps to avoid the cost of generating large strings
55when 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
78vtk_module_find_kits(<output> [<directory>...])
81This scans the given directories recursively for `vtk.kit` files and put the
82paths into the output variable.
84function (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
100vtk_module_find_modules(<output> [<directory>...])
103This scans the given directories recursively for `vtk.module` files and put the
104paths into the output variable. Note that module files are assumed to live next
105to the `CMakeLists.txt` file which will build the module.
107function (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
122Module names may include a namespace. This function splits the name into a
123namespace and target name part.
126_vtk_module_split_module_name(<name> <prefix>)
129The `<prefix>_NAMESPACE` and `<prefix>_TARGET_NAME` variables will be set in
132function (_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
157The `vtk.module` file is parsed and used as arguments to a CMake function which
158stores information about the module for use when building it. Note that no
159variable expansion is allowed and it is not CMake code, so no control flow is
160allowed. Comments are supported and any content after a `#` on a line is
161treated as a comment. Due to the breakdown of the content, quotes are not
162meaningful within the files.
172 The base VTK library.
182All 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
225This macro places all `vtk.module` keyword "arguments
" into the caller's scope
226prefixed 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...>)
233For example, this `vtk.module` file:
242called with `_vtk_module_parse_module_args(name ...)` will set the following
243variables in the calling scope:
245 - `name`: `Namespace::Target`
246 - `Namespace::Target_LIBRARY_NAME`: `nsTarget`
248With namespace support for module names, the variable should instead be
249referenced via `${${name}_LIBRARY_NAME}` instead.
251macro (_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}
")
299@section module-parse-kit vtk.kit file contents
301The `vtk.kit` file is parsed similarly to `vtk.module` files. Kits are intended
302to bring together related modules into a single library in order to reduce the
303number of objects that linkers need to deal with.
313 Core utilities for VTK.
316All 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
330Just like @ref _vtk_module_parse_module_args, but for kits.
332macro (_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}
")
377@section module-enable-status Enable status values
379Modules 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
392If a `YES` module preference requires a module with a `NO` preference, an error
395A module with a setting of `DEFAULT` will look for its first non-`DEFAULT`
396group setting and only if all of those are set to `DEFAULT` is the
397`WANT_BY_DEFAULT` setting used.
402@brief Verify enable values
404Verifies that the variable named as the first parameter is a valid `enable
408_vtk_module_verify_enable_value(var)
411function (_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}}`.
")
423include("${CMAKE_CURRENT_LIST_DIR}/vtkTopologicalSort.cmake
")
427@brief Scan modules and kits
429Once all of the modules and kits files have been found, they are "scanned
" to
430determine 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>])
447The `MODULE_FILES` and `PROVIDES_MODULES` arguments are required. Modules which
448refer to kits must be scanned at the same time as their kits. This is so that
449modules 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 `DEFAULT`) 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. Note that this
474 has known issues where modules required only via testing may not have
475 their dependencies enabled.
476 - `DEFAULT`: Test modules will be enabled if their required dependencies
477 are satisfied and skipped otherwise.
479To make error messages clearer, modules passed to `REQUIRES_MODULES` and
480`REJECT_MODULES` may have a `_vtk_module_reason_<MODULE>` variable set to the
481reason for the module appearing in either argument. For example, if the
482`Package::Frobnitz` module is required due to a `ENABLE_FROBNITZ` cache
486set("_vtk_module_reason_Package::Frobnitz
"
487 "via the `ENABLE_FROBNITZ` setting
")
490Additionally, the reason for the `WANT_BY_DEFAULT` value may be provided via
491the `_vtk_module_reason_WANT_BY_DEFAULT` variable.
493@section module-scanning-multiple Scanning multiple groups of modules
495When scanning complicated projects, multiple scans may be required to get
496defaults set properly. The `REQUIRES_MODULES`, `REQUEST_MODULES`, and
497`UNRECOGNIZED_MODULES` arguments are meant to deal with this case. As an
498example, imagine a project with its source code, third party dependencies, as
499well as some utility modules which should only be built as necessary. Here, the
500project would perform three scans, one for each "grouping
" of modules:
503# Scan our modules first because we need to know what of the other groups we
505vtk_module_find_modules(our_modules "${CMAKE_CURRENT_SOURCE_DIR}/src
")
507 MODULE_FILES ${our_modules}
508 PROVIDES_MODULES our_enabled_modules
509 REQUIRES_MODULES required_modules)
511# Scan the third party modules, requesting only those that are necessary, but
512# allowing them to be toggled during the build.
513vtk_module_find_modules(third_party_modules "${CMAKE_CURRENT_SOURCE_DIR}/third-party
")
515 MODULE_FILES ${third_party_modules}
516 PROVIDES_MODULES third_party_enabled_modules
517 # These modules were requested by an earlier scan.
518 REQUEST_MODULES ${required_modules}
519 REQUIRES_MODULES required_modules
520 UNRECOGNIZED_MODULES unrecognized_modules)
522# These modules are internal and should only be built if necessary. There is no
523# need to support them being enabled independently, so hide them from the
525vtk_module_find_modules(utility_modules "${CMAKE_CURRENT_SOURCE_DIR}/utilities
")
527 MODULE_FILES ${utility_modules}
528 PROVIDES_MODULES utility_enabled_modules
529 # These modules were either requested or unrecognized by an earlier scan.
530 REQUEST_MODULES ${required_modules}
531 ${unrecognized_modules}
532 REQUIRES_MODULES required_modules
533 UNRECOGNIZED_MODULES unrecognized_modules
534 HIDE_MODULES_FROM_CACHE ON)
536if (required_modules OR unrecognized_modules)
537 # Not all of the modules we required were found. This should probably error out.
541function (vtk_module_scan)
542 cmake_parse_arguments(PARSE_ARGV 0 _vtk_scan
544 "WANT_BY_DEFAULT;HIDE_MODULES_FROM_CACHE;PROVIDES_MODULES;REQUIRES_MODULES;UNRECOGNIZED_MODULES;ENABLE_TESTS;PROVIDES_KITS
"
545 "MODULE_FILES;KIT_FILES;REQUEST_MODULES;REJECT_MODULES
")
547 if (_vtk_scan_UNPARSED_ARGUMENTS)
550 "${_vtk_scan_UNPARSED_ARGUMENTS}
")
553 if (NOT DEFINED _vtk_scan_WANT_BY_DEFAULT)
554 set(_vtk_scan_WANT_BY_DEFAULT OFF)
557 if (NOT DEFINED _vtk_scan_HIDE_MODULES_FROM_CACHE)
558 set(_vtk_scan_HIDE_MODULES_FROM_CACHE OFF)
561 if (NOT DEFINED _vtk_scan_PROVIDES_MODULES)
563 "The `PROVIDES_MODULES` argument is required.
")
566 if (NOT DEFINED _vtk_scan_PROVIDES_KITS AND _vtk_scan_KIT_FILES)
568 "The `PROVIDES_KITS` argument is required.
")
571 if (NOT DEFINED _vtk_scan_ENABLE_TESTS)
572 set(_vtk_scan_ENABLE_TESTS "DEFAULT
")
575 if (NOT (_vtk_scan_ENABLE_TESTS STREQUAL "ON
" OR
576 _vtk_scan_ENABLE_TESTS STREQUAL "OFF
" OR
577 _vtk_scan_ENABLE_TESTS STREQUAL "WANT
" OR
578 _vtk_scan_ENABLE_TESTS STREQUAL "DEFAULT
"))
580 "The `ENABLE_TESTS` argument must be one of `ON`, `OFF`, `WANT`, or
"
581 "`DEFAULT`.
" "Received `${_vtk_scan_ENABLE_TESTS}`.
")
584 if (NOT _vtk_scan_MODULE_FILES)
586 "No module files given to scan.
")
589 set(_vtk_scan_option_default_type STRING)
590 if (_vtk_scan_HIDE_MODULES_FROM_CACHE)
591 set(_vtk_scan_option_default_type INTERNAL)
594 set(_vtk_scan_all_kits)
596 foreach (_vtk_scan_kit_file IN LISTS _vtk_scan_KIT_FILES)
597 if (NOT IS_ABSOLUTE "${_vtk_scan_kit_file}
")
598 string(PREPEND _vtk_scan_kit_file "${CMAKE_CURRENT_SOURCE_DIR}/
")
600 set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}
" APPEND
602 CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_kit_file}
")
604 file(READ "${_vtk_scan_kit_file}
" _vtk_scan_kit_args)
606 string(REGEX REPLACE "#[^\n]*\n
" "\n
" _vtk_scan_kit_args "${_vtk_scan_kit_args}
")
607 # Use argument splitting.
608 string(REGEX REPLACE "( |\n)+
" ";
" _vtk_scan_kit_args "${_vtk_scan_kit_args}
")
609 _vtk_module_parse_kit_args(_vtk_scan_kit_name ${_vtk_scan_kit_args})
610 _vtk_module_debug(kit "@_vtk_scan_kit_name@ declared by @_vtk_scan_kit_file
@")
612 list(APPEND _vtk_scan_all_kits
613 "${_vtk_scan_kit_name}
")
615 # Set properties for building.
618 "_vtk_kit_${_vtk_scan_kit_name}_namespace
" "${${_vtk_scan_kit_name}_NAMESPACE}
")
621 "_vtk_kit_${_vtk_scan_kit_name}_target_name
" "${${_vtk_scan_kit_name}_TARGET_NAME}
")
624 "_vtk_kit_${_vtk_scan_kit_name}_library_name
" "${${_vtk_scan_kit_name}_LIBRARY_NAME}
")
627 set(_vtk_scan_all_modules)
628 set(_vtk_scan_all_groups)
629 set(_vtk_scan_rejected_modules)
631 # Read all of the module files passed in.
632 foreach (_vtk_scan_module_file IN LISTS _vtk_scan_MODULE_FILES)
633 if (NOT IS_ABSOLUTE "${_vtk_scan_module_file}
")
634 string(PREPEND _vtk_scan_module_file "${CMAKE_CURRENT_SOURCE_DIR}/
")
636 set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}
" APPEND
638 CMAKE_CONFIGURE_DEPENDS "${_vtk_scan_module_file}
")
640 file(READ "${_vtk_scan_module_file}
" _vtk_scan_module_args)
642 string(REGEX REPLACE "#[^\n]*\n
" "\n
" _vtk_scan_module_args "${_vtk_scan_module_args}
")
643 # Use argument splitting.
644 string(REGEX REPLACE "( |\n)+
" ";
" _vtk_scan_module_args "${_vtk_scan_module_args}
")
645 _vtk_module_parse_module_args(_vtk_scan_module_name ${_vtk_scan_module_args})
646 _vtk_module_debug(module "@_vtk_scan_module_name@ declared by @_vtk_scan_module_file
@")
647 string(REPLACE "::
" "_
" _vtk_scan_module_name_safe "${_vtk_scan_module_name}
")
649 if (${_vtk_scan_module_name}_THIRD_PARTY)
650 if (_vtk_module_warnings)
651 if (${_vtk_scan_module_name}_EXCLUDE_WRAP)
653 "The third party ${_vtk_scan_module_name} module does not need to
"
654 "declare `EXCLUDE_WRAP` also.
")
657 if (${_vtk_scan_module_name}_IMPLEMENTABLE)
659 "The third party ${_vtk_scan_module_name} module may not be
"
662 if (${_vtk_scan_module_name}_IMPLEMENTS)
664 "The third party ${_vtk_scan_module_name} module may not
"
665 "`IMPLEMENTS` another module.
")
667 if (${_vtk_scan_module_name}_KIT)
669 "The third party ${_vtk_scan_module_name} module may not be part of
"
670 "a kit (${${_vtk_scan_module_name}_KIT}).
")
674 if (${_vtk_scan_module_name}_KIT)
675 if (NOT ${_vtk_scan_module_name}_KIT IN_LIST _vtk_scan_all_kits)
677 "The ${_vtk_scan_module_name} belongs to the
"
678 "${${_vtk_scan_module_name}_KIT} kit, but it has not been scanned.
")
682 # Check if the module is visible. Modules which have a failing condition
683 # are basically invisible.
684 if (DEFINED ${_vtk_scan_module_name}_CONDITION)
685 if (NOT (${${_vtk_scan_module_name}_CONDITION}))
686 if (DEFINED "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
")
687 set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
"
691 _vtk_module_debug(module "@_vtk_scan_module_name@ hidden by its `CONDITION`
")
696 # Determine whether we should provide a user-visible option for this
698 set(_vtk_build_use_option 1)
699 if (DEFINED _vtk_scan_REQUEST_MODULE)
700 if (_vtk_scan_module_name IN_LIST _vtk_scan_REQUEST_MODULE)
701 set("_vtk_scan_enable_${_vtk_scan_module_name}
" YES)
702 set(_vtk_build_use_option 0)
705 if (DEFINED _vtk_scan_REJECT_MODULES)
706 if (_vtk_scan_module_name IN_LIST _vtk_scan_REJECT_MODULES)
707 if (NOT _vtk_build_use_option)
709 "The ${_vtk_scan_module_name} module has been requested and rejected.
")
711 # Rejected modules should not have a build option.
712 set(_vtk_build_use_option 0)
713 list(APPEND _vtk_scan_rejected_modules
714 "${_vtk_scan_module_name}
")
718 # Handle cache entries and determine the enabled state of the module from
719 # the relevant cache variables.
720 if (_vtk_build_use_option)
721 set("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
" "DEFAULT
"
722 CACHE STRING "Enable the ${_vtk_scan_module_name} module. ${${_vtk_scan_module_name}_DESCRIPTION}
")
723 mark_as_advanced("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
")
724 set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
"
726 STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT
")
727 _vtk_module_verify_enable_value("VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
")
729 if (NOT VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT
")
730 set("_vtk_scan_enable_${_vtk_scan_module_name}
" "${VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}}
")
731 set("_vtk_scan_enable_reason_${_vtk_scan_module_name}
"
732 "via `VTK_MDDULE_ENABLE_${_vtk_scan_module_name_safe}`
")
733 _vtk_module_debug(enable "@_vtk_scan_module_name@ is `${_vtk_scan_enable_${_vtk_scan_module_name}}` by cache
value")
736 # Check the state of any groups the module belongs to.
737 foreach (_vtk_scan_group IN LISTS "${_vtk_scan_module_name}_GROUPS
")
738 if (NOT DEFINED "VTK_GROUP_ENABLE_${_vtk_scan_group}
")
739 set(_vtk_scan_group_default "DEFAULT
")
740 if (DEFINED "_vtk_module_group_default_${_vtk_scan_group}
")
741 set(_vtk_scan_group_default "${_vtk_module_group_default_${_vtk_scan_group}}
")
743 set("VTK_GROUP_ENABLE_${_vtk_scan_group}
" "${_vtk_scan_group_default}
"
744 CACHE STRING "Enable the ${_vtk_scan_group} group modules.
")
745 set_property(CACHE "VTK_GROUP_ENABLE_${_vtk_scan_group}
"
747 STRINGS "YES;WANT;DONT_WANT;NO;DEFAULT
")
748 set_property(CACHE "VTK_GROUP_ENABLE_${_vtk_scan_group}
"
750 TYPE "${_vtk_scan_option_default_type}
")
752 _vtk_module_verify_enable_value("VTK_GROUP_ENABLE_${_vtk_scan_group}
")
754 if (NOT VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT
")
758 # Determine the state of the group.
759 set(_vtk_scan_group_enable "${VTK_GROUP_ENABLE_${_vtk_scan_group}}
")
760 if (NOT _vtk_scan_group_enable STREQUAL "DEFAULT
")
761 set("_vtk_scan_enable_${_vtk_scan_module_name}
" "${_vtk_scan_group_enable}
")
762 set("_vtk_scan_enable_reason_${_vtk_scan_module_name}
"
763 "via `VTK_GROUP_ENABLE_${_vtk_scan_group}`
")
764 _vtk_module_debug(enable "@_vtk_scan_module_name@ is DEFAULT,
using group `@_vtk_scan_group@` setting: @_vtk_scan_group_enable
@")
768 set_property(CACHE "VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe}
"
770 TYPE "${_vtk_scan_option_default_type}
")
773 if (NOT DEFINED "_vtk_scan_enable_${_vtk_scan_module_name}
" AND
774 VTK_MODULE_ENABLE_${_vtk_scan_module_name_safe} STREQUAL "DEFAULT
")
775 if (_vtk_scan_WANT_BY_DEFAULT)
776 set("_vtk_scan_enable_${_vtk_scan_module_name}
" "WANT
")
778 set("_vtk_scan_enable_${_vtk_scan_module_name}
" "DONT_WANT
")
780 if (DEFINED _vtk_module_reason_WANT_BY_DEFAULT)
781 set("_vtk_scan_enable_reason_${_vtk_scan_module_name}
"
782 "${_vtk_module_reason_WANT_BY_DEFAULT}
")
784 set("_vtk_scan_enable_reason_${_vtk_scan_module_name}
"
785 "via `WANT_BY_DEFAULT=${_vtk_scan_WANT_BY_DEFAULT}`
")
787 _vtk_module_debug(enable "@_vtk_scan_module_name@ is DEFAULT,
using `WANT_BY_DEFAULT`: ${_vtk_scan_enable_${_vtk_scan_module_name}}
")
790 list(APPEND _vtk_scan_all_modules
791 "${_vtk_scan_module_name}
")
792 set("_vtk_scan_${_vtk_scan_module_name}_all_depends
"
793 ${${_vtk_scan_module_name}_DEPENDS}
794 ${${_vtk_scan_module_name}_PRIVATE_DEPENDS})
796 if (${_vtk_scan_module_name}_THIRD_PARTY)
797 set("${_vtk_scan_module_name}_EXCLUDE_WRAP
" TRUE)
798 set("${_vtk_scan_module_name}_IMPLEMENTABLE
" FALSE)
799 set("${_vtk_scan_module_name}_IMPLEMENTS
")
802 if (${_vtk_scan_module_name}_KIT)
803 _vtk_module_debug(kit "@_vtk_scan_module_name@ belongs to the ${${_vtk_scan_module_name}_KIT} kit
")
806 # Set properties for building.
809 "_vtk_module_${_vtk_scan_module_name}_file
" "${_vtk_scan_module_file}
")
812 "_vtk_module_${_vtk_scan_module_name}_namespace
" "${${_vtk_scan_module_name}_NAMESPACE}
")
815 "_vtk_module_${_vtk_scan_module_name}_target_name
" "${${_vtk_scan_module_name}_TARGET_NAME}
")
818 "_vtk_module_${_vtk_scan_module_name}_library_name
" "${${_vtk_scan_module_name}_LIBRARY_NAME}
")
821 "_vtk_module_${_vtk_scan_module_name}_third_party
" "${${_vtk_scan_module_name}_THIRD_PARTY}
")
824 "_vtk_module_${_vtk_scan_module_name}_exclude_wrap
" "${${_vtk_scan_module_name}_EXCLUDE_WRAP}
")
827 "_vtk_module_${_vtk_scan_module_name}_kit
" "${${_vtk_scan_module_name}_KIT}
")
830 "_vtk_module_${_vtk_scan_module_name}_depends
" "${${_vtk_scan_module_name}_DEPENDS}
")
833 "_vtk_module_${_vtk_scan_module_name}_order_depends
" "${${_vtk_scan_module_name}_ORDER_DEPENDS}
")
836 "_vtk_module_${_vtk_scan_module_name}_private_depends
" "${${_vtk_scan_module_name}_PRIVATE_DEPENDS}
")
839 "_vtk_module_${_vtk_scan_module_name}_optional_depends
" "${${_vtk_scan_module_name}_OPTIONAL_DEPENDS}
")
842 "_vtk_module_${_vtk_scan_module_name}_test_depends
" "${${_vtk_scan_module_name}_TEST_DEPENDS}
")
845 "_vtk_module_${_vtk_scan_module_name}_test_optional_depends
" "${${_vtk_scan_module_name}_TEST_OPTIONAL_DEPENDS}
")
848 "_vtk_module_${_vtk_scan_module_name}_test_labels
" "${${_vtk_scan_module_name}_TEST_LABELS}
")
851 "_vtk_module_${_vtk_scan_module_name}_implements
" "${${_vtk_scan_module_name}_IMPLEMENTS}
")
854 "_vtk_module_${_vtk_scan_module_name}_implementable
" "${${_vtk_scan_module_name}_IMPLEMENTABLE}
")
855 if (_vtk_scan_ENABLE_TESTS STREQUAL "WANT
")
858 "_vtk_module_${_vtk_scan_module_name}_enable_tests_by_want
" "1
")
862 set(_vtk_scan_current_modules "${_vtk_scan_all_modules}
")
863 vtk_topological_sort(_vtk_scan_all_modules "_vtk_scan_
" "_all_depends
")
865 set(_vtk_scan_provided_modules)
866 set(_vtk_scan_required_modules)
867 set(_vtk_scan_disabled_modules)
869 # Seed the `_vtk_scan_provide_` variables with modules requested and rejected
871 foreach (_vtk_scan_request_module IN LISTS _vtk_scan_REQUEST_MODULES)
872 set("_vtk_scan_provide_${_vtk_scan_request_module}
" ON)
873 if (DEFINED "_vtk_module_reason_${_vtk_scan_request_module}
")
874 set("_vtk_scan_provide_reason_${_vtk_scan_request_module}
"
875 "${_vtk_module_reason_${_vtk_scan_request_module}}
")
877 set("_vtk_scan_provide_reason_${_vtk_scan_request_module}
"
878 "via REQUEST_MODULES
")
880 _vtk_module_debug(provide "@_vtk_scan_request_module@ is provided via `REQUEST_MODULES`
")
882 foreach (_vtk_scan_reject_module IN LISTS _vtk_scan_REJECT_MODULES)
883 set("_vtk_scan_provide_${_vtk_scan_reject_module}
" OFF)
884 if (DEFINED "_vtk_module_reason_${_vtk_scan_reject_module}
")
885 set("_vtk_scan_provide_reason_${_vtk_scan_reject_module}
"
886 "${_vtk_module_reason_${_vtk_scan_reject_module}}
")
888 set("_vtk_scan_provide_reason_${_vtk_scan_reject_module}
"
889 "via REJECT_MODULES
")
891 _vtk_module_debug(provide "@_vtk_scan_reject_module@ is not provided via `REJECT_MODULES`
")
894 # Traverse the graph classifying the quad-state for enabling modules into a
895 # boolean stored in the `_vtk_scan_provide_` variables.
896 foreach (_vtk_scan_module IN LISTS _vtk_scan_all_modules)
897 if (NOT _vtk_scan_module IN_LIST _vtk_scan_current_modules)
898 _vtk_module_debug(provide "@_vtk_scan_module@ is ignored because it is not in the current scan set
")
902 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module}
")
904 elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "YES
")
905 # Mark enabled modules as to-be-provided. Any errors with requiring a
906 # disabled module will be dealt with later.
907 set("_vtk_scan_provide_${_vtk_scan_module}
" ON)
908 set("_vtk_scan_provide_reason_${_vtk_scan_module}
"
909 "via a `YES` setting (${_vtk_scan_enable_reason_${_vtk_scan_module}})
")
910 _vtk_module_debug(provide "@_vtk_scan_module@ is provided due to `YES` setting
")
911 elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "WANT
")
912 # Check to see if we can provide this module by checking of any of its
913 # dependencies have been disabled.
914 set(_vtk_scan_test_depends)
915 if (NOT ${_vtk_scan_module}_THIRD_PARTY AND _vtk_scan_ENABLE_TESTS STREQUAL "ON
")
916 # If the tests have to be on, we also need the test dependencies.
917 set(_vtk_scan_test_depends "${${_vtk_scan_module}_TEST_DEPENDS}
")
920 set("_vtk_scan_provide_${_vtk_scan_module}
" ON)
921 set("_vtk_scan_provide_reason_${_vtk_scan_module}
"
922 "via a `WANT` setting (${_vtk_scan_enable_reason_${_vtk_scan_module}})
")
923 _vtk_module_debug(provide "@_vtk_scan_module@ is provided due to `WANT` setting
")
924 foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS
" "${_vtk_scan_module}_PRIVATE_DEPENDS
" _vtk_scan_test_depends)
925 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}
" AND NOT _vtk_scan_provide_${_vtk_scan_module_depend})
926 set("_vtk_scan_provide_${_vtk_scan_module}
" OFF)
927 set("_vtk_scan_provide_reason_${_vtk_scan_module}
"
928 "due to the ${_vtk_scan_module_depend} module not being available
")
929 if (DEFINED "_vtk_scan_provide_reason_${_vtk_scan_module_depend}
")
930 string(APPEND "_vtk_scan_provide_reason_${_vtk_scan_module}
"
931 " (${_vtk_scan_provide_reason_${_vtk_scan_module_depend}})
")
933 _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to not provided dependency @_vtk_scan_module_depend
@")
937 elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "DONT_WANT
")
938 # Check for disabled dependencies and disable if so.
939 foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS
" "${_vtk_scan_module}_PRIVATE_DEPENDS
" _vtk_scan_test_depends)
940 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}
" AND NOT _vtk_scan_provide_${_vtk_scan_module_depend})
941 set("_vtk_scan_provide_${_vtk_scan_module}
" OFF)
942 set("_vtk_scan_provide_reason_${_vtk_scan_module}
"
943 "due to the ${_vtk_scan_module_depend} module not being available
")
944 if (DEFINED "_vtk_scan_provide_reason_${_vtk_scan_module_depend}
")
945 string(APPEND "_vtk_scan_provide_reason_${_vtk_scan_module}
"
946 " (${_vtk_scan_provide_reason_${_vtk_scan_module_depend}})
")
948 _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to not provided dependency @_vtk_scan_module_depend
@")
952 elseif (_vtk_scan_enable_${_vtk_scan_module} STREQUAL "NO
")
953 # Disable the module.
954 set("_vtk_scan_provide_${_vtk_scan_module}
" OFF)
955 set("_vtk_scan_provide_reason_${_vtk_scan_module}
"
956 "via a `NO` setting (${_vtk_scan_enable_reason_${_vtk_scan_module}})
")
957 _vtk_module_debug(provide "@_vtk_scan_module@ is not provided due to `NO` setting
")
960 # Collect disabled modules into a list.
961 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module}
" AND NOT _vtk_scan_provide_${_vtk_scan_module})
962 list(APPEND _vtk_scan_disabled_modules
963 "${_vtk_scan_module}
")
966 if (NOT DEFINED "_vtk_scan_provide_${_vtk_scan_module}
")
967 _vtk_module_debug(provide "@_vtk_scan_module@ is indeterminite (${_vtk_scan_enable_${_vtk_scan_module}})
")
971 # Scan all modules from the top of tree to the bottom.
972 list(REVERSE _vtk_scan_all_modules)
973 foreach (_vtk_scan_module IN LISTS _vtk_scan_all_modules)
974 if (NOT _vtk_scan_module IN_LIST _vtk_scan_current_modules)
978 # If we're providing this module...
979 if (_vtk_scan_provide_${_vtk_scan_module})
980 list(APPEND _vtk_scan_provided_modules
981 "${_vtk_scan_module}
")
983 # Grab any test dependencies that are required.
984 set(_vtk_scan_test_depends)
985 set(_vtk_scan_test_wants)
986 if (NOT ${_vtk_scan_module}_THIRD_PARTY)
987 if (_vtk_scan_ENABLE_TESTS STREQUAL "ON
")
988 set_property(GLOBAL APPEND
990 "_vtk_module_test_modules
" "${_vtk_scan_module}
")
991 set(_vtk_scan_test_depends "${${_vtk_scan_module}_TEST_DEPENDS}
")
992 elseif (_vtk_scan_ENABLE_TESTS STREQUAL "WANT
")
993 set_property(GLOBAL APPEND
995 "_vtk_module_test_modules
" "${_vtk_scan_module}
")
996 set(_vtk_scan_test_wants _vtk_scan_wants_marker ${${_vtk_scan_module}_TEST_DEPENDS})
997 elseif (_vtk_scan_ENABLE_TESTS STREQUAL "DEFAULT
")
998 set_property(GLOBAL APPEND
1000 "_vtk_module_test_modules
" "${_vtk_scan_module}
")
1001 elseif (_vtk_scan_ENABLE_TESTS STREQUAL "OFF
")
1005 "Unrecognized option
for ENABLE_TESTS: ${_vtk_module_ENABLE_TESTS}.
")
1009 # Add all dependent modules to the list of required or provided modules.
1010 set(_vtk_scan_is_wanting 0)
1011 foreach (_vtk_scan_module_depend IN LISTS "${_vtk_scan_module}_DEPENDS
" "${_vtk_scan_module}_PRIVATE_DEPENDS
" _vtk_scan_test_depends _vtk_scan_test_wants)
1012 if (_vtk_scan_module_depend STREQUAL "_vtk_scan_wants_marker
")
1013 set(_vtk_scan_is_wanting 1)
1016 # Though we need to error if this would cause a disabled module to be
1018 if (_vtk_scan_module_depend IN_LIST _vtk_scan_disabled_modules)
1019 if (_vtk_scan_is_wanting)
1023 "The ${_vtk_scan_module} module (enabled
"
1024 "${_vtk_scan_provide_reason_${_vtk_scan_module}})
requires the
"
1025 "disabled module ${_vtk_scan_module_depend} (disabled
"
1026 "${_vtk_scan_provide_reason_${_vtk_scan_module_depend}}).
")
1030 if (DEFINED "_vtk_scan_provide_${_vtk_scan_module_depend}
")
1031 if (NOT _vtk_scan_provide_${_vtk_scan_module_depend})
1033 "The ${_vtk_scan_module_depend} module (disabled
"
1034 "${_vtk_scan_provide_reason_${_vtk_scan_module_depend}}) should
"
1035 "be provided because it is required by ${_vtk_scan_module}
"
1036 "(${_vtk_scan_provide_reason_${_vtk_scan_module}})
")
1040 set("_vtk_scan_provide_reason_${_vtk_scan_module_depend}
"
1041 "via dependency from ${_vtk_scan_module}
")
1042 if (DEFINED "_vtk_scan_provide_reason_${_vtk_scan_module}
")
1043 string(APPEND "_vtk_scan_provide_reason_${_vtk_scan_module_depend}
"
1044 " (${_vtk_scan_provide_reason_${_vtk_scan_module}})
")
1046 set("_vtk_scan_provide_${_vtk_scan_module_depend}
" ON)
1048 if (NOT _vtk_scan_module_depend IN_LIST _vtk_scan_current_modules)
1049 if (NOT TARGET "${_vtk_scan_module_depend}
")
1050 _vtk_module_debug(provide "@_vtk_scan_module_depend@ is external and required due to dependency from @_vtk_scan_module
@")
1052 list(APPEND _vtk_scan_required_modules
1053 "${_vtk_scan_module_depend}
")
1055 _vtk_module_debug(provide "@_vtk_scan_module_depend@ is provided due to dependency from @_vtk_scan_module
@")
1056 list(APPEND _vtk_scan_provided_modules
1057 "${_vtk_scan_module_depend}
")
1063 if (_vtk_scan_provided_modules)
1064 list(REMOVE_DUPLICATES _vtk_scan_provided_modules)
1067 set(_vtk_scan_provided_kits)
1069 # Build a list of kits which contain the provided modules.
1070 foreach (_vtk_scan_provided_module IN LISTS _vtk_scan_provided_modules)
1071 if (${_vtk_scan_provided_module}_KIT)
1072 list(APPEND _vtk_scan_provided_kits
1073 "${${_vtk_scan_provided_module}_KIT}
")
1074 set_property(GLOBAL APPEND
1076 "_vtk_kit_${${_vtk_scan_provided_module}_KIT}_kit_modules
" "${_vtk_scan_provided_module}
")
1080 if (_vtk_scan_provided_kits)
1081 list(REMOVE_DUPLICATES _vtk_scan_provided_kits)
1084 if (_vtk_scan_required_modules)
1085 list(REMOVE_DUPLICATES _vtk_scan_required_modules)
1088 set(_vtk_scan_unrecognized_modules
1089 ${_vtk_scan_REQUEST_MODULES}
1090 ${_vtk_scan_REJECT_MODULES})
1092 if (_vtk_scan_unrecognized_modules AND (_vtk_scan_provided_modules OR _vtk_scan_rejected_modules))
1093 list(REMOVE_ITEM _vtk_scan_unrecognized_modules
1094 ${_vtk_scan_provided_modules}
1095 ${_vtk_scan_rejected_modules})
1098 set("${_vtk_scan_PROVIDES_MODULES}
"
1099 ${_vtk_scan_provided_modules}
1102 if (DEFINED _vtk_scan_REQUIRES_MODULES)
1103 set("${_vtk_scan_REQUIRES_MODULES}
"
1104 ${_vtk_scan_required_modules}
1108 if (DEFINED _vtk_scan_UNRECOGNIZED_MODULES)
1109 set("${_vtk_scan_UNRECOGNIZED_MODULES}
"
1110 ${_vtk_scan_unrecognized_modules}
1114 if (DEFINED _vtk_scan_PROVIDES_KITS)
1115 set("${_vtk_scan_PROVIDES_KITS}
"
1116 ${_vtk_scan_provided_kits}
1122@page module-overview
1124@section module-target-functions Module-as-target functions
1126Due to the nature of VTK modules supporting being built as kits, the module
1127name might not be usable as a target to CMake's `target_` family of commands.
1128Instead, there are various wrappers around them which take the module name as
1129an argument. These handle the forwarding of relevant information to the kit
1130library as well where necessary.
1132 - @ref vtk_module_set_properties
1133 - @ref vtk_module_set_property
1134 - @ref vtk_module_get_property
1135 - @ref vtk_module_depend
1136 - @ref vtk_module_include
1137 - @ref vtk_module_definitions
1138 - @ref vtk_module_compile_options
1139 - @ref vtk_module_compile_features
1140 - @ref vtk_module_link
1141 - @ref vtk_module_link_options
1145@page module-internal-api
1147@section module-target-internals Module target internals
1149When manipulating modules as targets, there are a few functions provided for
1150use in wrapping code to more easily access them.
1152 - @ref _vtk_module_real_target
1153 - @ref _vtk_module_real_target_kit
1157@ingroup module-internal
1158@brief The real target for a module
1161_vtk_module_real_target(<var> <module>)
1164Sometimes the actual, core target for a module is required (e.g., setting
1165CMake-level target properties or install rules). This function returns the real
1168function (_vtk_module_real_target var module)
1174 set(_vtk_real_target_res "")
1175 if (TARGET "${module}
")
1176 get_property(_vtk_real_target_imported
1179 if (_vtk_real_target_imported)
1180 set(_vtk_real_target_res "${module}
")
1184 if (NOT _vtk_real_target_res)
1185 get_property(_vtk_real_target_res GLOBAL
1186 PROPERTY "_vtk_module_${module}_target_name
")
1187 # Querying during the build.
1188 if (DEFINED _vtk_build_BUILD_WITH_KITS AND _vtk_build_BUILD_WITH_KITS)
1189 get_property(_vtk_real_target_kit GLOBAL
1190 PROPERTY "_vtk_module_${module}_kit
")
1191 if (_vtk_real_target_kit)
1192 string(APPEND _vtk_real_target_res "-objects
")
1194 # A query for after the module is built.
1195 elseif (TARGET "${_vtk_real_target_res}-objects
")
1196 string(APPEND _vtk_real_target_res "-objects
")
1200 if (NOT _vtk_real_target_res)
1201 set(_vtk_real_target_msg "")
1202 if (NOT TARGET "${module}
")
1203 if (DEFINED _vtk_build_module)
1204 set(_vtk_real_target_msg
1205 " Is a module dependency missing?
")
1206 elseif (TARGET "${module}
")
1207 set(_vtk_real_target_msg
1208 " It
's a target, but is it a VTK module?")
1210 set(_vtk_real_target_msg
1211 " The module name is not a CMake target. Is there a typo? Is it missing a `Package::` prefix? Is a `find_package` missing a required component?")
1215 "Failed to determine the real target for the `${module}` "
1216 "module.${_vtk_real_target_msg}")
1220 "${_vtk_real_target_res}"
1225@ingroup module-internal
1226@brief The real target for a kit
1229_vtk_module_real_target_kit(<var> <kit>)
1232Sometimes the actual, core target for a module is required (e.g., setting
1233CMake-level target properties or install rules). This function returns the real
1236function (_vtk_module_real_target_kit var kit)
1239 "Unparsed arguments for _vtk_module_real_target_kit: ${ARGN}.")
1242 set(_vtk_real_target_res "")
1243 if (TARGET "${kit}")
1244 get_property(_vtk_real_target_imported
1247 if (_vtk_real_target_imported)
1248 set(_vtk_real_target_res "${kit}")
1252 if (NOT _vtk_real_target_res)
1253 get_property(_vtk_real_target_res GLOBAL
1254 PROPERTY "_vtk_kit_${kit}_target_name")
1257 if (NOT _vtk_real_target_res)
1259 "Failed to determine the real target for the `${kit}` kit.")
1263 "${_vtk_real_target_res}"
1269@brief Set multiple properties on a module
1271A wrapper around `set_target_properties` that works for modules.
1274vtk_module_set_properties(<module>
1275 [<property> <value>]...)
1278function (vtk_module_set_properties module)
1279 _vtk_module_real_target(_vtk_set_properties_target "${module}")
1281 set_target_properties("${_vtk_set_properties_target}"
1288@brief Set a property on a module
1290A wrapper around `set_property(TARGET)` that works for modules.
1293vtk_module_set_property(<module>
1294 [APPEND] [APPEND_STRING]
1299function (vtk_module_set_property module)
1300 cmake_parse_arguments(PARSE_ARGV 1 _vtk_property
1301 "APPEND;APPEND_STRING"
1305 if (_vtk_property_UNPARSED_ARGUMENTS)
1307 "Unparsed arguments for vtk_module_set_property: "
1308 "${_vtk_property_UNPARSED_ARGUMENTS}.")
1311 if (NOT DEFINED _vtk_property_PROPERTY)
1313 "The `PROPERTY` argument is required.")
1316 if (NOT DEFINED _vtk_property_VALUE)
1318 "The `VALUE` argument is required.")
1321 if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1323 "`APPEND` and `APPEND_STRING` may not be used at the same time.")
1326 set(_vtk_property_args)
1327 if (_vtk_property_APPEND)
1328 list(APPEND _vtk_property_args
1331 if (_vtk_property_APPEND_STRING)
1332 list(APPEND _vtk_property_args
1336 _vtk_module_real_target(_vtk_property_target "${module}")
1338 set_property(TARGET "${_vtk_property_target}"
1339 ${_vtk_property_args}
1341 "${_vtk_property_PROPERTY}" "${_vtk_property_VALUE}")
1346@brief Get a property from a module
1348A wrapper around `get_property(TARGET)` that works for modules.
1351vtk_module_get_property(<module>
1353 VARIABLE <variable>)
1356The variable name passed to the `VARIABLE` argument will be unset if the
1357property is not set (rather than the empty string).
1359function (vtk_module_get_property module)
1360 cmake_parse_arguments(PARSE_ARGV 1 _vtk_property
1365 if (_vtk_property_UNPARSED_ARGUMENTS)
1367 "Unparsed arguments for vtk_module_get_property: "
1368 "${_vtk_property_UNPARSED_ARGUMENTS}.")
1371 if (NOT DEFINED _vtk_property_PROPERTY)
1373 "The `PROPERTY` argument is required.")
1376 if (NOT DEFINED _vtk_property_VARIABLE)
1378 "The `VARIABLE` argument is required.")
1381 _vtk_module_real_target(_vtk_property_target "${module}")
1383 get_property(_vtk_property_is_set
1384 TARGET "${_vtk_property_target}"
1385 PROPERTY "${_vtk_property_PROPERTY}"
1387 if (_vtk_property_is_set)
1388 get_property(_vtk_property_value
1389 TARGET "${_vtk_property_target}"
1390 PROPERTY "${_vtk_property_PROPERTY}")
1392 set("${_vtk_property_VARIABLE}"
1393 "${_vtk_property_value}"
1396 unset("${_vtk_property_VARIABLE}"
1403@brief Generate arguments for target function wrappers
1405Create the `INTERFACE`, `PUBLIC`, and `PRIVATE` arguments for a function
1406wrapping CMake's `target_` functions to call the wrapped function.
1408This is necessary because not all of the functions support empty lists given a
1412 foreach (visibility IN ITEMS INTERFACE PUBLIC PRIVATE)
1413 if (${prefix}_${visibility})
1414 set(
"${prefix}_${visibility}_args"
1416 ${${prefix}_${visibility}}
1424@brief Add dependencies to a module
1426A wrapper around `add_dependencies` that works
for modules.
1429vtk_module_depend(<module> <depend>...)
1435 add_dependencies(
"${_vtk_depend_target}"
1441@brief Add include directories to a module
1443A wrapper around `add_dependencies` that works
for modules.
1446vtk_module_include(<module>
1448 [PUBLIC <directory>...]
1449 [PRIVATE <directory>...]
1450 [INTERFACE <directory>...])
1454 cmake_parse_arguments(PARSE_ARGV 1 _vtk_include
1457 "INTERFACE;PUBLIC;PRIVATE")
1459 if (_vtk_include_UNPARSED_ARGUMENTS)
1461 "Unparsed arguments for vtk_module_include: "
1462 "${_vtk_include_UNPARSED_ARGUMENTS}.")
1466 _vtk_module_target_function(_vtk_include)
1468 set(_vtk_include_system_arg)
1469 if (_vtk_include_SYSTEM)
1470 set(_vtk_include_system_arg SYSTEM)
1473 target_include_directories("${_vtk_include_target}
"
1474 ${_vtk_include_system_arg}
1475 ${_vtk_include_INTERFACE_args}
1476 ${_vtk_include_PUBLIC_args}
1477 ${_vtk_include_PRIVATE_args})
1482@brief Add compile definitions to a module
1484A wrapper around `target_compile_definitions` that works for modules.
1487vtk_module_definitions(<module>
1488 [PUBLIC <directory>...]
1489 [PRIVATE <directory>...]
1490 [INTERFACE <directory>...])
1493function (vtk_module_definitions module)
1494 cmake_parse_arguments(PARSE_ARGV 1 _vtk_definitions
1497 "INTERFACE;PUBLIC;PRIVATE
")
1499 if (_vtk_definitions_UNPARSED_ARGUMENTS)
1502 "${_vtk_definitions_UNPARSED_ARGUMENTS}.
")
1505 _vtk_module_real_target(_vtk_definitions_target "${module}
")
1506 _vtk_module_target_function(_vtk_definitions)
1508 target_compile_definitions("${_vtk_definitions_target}
"
1509 ${_vtk_definitions_INTERFACE_args}
1510 ${_vtk_definitions_PUBLIC_args}
1511 ${_vtk_definitions_PRIVATE_args})
1516@brief Add compile options to a module
1518A wrapper around `target_compile_options` that works for modules.
1521vtk_module_compile_options(<module>
1522 [PUBLIC <directory>...]
1523 [PRIVATE <directory>...]
1524 [INTERFACE <directory>...])
1527function (vtk_module_compile_options module)
1528 cmake_parse_arguments(PARSE_ARGV 1 _vtk_compile_options
1531 "INTERFACE;PUBLIC;PRIVATE
")
1533 if (_vtk_compile_options_UNPARSED_ARGUMENTS)
1536 "${_vtk_compile_options_UNPARSED_ARGUMENTS}.
")
1539 _vtk_module_real_target(_vtk_compile_options_target "${module}
")
1540 _vtk_module_target_function(_vtk_compile_options)
1542 target_compile_options("${_vtk_compile_options_target}
"
1543 ${_vtk_compile_options_INTERFACE_args}
1544 ${_vtk_compile_options_PUBLIC_args}
1545 ${_vtk_compile_options_PRIVATE_args})
1550@brief Add compile features to a module
1552A wrapper around `target_compile_features` that works for modules.
1555vtk_module_compile_features(<module>
1556 [PUBLIC <directory>...]
1557 [PRIVATE <directory>...]
1558 [INTERFACE <directory>...])
1561function (vtk_module_compile_features module)
1562 cmake_parse_arguments(PARSE_ARGV 1 _vtk_compile_features
1565 "INTERFACE;PUBLIC;PRIVATE
")
1567 if (_vtk_compile_features_UNPARSED_ARGUMENTS)
1570 "${_vtk_compile_features_UNPARSED_ARGUMENTS}.
")
1573 _vtk_module_real_target(_vtk_compile_features_target "${module}
")
1574 _vtk_module_target_function(_vtk_compile_features)
1576 target_compile_features("${_vtk_compile_features_target}
"
1577 ${_vtk_compile_features_INTERFACE_args}
1578 ${_vtk_compile_features_PUBLIC_args}
1579 ${_vtk_compile_features_PRIVATE_args})
1584@brief Manage the private link target for a module
1586This function manages the private link target for a module.
1589_vtk_private_kit_link_target(<module>
1591 [SETUP_TARGET_NAME <var>]
1592 [USAGE_TARGET_NAME <var>])
1595function (_vtk_private_kit_link_target module)
1596 cmake_parse_arguments(_vtk_private_kit_link_target
1598 "SETUP_TARGET_NAME;USAGE_TARGET_NAME
"
1602 if (_vtk_private_kit_link_target_UNPARSED_ARGUMENTS)
1605 "${_vtk_private_kit_link_target_UNPARSED_ARGUMENTS}.
")
1608 # Compute the target name.
1609 get_property(_vtk_private_kit_link_base_target_name GLOBAL
1610 PROPERTY "_vtk_module_${module}_target_name
")
1611 if (NOT _vtk_private_kit_link_base_target_name)
1617 set(_vtk_private_kit_link_target_setup_name
1618 "${_vtk_private_kit_link_base_target_name}-
private-kit-links
")
1619 get_property(_vtk_private_kit_link_namespace GLOBAL
1620 PROPERTY "_vtk_module_${module}_namespace
")
1621 if (_vtk_private_kit_link_namespace)
1622 set(_vtk_private_kit_link_target_usage_name
1623 "${_vtk_private_kit_link_namespace}::${_vtk_private_kit_link_target_setup_name}
")
1625 set(_vtk_private_kit_link_target_usage_name
1626 ":${_vtk_private_kit_link_target_setup_name}
")
1629 # Create the target if requested.
1630 if (_vtk_private_kit_link_target_CREATE_IF_NEEDED AND
1631 NOT TARGET "${_vtk_private_kit_link_target_setup_name}
")
1632 add_library("${_vtk_private_kit_link_target_setup_name}
" INTERFACE)
1633 if (NOT _vtk_private_kit_link_target_setup_name STREQUAL _vtk_private_kit_link_target_usage_name)
1634 add_library("${_vtk_private_kit_link_target_usage_name}
" ALIAS
1635 "${_vtk_private_kit_link_target_setup_name}
")
1637 _vtk_module_install("${_vtk_private_kit_link_target_setup_name}
")
1640 if (_vtk_private_kit_link_target_SETUP_TARGET_NAME)
1641 set("${_vtk_private_kit_link_target_SETUP_TARGET_NAME}
"
1642 "${_vtk_private_kit_link_target_setup_name}
"
1646 if (_vtk_private_kit_link_target_USAGE_TARGET_NAME)
1647 set("${_vtk_private_kit_link_target_USAGE_TARGET_NAME}
"
1648 "${_vtk_private_kit_link_target_usage_name}
"
1655@brief Add link libraries to a module
1657A wrapper around `target_link_libraries` that works for modules. Note that this
1658function does extra work in kit builds, so circumventing it may break in kit
1662vtk_module_link(<module>
1663 [PUBLIC <directory>...]
1664 [PRIVATE <directory>...]
1665 [INTERFACE <directory>...])
1668function (vtk_module_link module)
1669 cmake_parse_arguments(PARSE_ARGV 1 _vtk_link
1672 "INTERFACE;PUBLIC;PRIVATE
")
1674 if (_vtk_link_UNPARSED_ARGUMENTS)
1677 "${_vtk_link_UNPARSED_ARGUMENTS}.
")
1680 _vtk_module_real_target(_vtk_link_target "${module}
")
1681 _vtk_module_target_function(_vtk_link)
1683 get_property(_vtk_link_kit GLOBAL
1684 PROPERTY "_vtk_module_${module}_kit
")
1686 if (_vtk_link_PRIVATE)
1687 _vtk_private_kit_link_target("${module}
"
1689 SETUP_TARGET_NAME _vtk_link_private_kit_link_target)
1690 foreach (_vtk_link_private IN LISTS _vtk_link_PRIVATE)
1691 target_link_libraries("${_vtk_link_private_kit_link_target}
"
1693 "$<LINK_ONLY:${_vtk_link_private}>
")
1698 target_link_libraries("${_vtk_link_target}
"
1699 ${_vtk_link_INTERFACE_args}
1700 ${_vtk_link_PUBLIC_args}
1701 ${_vtk_link_PRIVATE_args})
1706@brief Add link options to a module
1708A wrapper around `target_link_options` that works for modules.
1711vtk_module_link_options(<module>
1712 [PUBLIC <directory>...]
1713 [PRIVATE <directory>...]
1714 [INTERFACE <directory>...])
1717function (vtk_module_link_options module)
1718 cmake_parse_arguments(PARSE_ARGV 1 _vtk_link_options
1721 "INTERFACE;PUBLIC;PRIVATE
")
1723 if (_vtk_link_options_UNPARSED_ARGUMENTS)
1726 "${_vtk_link_options_UNPARSED_ARGUMENTS}.
")
1729 _vtk_module_real_target(_vtk_link_options_target "${module}
")
1730 _vtk_module_target_function(_vtk_link_options)
1732 target_link_options("${_vtk_link_options_target}
"
1733 ${_vtk_link_options_INTERFACE_args}
1734 ${_vtk_link_options_PUBLIC_args}
1735 ${_vtk_link_options_PRIVATE_args})
1739@page module-internal-api
1741@ingroup module-internal
1742@section module-properties Module properties
1744The VTK module system leverages CMake's target propagation and storage. As
1745such, there are a number of properties added to the targets representing
1746modules. These properties are intended for use by the module system and
1747associated functionality. In particular, more properties may be available by
1750@subsection module-properties-naming Naming properties
1752When creating properties for use with the module system, they should be
1753prefixed with `INTERFACE_vtk_module_`. The `INTERFACE_` portion is required in
1754order to work with interface libraries. The `vtk_module_` portion is to avoid
1755colliding with any other properties. This function assumes this naming scheme
1756for some of its convenience features as well.
1758Properties should be the same in the local build as well as when imported to
1761@subsection module-properties-system VTK module system properties
1763There are a number of properties that are used and expected by the core of the
1764module system. These are generally module metadata (module dependencies,
1765whether to wrap or not, etc.). The properties all have the
1766`INTERFACE_vtk_module_` prefix mentioned in the previous section.
1768 * `third_party`: If set, the module represents a third party
1769 dependency and should be treated specially. Third party modules are very
1770 restricted and generally do not have any other properties set on them.
1771 * `exclude_wrap`: If set, the module should not be wrapped by an external
1773 * `depends`: The list of dependent modules. Language wrappers will generally
1774 require this to satisfy references to parent classes of the classes in the
1776 * `private_depends`: The list of privately dependent modules. Language
1777 wrappers may require this to satisfy references to parent classes of the
1778 classes in the module.
1779 * `optional_depends`: The list of optionally dependent modules. Language
1780 wrappers may require this to satisfy references to parent classes of the
1781 classes in the module.
1782 * `kit`: The kit the module is a member of. Only set if the module is
1783 actually a member of the kit (i.e., the module was built with
1784 `BUILD_WITH_KITS ON`).
1785 * `implements`: The list of modules for which this module registers to. This
1786 is used by the autoinit subsystem and generally is not required.
1787 * `implementable`: If set, this module provides registries which may be
1788 populated by dependent modules. It is used to check the `implements`
1789 property to help minimize unnecessary work from the autoinit subsystem.
1790 * `needs_autoinit`: If set, linking to this module requires the autoinit
1791 subsystem to ensure that registries in modules are fully populated.
1792 * `headers`: Paths to the public headers from the module. These are the
1793 headers which should be handled by language wrappers.
1794 * `hierarchy`: The path to the hierarchy file describing inheritance of the
1795 classes for use in language wrappers.
1796 * `forward_link`: Usage requirements that must be forwarded even though the
1797 module is linked to privately.
1799Kits have the following properties available (but only if kits are enabled):
1801 * `kit_modules`: Modules which are compiled into the kit.
1805@ingroup module-internal
1806@brief Set a module property
1808This function sets a [module property](@ref module-properties) on a module. The
1809required prefix will automatically be added to the passed name.
1812_vtk_module_set_module_property(<module>
1813 [APPEND] [APPEND_STRING]
1818function (_vtk_module_set_module_property module)
1819 cmake_parse_arguments(PARSE_ARGV 1 _vtk_property
1820 "APPEND;APPEND_STRING
"
1824 if (_vtk_property_UNPARSED_ARGUMENTS)
1826 "Unparsed arguments
for vtk_module_set_module_property:
"
1827 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1830 if (NOT DEFINED _vtk_property_PROPERTY)
1832 "The `PROPERTY` argument is required.
")
1835 if (NOT DEFINED _vtk_property_VALUE)
1837 "The `VALUE` argument is required.
")
1840 if (_vtk_property_APPEND AND _vtk_property_APPEND_STRING)
1842 "`APPEND` and `APPEND_STRING` may not be used at the same
time.
")
1845 set(_vtk_property_args)
1846 if (_vtk_property_APPEND)
1847 list(APPEND _vtk_property_args
1850 if (_vtk_property_APPEND_STRING)
1851 list(APPEND _vtk_property_args
1855 get_property(_vtk_property_is_alias
1857 PROPERTY ALIASED_TARGET
1859 if (_vtk_property_is_alias)
1860 _vtk_module_real_target(_vtk_property_target "${module}
")
1862 set(_vtk_property_target "${module}
")
1865 set_property(TARGET "${_vtk_property_target}
"
1866 ${_vtk_property_args}
1868 "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
" "${_vtk_property_VALUE}
")
1872@ingroup module-internal
1873@brief Get a module property
1875Get a [module property](@ref module-properties) from a module.
1878_vtk_module_get_module_property(<module>
1880 VARIABLE <variable>)
1883As with @ref vtk_module_get_property, the output variable will be unset if the
1884property is not set. The property name is automatically prepended with the
1887function (_vtk_module_get_module_property module)
1888 cmake_parse_arguments(PARSE_ARGV 1 _vtk_property
1893 if (_vtk_property_UNPARSED_ARGUMENTS)
1895 "Unparsed arguments
for vtk_module_get_module_property:
"
1896 "${_vtk_property_UNPARSED_ARGUMENTS}.
")
1899 if (NOT DEFINED _vtk_property_PROPERTY)
1901 "The `PROPERTY` argument is required.
")
1904 if (NOT DEFINED _vtk_property_VARIABLE)
1906 "The `VARIABLE` argument is required.
")
1909 get_property(_vtk_property_is_alias
1911 PROPERTY ALIASED_TARGET
1913 if (_vtk_property_is_alias)
1914 _vtk_module_real_target(_vtk_property_target "${module}
")
1916 set(_vtk_property_target "${module}
")
1919 get_property(_vtk_property_is_set
1920 TARGET "${_vtk_property_target}
"
1921 PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
"
1923 if (_vtk_property_is_set)
1924 get_property(_vtk_property_value
1925 TARGET "${_vtk_property_target}
"
1926 PROPERTY "INTERFACE_vtk_module_${_vtk_property_PROPERTY}
")
1928 set("${_vtk_property_VARIABLE}
"
1929 "${_vtk_property_value}
"
1932 unset("${_vtk_property_VARIABLE}
"
1938@ingroup module-internal
1939@brief Check that destinations are valid
1941All installation destinations are expected to be relative so that
1942`CMAKE_INSTALL_PREFIX` can be relied upon in all code paths. This function may
1943be used to verify that destinations are relative.
1946_vtk_module_check_destinations(<prefix> [<suffix>...])
1949For each `suffix`, `prefix` is prefixed to it and the resulting variable name
1950is checked for validity as an install prefix. Raises an error if any is
1953function (_vtk_module_check_destinations prefix)
1954 foreach (suffix IN LISTS ARGN)
1955 if (IS_ABSOLUTE "${${prefix}${suffix}}
")
1957 "The `${suffix}` must not be an absolute path. Use
"
1958 "`CMAKE_INSTALL_PREFIX` to keep everything in a single installation
"
1965@ingroup module-internal
1966@brief Write an import prefix statement
1968CMake files, once installed, may need to construct paths to other locations
1969within the install prefix. This function writes a prefix computation for file
1970given its install destination.
1973_vtk_module_write_import_prefix(<file> <destination>)
1976The passed file is cleared so that it occurs at the top of the file. The prefix
1977is available in the file as the `_vtk_module_import_prefix` variable. It is
1978recommended to unset the variable at the end of the file.
1980function (_vtk_module_write_import_prefix file destination)
1981 if (IS_ABSOLUTE "${destination}
")
1983 "An
import prefix cannot be determined from an absolute installation
"
1984 "destination. Use `CMAKE_INSTALL_PREFIX` to keep everything in a single
"
1985 "installation prefix.
")
1988 file(WRITE "${file}
"
1989 "set(_vtk_module_import_prefix \
"\${CMAKE_CURRENT_LIST_DIR}\")\n")
1991 get_filename_component(destination
"${destination}" DIRECTORY)
1992 file(APPEND
"${file}"
1993 "get_filename_component(_vtk_module_import_prefix \"\${_vtk_module_import_prefix}\" DIRECTORY)\n")
1999@brief Export properties
on modules and targets
2001This
function is intended
for use in support functions which leverage the
2002module system, not by general system users. This
function supports exporting
2003properties from the build into dependencies via
target properties which are
2004loaded from a project
's config file which is loaded via CMake's `find_package`
2008_vtk_module_export_properties(
2013 [PROPERTIES <property>...]
2014 [FROM_GLOBAL_PROPERTIES <property fragment>...]
2015 [SPLIT_INSTALL_PROPERTIES <property fragment>...])
2018The `BUILD_FILE` and `INSTALL_FILE` arguments are required. Exactly one of
2019`MODULE` and `KIT` is also required. The `MODULE` or `KIT` argument holds the
2020name of the module or kit that will have properties exported. The `BUILD_FILE`
2021and `INSTALL_FILE` paths are *appended to*. As such, when setting up these
2022files, it should be preceded with:
2025file(WRITE
"${build_file}")
2026file(WRITE
"${install_file}")
2029To avoid accidental usage of the install file from the build tree, it is
2030recommended to store it under a `CMakeFiles/` directory in the build tree with
2031an additional `.install` suffix and use `install(RENAME)` to rename it at
2034The set of properties exported is computed as follows:
2036 * `PROPERTIES` queries the module
target for the given
property and exports
2037 its
value as-is to both the build and install files. In addition, these
2038 properties are set
on the
target directly as the same
name.
2039 * `FROM_GLOBAL_PROPERTIES` queries the
global
2040 `_vtk_module_<MODULE>_<fragment>`
property and exports it to both the build
2041 and install files as `INTERFACE_vtk_module_<fragment>`.
2042 * `SPLIT_INSTALL_PROPERTIES` queries the
target for
2043 `INTERFACE_vtk_module_<fragment>` and exports its
value to the build file
2044 and `INTERFACE_vtk_module_<fragment>_install` to the install file as the
2045 non-install
property name. This is generally useful
for properties which
2046 change between the build and installation.
2049 cmake_parse_arguments(PARSE_ARGV 0 _vtk_export_properties
2051 "BUILD_FILE;INSTALL_FILE;MODULE;KIT"
2052 "FROM_GLOBAL_PROPERTIES;PROPERTIES;SPLIT_INSTALL_PROPERTIES")
2054 if (_vtk_export_properties_UNPARSED_ARGUMENTS)
2056 "Unparsed arguments for _vtk_export_properties: "
2057 "${_vtk_export_properties_UNPARSED_ARGUMENTS}.")
2060 if (DEFINED _vtk_export_properties_MODULE)
2061 if (DEFINED _vtk_export_properties_KIT)
2063 "Only one of `MODULE` or `KIT` is required to export properties.")
2065 set(_vtk_export_properties_type "module")
2066 set(_vtk_export_properties_name "${_vtk_export_properties_MODULE}
")
2067 elseif (_vtk_export_properties_KIT)
2068 set(_vtk_export_properties_type "kit
")
2069 set(_vtk_export_properties_name "${_vtk_export_properties_KIT}
")
2072 "A module or kit is required to export properties.
")
2075 if (NOT _vtk_export_properties_BUILD_FILE)
2077 "Exporting properties
requires a build file to write to.
")
2080 if (NOT _vtk_export_properties_INSTALL_FILE)
2082 "Exporting properties
requires an install file to write to.
")
2085 if (_vtk_export_properties_type STREQUAL "module
")
2086 _vtk_module_real_target(_vtk_export_properties_target_name "${_vtk_export_properties_name}
")
2087 elseif (_vtk_export_properties_type STREQUAL "kit
")
2088 _vtk_module_real_target_kit(_vtk_export_properties_target_name "${_vtk_export_properties_name}
")
2091 foreach (_vtk_export_properties_global IN LISTS _vtk_export_properties_FROM_GLOBAL_PROPERTIES)
2092 get_property(_vtk_export_properties_is_set GLOBAL
2093 PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}
"
2095 if (NOT _vtk_export_properties_is_set)
2099 get_property(_vtk_export_properties_value GLOBAL
2100 PROPERTY "_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_name}_${_vtk_export_properties_global}
")
2101 set(_vtk_export_properties_set_property
2102 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}\" \"${_vtk_export_properties_value}\")\n")
2104 set_property(TARGET
"${_vtk_export_properties_target_name}"
2106 "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_global}" "${_vtk_export_properties_value}")
2107 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
2108 "${_vtk_export_properties_set_property}")
2109 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
2110 "${_vtk_export_properties_set_property}")
2113 foreach (_vtk_export_properties_target IN LISTS _vtk_export_properties_PROPERTIES)
2114 get_property(_vtk_export_properties_is_set
2115 TARGET "${_vtk_export_properties_target_name}
"
2116 PROPERTY "${_vtk_export_properties_target}
"
2118 if (NOT _vtk_export_properties_is_set)
2122 get_property(_vtk_export_properties_value
2123 TARGET "${_vtk_export_properties_target_name}
"
2124 PROPERTY "${_vtk_export_properties_target}
")
2125 set(_vtk_export_properties_set_property
2126 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"${_vtk_export_properties_target}\" \"${_vtk_export_properties_value}\")\n")
2128 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
2129 "${_vtk_export_properties_set_property}")
2130 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
2131 "${_vtk_export_properties_set_property}")
2134 foreach (_vtk_export_properties_split IN LISTS _vtk_export_properties_SPLIT_INSTALL_PROPERTIES)
2135 get_property(_vtk_export_properties_is_set
2136 TARGET "${_vtk_export_properties_target_name}
"
2137 PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}
"
2139 if (NOT _vtk_export_properties_is_set)
2143 get_property(_vtk_export_properties_value
2144 TARGET "${_vtk_export_properties_target_name}
"
2145 PROPERTY "INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}
")
2146 set(_vtk_export_properties_set_property
2147 "set_property(TARGET \
"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2148 file(APPEND
"${_vtk_export_properties_BUILD_FILE}"
2149 "${_vtk_export_properties_set_property}")
2151 get_property(_vtk_export_properties_value
2152 TARGET
"${_vtk_export_properties_target_name}"
2153 PROPERTY
"INTERFACE_vtk_${_vtk_export_properties_type}_${_vtk_export_properties_split}_install")
2154 set(_vtk_export_properties_set_property
2155 "set_property(TARGET \"${_vtk_export_properties_name}\" PROPERTY \"INTERFACE_vtk_module_${_vtk_export_properties_split}\" \"${_vtk_export_properties_value}\")\n")
2156 file(APPEND
"${_vtk_export_properties_INSTALL_FILE}"
2157 "${_vtk_export_properties_set_property}")
2161include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleTesting.cmake
")
2165@brief Build modules and kits
2167Once all of the modules have been scanned, they need to be built. Generally,
2168there will be just one build necessary for a set of scans, though they may be
2169built distinctly as well. If there are multiple calls to this function, they
2170should generally in reverse order of their scans.
2177 [LIBRARY_NAME_SUFFIX <suffix>]
2179 [SOVERSION <soversion>]
2183 [BUILD_WITH_KITS <ON|OFF>]
2185 [ENABLE_WRAPPING <ON|OFF>]
2187 [USE_EXTERNAL <ON|OFF>]
2189 [INSTALL_HEADERS <ON|OFF>]
2190 [HEADERS_COMPONENT <component>]
2192 [TARGETS_COMPONENT <component>]
2193 [INSTALL_EXPORT <export>]
2195 [TARGET_SPECIFIC_COMPONENTS <ON|OFF>]
2197 [UTILITY_TARGET <target>]
2199 [TEST_DIRECTORY_NAME <name>]
2200 [TEST_DATA_TARGET <target>]
2201 [TEST_INPUT_DATA_DIRECTORY <directory>]
2202 [TEST_OUTPUT_DATA_DIRECTORY <directory>]
2203 [TEST_OUTPUT_DIRECTORY <directory>]
2205 [ARCHIVE_DESTINATION <destination>]
2206 [HEADERS_DESTINATION <destination>]
2207 [LIBRARY_DESTINATION <destination>]
2208 [RUNTIME_DESTINATION <destination>]
2209 [CMAKE_DESTINATION <destination>]
2210 [LICENSE_DESTINATION <destination>]
2211 [HIERARCHY_DESTINATION <destination>])
2214The only requirement of the function is the list of modules to build, the rest
2215have reasonable defaults if not specified.
2217 * `MODULES`: (Required) The list of modules to build.
2218 * `KITS`: (Required if `BUILD_WITH_KITS` is `ON`) The list of kits to build.
2219 * `LIBRARY_NAME_SUFFIX`: (Defaults to `""`) A suffix to add to library names.
2220 If it is not empty, it is prefixed with `-` to separate it from the kit
2222 * `VERSION`: If specified, the `VERSION` property on built libraries will be
2224 * `SOVERSION`: If specified, the `SOVERSION` property on built libraries will
2225 be set to this value.
2226 * `PACKAGE`: (Defaults to `${CMAKE_PROJECT_NAME}`) The name the build is
2227 meant to be found as when using `find_package`. Note that separate builds
2228 will require distinct `PACKAGE` values.
2229 * `BUILD_WITH_KITS`: (Defaults to `OFF`) If enabled, kit libraries will be
2231 * `ENABLE_WRAPPING`: (Default depends on the existence of
2232 `VTK::WrapHierarchy` or `VTKCompileTools::WrapHierarchy` targets) If
2233 enabled, wrapping will be available to the modules built in this call.
2234 * `USE_EXTERNAL`: (Defaults to `OFF`) Whether third party modules should find
2235 external copies rather than building their own copy.
2236 * `INSTALL_HEADERS`: (Defaults to `ON`) Whether or not to install public headers.
2237 * `HEADERS_COMPONENT`: (Defaults to `development`) The install component to
2238 use for header installation. Note that other SDK-related bits use the same
2239 component (e.g., CMake module files).
2240 * `TARGETS_COMPONENT`: `Defaults to `runtime`) The install component to use
2241 for the libraries built.
2242 * `TARGET_SPECIFIC_COMPONENTS`: (Defaults to `OFF`) If `ON`, place artifacts
2243 into target-specific install components (`<TARGET>-<COMPONENT>`).
2244 * `UTILITY_TARGET`: If specified, all libraries and executables made by the
2245 VTK Module API will privately link to this target. This may be used to
2246 provide things such as project-wide compilation flags or similar.
2247 * `TARGET_NAMESPACE`: `Defaults to `<AUTO>`) The namespace for installed
2248 targets. All targets must have the same namespace. If set to `<AUTO>`,
2249 the namespace will be detected automatically.
2250 * `INSTALL_EXPORT`: (Defaults to `""`) If non-empty, targets will be added to
2251 the given export. The export will also be installed as part of this build
2253 * `TEST_DIRECTORY_NAME`: (Defaults to `Testing`) The name of the testing
2254 directory to look for in each module. Set to `NONE` to disable automatic
2256 * `TEST_DATA_TARGET`: (Defaults to `<PACKAGE>-data`) The target to add
2257 testing data download commands to.
2258 * `TEST_INPUT_DATA_DIRECTORY`: (Defaults to
2259 `${CMAKE_CURRENT_SOURCE_DIR}/Data`) The directory which will contain data
2261 * `TEST_OUTPUT_DATA_DIRECTORY`: (Defaults to
2262 `${CMAKE_CURRENT_BINARY_DIR}/Data`) The directory which will contain data
2264 * `TEST_OUTPUT_DIRECTORY`: (Defaults to
2265 `${CMAKE_BINARY_DIR}/<TEST_DIRECTORY_NAME>/Temporary`) The directory which
2266 tests may write any output files to.
2268The remaining arguments control where to install files related to the build.
2269See CMake documentation for the difference between `ARCHIVE`, `LIBRARY`, and
2272 * `ARCHIVE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2273 destination for archive files.
2274 * `HEADERS_DESTINATION`: (Defaults to `${CMAKE_INSTALL_INCLUDEDIR}`) The
2275 install destination for header files.
2276 * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) The install
2277 destination for library files.
2278 * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) The install
2279 destination for runtime files.
2280 * `CMAKE_DESTINATION`: (Defaults to `<LIBRARY_DESTINATION>/cmake/<PACKAGE>`)
2281 The install destination for CMake files.
2282 * `LICENSE_DESTINATION`: (Defaults to `${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}`)
2283 The install destination for license files (relevant for third party
2285 * `HIERARCHY_DESTINATION`: (Defaults to
2286 `<LIBRARY_DESTINATION>/vtk/hierarchy/<PACKAGE>`) The install destination
2287 for hierarchy files (used for language wrapping).
2289function (vtk_module_build)
2290 set(_vtk_build_install_arguments
2308 HIERARCHY_DESTINATION)
2309 set(_vtk_build_test_arguments
2313 TEST_INPUT_DATA_DIRECTORY
2314 TEST_OUTPUT_DATA_DIRECTORY
2315 TEST_OUTPUT_DIRECTORY)
2317 # TODO: Add an option to build statically? Currently, `BUILD_SHARED_LIBS` is
2320 cmake_parse_arguments(PARSE_ARGV 0 _vtk_build
2322 "BUILD_WITH_KITS;USE_EXTERNAL;TARGET_SPECIFIC_COMPONENTS;LIBRARY_NAME_SUFFIX;VERSION;SOVERSION;PACKAGE;ENABLE_WRAPPING;${_vtk_build_install_arguments};${_vtk_build_test_arguments}
"
2325 if (_vtk_build_UNPARSED_ARGUMENTS)
2328 "${_vtk_build_UNPARSED_ARGUMENTS}
")
2331 if (NOT DEFINED _vtk_build_USE_EXTERNAL)
2332 set(_vtk_build_USE_EXTERNAL OFF)
2335 if (NOT DEFINED _vtk_build_TARGET_SPECIFIC_COMPONENTS)
2336 set(_vtk_build_TARGET_SPECIFIC_COMPONENTS OFF)
2339 if (NOT DEFINED _vtk_build_PACKAGE)
2340 set(_vtk_build_PACKAGE "${CMAKE_PROJECT_NAME}
")
2342 get_property(_vtk_build_package_exists GLOBAL
2343 PROPERTY "_vtk_module_package_${_vtk_build_PACKAGE}
"
2345 if (_vtk_build_package_exists)
2347 "A set of modules have already been built
using the
"
2348 "`${_vtk_build_PACKAGE}` package.
")
2352 "_vtk_module_package_${_vtk_build_PACKAGE}
" "ON
")
2355 if (NOT DEFINED _vtk_build_INSTALL_HEADERS)
2356 set(_vtk_build_INSTALL_HEADERS ON)
2359 if (NOT DEFINED _vtk_build_ENABLE_WRAPPING)
2360 if (TARGET "VTKCompileTools::WrapHierarchy
" OR
2361 TARGET "VTK::WrapHierarchy
")
2362 set(_vtk_build_ENABLE_WRAPPING ON)
2364 set(_vtk_build_ENABLE_WRAPPING OFF)
2368 if (NOT DEFINED _vtk_build_TARGET_NAMESPACE)
2369 set(_vtk_build_TARGET_NAMESPACE "<AUTO>
")
2372 if (NOT DEFINED _vtk_build_BUILD_WITH_KITS)
2373 set(_vtk_build_BUILD_WITH_KITS OFF)
2375 if (_vtk_build_BUILD_WITH_KITS AND NOT BUILD_SHARED_LIBS)
2376 message(AUTHOR_WARNING
2377 "Static builds with kits are not well-tested and doesn
't make much "
2378 "sense. It is recommended to only build with kits in shared builds.")
2381 if (_vtk_build_BUILD_WITH_KITS AND NOT DEFINED _vtk_build_KITS)
2383 "Building with kits was requested, but no kits were specified.")
2386 if (NOT DEFINED _vtk_build_TEST_DIRECTORY_NAME)
2387 set(_vtk_build_TEST_DIRECTORY_NAME "Testing")
2390 if (NOT DEFINED _vtk_build_TEST_DATA_TARGET)
2391 set(_vtk_build_TEST_DATA_TARGET "${_vtk_build_PACKAGE}-data")
2394 if (NOT DEFINED _vtk_build_TEST_INPUT_DATA_DIRECTORY)
2395 set(_vtk_build_TEST_INPUT_DATA_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Data")
2398 if (NOT DEFINED _vtk_build_TEST_OUTPUT_DATA_DIRECTORY)
2399 set(_vtk_build_TEST_OUTPUT_DATA_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Data")
2402 if (NOT DEFINED _vtk_build_TEST_OUTPUT_DIRECTORY)
2403 set(_vtk_build_TEST_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_TEST_DIRECTORY_NAME}/Temporary")
2406 if (NOT DEFINED _vtk_build_HEADERS_COMPONENT)
2407 set(_vtk_build_HEADERS_COMPONENT "development")
2410 if (NOT DEFINED _vtk_build_ARCHIVE_DESTINATION)
2411 set(_vtk_build_ARCHIVE_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
2414 if (NOT DEFINED _vtk_build_HEADERS_DESTINATION)
2415 set(_vtk_build_HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
2418 if (NOT DEFINED _vtk_build_LIBRARY_DESTINATION)
2419 set(_vtk_build_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
2422 if (NOT DEFINED _vtk_build_RUNTIME_DESTINATION)
2423 set(_vtk_build_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}")
2426 if (NOT DEFINED _vtk_build_CMAKE_DESTINATION)
2427 set(_vtk_build_CMAKE_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/cmake/${_vtk_build_PACKAGE}")
2430 if (NOT DEFINED _vtk_build_LICENSE_DESTINATION)
2431 set(_vtk_build_LICENSE_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}")
2434 if (NOT DEFINED _vtk_build_HIERARCHY_DESTINATION)
2435 set(_vtk_build_HIERARCHY_DESTINATION "${_vtk_build_LIBRARY_DESTINATION}/vtk/hierarchy/${_vtk_build_PACKAGE}")
2438 if (NOT DEFINED _vtk_build_TARGETS_COMPONENT)
2439 set(_vtk_build_TARGETS_COMPONENT "runtime")
2442 if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
2443 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_ARCHIVE_DESTINATION}")
2445 if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
2446 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_LIBRARY_DESTINATION}")
2448 if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
2449 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_RUNTIME_DESTINATION}")
2452 if (NOT _vtk_build_MODULES)
2454 "No modules given to build.")
2457 _vtk_module_check_destinations(_vtk_build_
2463 HIERARCHY_DESTINATION)
2465 foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2466 get_property("_vtk_build_${_vtk_build_module}_depends" GLOBAL
2467 PROPERTY "_vtk_module_${_vtk_build_module}_depends")
2468 get_property("_vtk_build_${_vtk_build_module}_private_depends" GLOBAL
2469 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends")
2470 get_property("_vtk_build_${_vtk_build_module}_optional_depends" GLOBAL
2471 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
2472 get_property("_vtk_build_${_vtk_build_module}_order_depends" GLOBAL
2473 PROPERTY "_vtk_module_${_vtk_build_module}_order_depends")
2474 set("_vtk_build_${_vtk_build_module}_all_depends"
2475 ${_vtk_build_${_vtk_build_module}_depends}
2476 ${_vtk_build_${_vtk_build_module}_private_depends}
2477 ${_vtk_build_${_vtk_build_module}_optional_depends}
2478 ${_vtk_build_${_vtk_build_module}_order_depends})
2481 set(_vtk_build_sorted_modules "${_vtk_build_MODULES}")
2482 vtk_topological_sort(_vtk_build_sorted_modules "_vtk_build_" "_all_depends")
2484 foreach (_vtk_build_module IN LISTS _vtk_build_sorted_modules)
2485 if (NOT _vtk_build_module IN_LIST _vtk_build_MODULES)
2489 if (TARGET "${_vtk_build_module}")
2490 get_property(_vtk_build_is_imported
2491 TARGET "${_vtk_build_module}"
2494 # TODO: Is this right?
2495 if (NOT _vtk_build_is_imported)
2497 "The ${_vtk_build_module} module has been requested to be built, but "
2498 "it is already built by this project.")
2504 foreach (_vtk_build_depend IN LISTS "_vtk_build_${_vtk_build_module}_depends" "_vtk_build_${_vtk_build_module}_private_depends")
2505 if (NOT TARGET "${_vtk_build_depend}")
2506 get_property(_vtk_build_enable_tests_by_want GLOBAL
2507 PROPERTY "_vtk_module_${_vtk_build_module}_enable_tests_by_want")
2509 set(_vtk_build_explain "")
2510 if (_vtk_build_enable_tests_by_want)
2511 string(APPEND _vtk_build_explain
2512 " The `vtk_module_scan` for this module used `ENABLE_TESTS WANT`. "
2513 "This is a known issue, but the fix is not trivial. You may "
2514 "either change the flag used to control testing for this scan or "
2515 "explicitly enable the ${_vtk_build_depend} module.")
2519 "The ${_vtk_build_depend} dependency is missing for "
2520 "${_vtk_build_module}.${_vtk_build_explain}")
2524 get_property(_vtk_build_module_file GLOBAL
2525 PROPERTY "_vtk_module_${_vtk_build_module}_file")
2526 if (NOT _vtk_build_module_file)
2528 "The requested ${_vtk_build_module} module is not a VTK module.")
2531 _vtk_module_debug(building "@_vtk_build_module@ is being built")
2533 get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}" DIRECTORY)
2534 file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}" "${_vtk_build_module_dir}")
2536 "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}"
2537 "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}")
2539 if (NOT TARGET "${_vtk_build_module}")
2541 "The ${_vtk_build_module} is being built, but a matching target was "
2546 if (_vtk_build_BUILD_WITH_KITS)
2547 foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2548 get_property(_vtk_build_target_name GLOBAL
2549 PROPERTY "_vtk_kit_${_vtk_build_kit}_target_name")
2550 set(_vtk_kit_source_file
2551 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/vtk_module_kit_${_vtk_build_target_name}.c")
2553 OUTPUT "${_vtk_kit_source_file}"
2554 CONTENT "void vtk_module_kit_${_vtk_build_target_name}() {}\n")
2555 add_library("${_vtk_build_target_name}"
2556 "${_vtk_kit_source_file}")
2557 get_property(_vtk_build_namespace GLOBAL
2558 PROPERTY "_vtk_kit_${_vtk_build_kit}_namespace")
2559 if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>")
2560 set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}")
2562 if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2564 "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the "
2565 "same as the ${_vtk_build_kit} kit namespace "
2566 "(${_vtk_build_namespace}).")
2568 if (NOT _vtk_build_kit STREQUAL _vtk_build_target_name)
2569 add_library("${_vtk_build_kit}" ALIAS
2570 "${_vtk_build_target_name}")
2572 _vtk_module_apply_properties("${_vtk_build_target_name}")
2573 _vtk_module_install("${_vtk_build_target_name}")
2575 set(_vtk_build_kit_modules_object_libraries)
2576 set(_vtk_build_kit_modules_private_depends)
2578 get_property(_vtk_build_kit_modules GLOBAL
2579 PROPERTY "_vtk_kit_${_vtk_build_kit}_kit_modules")
2580 foreach (_vtk_build_kit_module IN LISTS _vtk_build_kit_modules)
2581 get_property(_vtk_build_kit_module_target_name GLOBAL
2582 PROPERTY "_vtk_module_${_vtk_build_kit_module}_target_name")
2583 list(APPEND _vtk_build_kit_modules_object_libraries
2584 "${_vtk_build_kit_module_target_name}-objects")
2586 _vtk_private_kit_link_target("${_vtk_build_kit_module}"
2587 USAGE_TARGET_NAME _vtk_build_kit_module_usage_name)
2588 if (TARGET "${_vtk_build_kit_module_usage_name}")
2589 list(APPEND _vtk_build_kit_modules_private_depends
2590 "${_vtk_build_kit_module_usage_name}")
2593 # Since there is no link step for modules, we need to copy the private
2594 # dependencies of the constituent modules into the kit so that their
2595 # private dependencies are actually linked.
2596 get_property(_vtk_build_kit_module_private_depends GLOBAL
2597 PROPERTY "_vtk_module_${_vtk_build_kit_module}_private_depends")
2598 # Also grab optional dependencies since they end up being private
2600 get_property(_vtk_build_kit_module_optional_depends GLOBAL
2601 PROPERTY "_vtk_module_${_vtk_build_kit_module}_optional_depends")
2602 foreach (_vtk_build_kit_module_private_depend IN LISTS _vtk_build_kit_module_private_depends _vtk_build_kit_module_optional_depends)
2603 if (NOT TARGET "${_vtk_build_kit_module_private_depend}")
2607 # But we don't need to link to modules that are part of the kit we are
2609 if (NOT _vtk_build_kit_module_private_depend IN_LIST _vtk_build_kit_modules)
2610 list(APPEND _vtk_build_kit_modules_private_depends
2611 "$<LINK_ONLY:${_vtk_build_kit_module_private_depend}>")
2616 if (_vtk_build_kit_modules_private_depends)
2617 list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_depends)
2619 if (_vtk_build_kit_modules_private_links)
2620 list(REMOVE_DUPLICATES _vtk_build_kit_modules_private_links)
2623 target_link_libraries("${_vtk_build_target_name}
"
2625 ${_vtk_build_kit_modules_object_libraries}
2626 ${_vtk_build_kit_modules_private_depends})
2628 if (_vtk_build_UTILITY_TARGET)
2629 target_link_libraries("${_vtk_build_target_name}
"
2631 "${_vtk_build_UTILITY_TARGET}
")
2634 get_property(_vtk_build_kit_library_name GLOBAL
2635 PROPERTY "_vtk_kit_${_vtk_build_kit}_library_name
")
2636 if (_vtk_build_LIBRARY_NAME_SUFFIX)
2637 string(APPEND _vtk_build_kit_library_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}
")
2639 set_target_properties("${_vtk_build_target_name}
"
2641 OUTPUT_NAME "${_vtk_build_kit_library_name}
")
2645 set(_vtk_build_properties_filename "${_vtk_build_PACKAGE}-
vtk-module-properties.cmake
")
2646 set(_vtk_build_properties_install_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_build_properties_filename}.install
")
2647 set(_vtk_build_properties_build_file "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_properties_filename}
")
2649 file(WRITE "${_vtk_build_properties_build_file}
")
2651 _vtk_module_write_import_prefix(
2652 "${_vtk_build_properties_install_file}
"
2653 "${_vtk_build_CMAKE_DESTINATION}
")
2655 foreach (_vtk_build_module IN LISTS _vtk_build_MODULES)
2656 get_property(_vtk_build_namespace GLOBAL
2657 PROPERTY "_vtk_module_${_vtk_build_module}_namespace
")
2658 if (_vtk_build_TARGET_NAMESPACE STREQUAL "<AUTO>
")
2659 set(_vtk_build_TARGET_NAMESPACE "${_vtk_build_namespace}
")
2661 if (NOT _vtk_build_namespace STREQUAL _vtk_build_TARGET_NAMESPACE)
2663 "The `TARGET_NAMESPACE` (${_vtk_build_TARGET_NAMESPACE}) is not the
"
2664 "same as the ${_vtk_build_module} module
namespace "
2665 "(${_vtk_build_namespace}).
")
2668 get_property(_vtk_build_is_third_party
2669 TARGET "${_vtk_build_module}
"
2670 PROPERTY "INTERFACE_vtk_module_third_party
")
2671 if (_vtk_build_is_third_party)
2672 _vtk_module_export_properties(
2673 BUILD_FILE "${_vtk_build_properties_build_file}
"
2674 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2675 MODULE "${_vtk_build_module}
"
2676 FROM_GLOBAL_PROPERTIES
2677 # Export the dependencies of a module.
2681 # The library name of the module.
2684 # Export whether a module is third party or not.
2685 INTERFACE_vtk_module_third_party
2686 INTERFACE_vtk_module_exclude_wrap)
2690 set(_vtk_build_split_properties)
2691 get_property(_vtk_build_exclude_wrap
2692 TARGET "${_vtk_build_module}
"
2693 PROPERTY "INTERFACE_vtk_module_${_vtk_build_module}_exclude_wrap
")
2694 if (NOT _vtk_build_exclude_wrap)
2695 list(APPEND _vtk_build_split_properties
2697 if (_vtk_build_ENABLE_WRAPPING)
2698 list(APPEND _vtk_build_split_properties
2703 set(_vtk_build_properties_kit_properties)
2704 if (_vtk_build_BUILD_WITH_KITS)
2705 list(APPEND _vtk_build_properties_kit_properties
2706 # Export the kit membership of a module.
2710 _vtk_module_export_properties(
2711 BUILD_FILE "${_vtk_build_properties_build_file}
"
2712 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2713 MODULE "${_vtk_build_module}
"
2714 FROM_GLOBAL_PROPERTIES
2715 # Export whether the module should be excluded from wrapping or not.
2717 # Export the dependencies of a module.
2721 # Export what modules are implemented by the module.
2723 # Export whether the module contains autoinit logic.
2725 # The library name of the module.
2727 ${_vtk_build_properties_kit_properties}
2729 # Export whether the module needs autoinit logic handled.
2730 INTERFACE_vtk_module_needs_autoinit
2731 # Forward private usage requirements with global effects.
2732 INTERFACE_vtk_module_forward_link
2733 SPLIT_INSTALL_PROPERTIES
2734 # Set the properties which differ between build and install trees.
2735 ${_vtk_build_split_properties})
2738 if (_vtk_build_BUILD_WITH_KITS)
2739 foreach (_vtk_build_kit IN LISTS _vtk_build_KITS)
2740 _vtk_module_export_properties(
2741 BUILD_FILE "${_vtk_build_properties_build_file}
"
2742 INSTALL_FILE "${_vtk_build_properties_install_file}
"
2743 KIT "${_vtk_build_kit}
"
2744 FROM_GLOBAL_PROPERTIES
2745 # Export the list of modules in the kit.
2750 if (_vtk_build_INSTALL_EXPORT AND _vtk_build_INSTALL_HEADERS)
2751 set(_vtk_build_namespace)
2752 if (_vtk_build_TARGET_NAMESPACE)
2753 set(_vtk_build_namespace
2754 NAMESPACE "${_vtk_build_TARGET_NAMESPACE}::
")
2758 EXPORT "${_vtk_build_INSTALL_EXPORT}
"
2759 ${_vtk_build_namespace}
2760 FILE "${CMAKE_BINARY_DIR}/${_vtk_build_CMAKE_DESTINATION}/${_vtk_build_PACKAGE}-targets.cmake
")
2762 EXPORT "${_vtk_build_INSTALL_EXPORT}
"
2763 DESTINATION "${_vtk_build_CMAKE_DESTINATION}
"
2764 ${_vtk_build_namespace}
2765 FILE "${_vtk_build_PACKAGE}-targets.cmake
"
2766 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
2768 if (_vtk_build_INSTALL_HEADERS)
2769 file(APPEND "${_vtk_build_properties_install_file}
"
2770 "unset(_vtk_module_import_prefix)\n
")
2773 FILES "${_vtk_build_properties_install_file}
"
2774 DESTINATION "${_vtk_build_CMAKE_DESTINATION}
"
2775 RENAME "${_vtk_build_properties_filename}
"
2776 COMPONENT "${_vtk_build_HEADERS_COMPONENT}
")
2780 get_property(_vtk_build_test_modules GLOBAL
2781 PROPERTY "_vtk_module_test_modules
")
2782 set(_vtk_build_tests_handled)
2783 foreach (_vtk_build_test IN LISTS _vtk_build_test_modules)
2784 if (NOT _vtk_build_test IN_LIST _vtk_build_MODULES)
2787 list(APPEND _vtk_build_tests_handled
2788 "${_vtk_build_test}
")
2790 get_property(_vtk_build_test_depends GLOBAL
2791 PROPERTY "_vtk_module_${_vtk_build_test}_test_depends
")
2793 set(_vtk_build_test_has_depends TRUE)
2794 foreach (_vtk_build_test_depend IN LISTS _vtk_build_test_depends)
2795 if (NOT TARGET "${_vtk_build_test_depend}
")
2796 set(_vtk_build_test_has_depends FALSE)
2797 _vtk_module_debug(testing "@_vtk_build_test@ testing disabled due to missing @_vtk_build_test_depend
@")
2800 if (NOT _vtk_build_test_has_depends)
2804 get_property(_vtk_build_module_file GLOBAL
2805 PROPERTY "_vtk_module_${_vtk_build_test}_file
")
2807 if (NOT _vtk_build_TEST_DIRECTORY_NAME STREQUAL "NONE
")
2808 get_filename_component(_vtk_build_module_dir "${_vtk_build_module_file}
" DIRECTORY)
2809 file(RELATIVE_PATH _vtk_build_module_subdir "${CMAKE_SOURCE_DIR}
" "${_vtk_build_module_dir}
")
2810 if (EXISTS "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
")
2811 get_property(_vtk_build_test_labels GLOBAL
2812 PROPERTY "_vtk_module_${_vtk_build_test}_test_labels
")
2814 "${CMAKE_SOURCE_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
"
2815 "${CMAKE_BINARY_DIR}/${_vtk_build_module_subdir}/${_vtk_build_TEST_DIRECTORY_NAME}
")
2820 if (_vtk_build_test_modules AND _vtk_build_tests_handled)
2821 list(REMOVE_ITEM _vtk_build_test_modules
2822 ${_vtk_build_tests_handled})
2825 _vtk_module_test_modules "${_vtk_build_test_modules}
")
2831@brief Add "standard
" include directories to a module
2833Add the "standard
" includes for a module to its interface. These are the source
2834and build directories for the module itself. They are always either `PUBLIC` or
2835`INTERFACE` (depending on the module's target type).
2838_vtk_module_standard_includes(
2842 [HEADERS_DESTINATION <destination>])
2845function (_vtk_module_standard_includes)
2846 cmake_parse_arguments(PARSE_ARGV 0 _vtk_standard_includes
2848 "TARGET;HEADERS_DESTINATION
"
2851 if (NOT _vtk_standard_includes_TARGET)
2853 "The `TARGET` argument is required.
")
2855 if (NOT TARGET "${_vtk_standard_includes_TARGET}
")
2857 "The `TARGET` argument is not a
target.
")
2860 if (_vtk_standard_includes_UNPARSED_ARGUMENTS)
2862 "Unparsed arguments
for vtk_module_standard_includes:
"
2863 "${_vtk_standard_includes_UNPARSED_ARGUMENTS}
")
2866 set(_vtk_standard_includes_system)
2867 if (_vtk_standard_includes_SYSTEM)
2868 set(_vtk_standard_includes_system SYSTEM)
2871 set(_vtk_standard_includes_visibility PUBLIC)
2872 if (_vtk_standard_includes_INTERFACE)
2873 set(_vtk_standard_includes_visibility INTERFACE)
2876 target_include_directories("${_vtk_standard_includes_TARGET}
"
2877 ${_vtk_standard_includes_system}
2878 "${_vtk_standard_includes_visibility}
"
2879 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
2880 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
2882 if (_vtk_build_INSTALL_HEADERS AND _vtk_standard_includes_HEADERS_DESTINATION)
2883 target_include_directories("${_vtk_standard_includes_TARGET}
"
2884 ${_vtk_standard_includes_system}
2885 "${_vtk_standard_includes_visibility}
"
2886 $<INSTALL_INTERFACE:${_vtk_standard_includes_HEADERS_DESTINATION}>)
2892@brief Determine the default export macro for a module
2894Determines the export macro to be used for a module from its metadata. Assumes
2895it is called from within a @ref vtk_module_build call.
2898_vtk_module_default_library_name(<varname>)
2901function (_vtk_module_default_export_macro_prefix varname)
2902 get_property(_vtk_module_default_library_name GLOBAL
2903 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
2904 string(TOUPPER "${_vtk_module_default_library_name}
" _vtk_default_export_macro_upper)
2906 "${_vtk_default_export_macro_upper}
"
2910# TODO: It would be nice to support `USE_LINK_PROPERTIES` instead of listing
2911# the modules again here. However, the format of the `LINK_LIBRARIES` property
2912# value may not be easy to handle.
2915@page module-overview
2918@section module-autoinit Autoinit
2920When a module contains a factory which may be populated by other modules, these
2921factories need to be populated when the modules are loaded by the dynamic linker
2922(for shared builds) or program load time (for static builds). To provide for
2923this, the module system contains an autoinit "subsystem
".
2925@subsection module-autoinit-leverage Leveraging the autoinit subsystem
2927The subsystem provides the following hooks for use by projects:
2929 * In modules which `IMPLEMENTS` other modules, in the generated
2930 `<module>Module.h` header (which provides export symbols as well) will
2931 include the modules which are implemented.
2932 * In modules which are `IMPLEMENTABLE` or `IMPLEMENTS` another module, the
2933 generated `<module>Module.h` file will include the following block:
2936#ifdef <module>_AUTOINIT_INCLUDE
2937#include <module>_AUTOINIT_INCLUDE
2939#ifdef <module>_AUTOINIT
2941VTK_MODULE_AUTOINIT(<module>)
2945The @ref vtk_module_autoinit function will generate an include file and provide
2946its path via the `<module>_AUTOINIT_INCLUDE` define. once it has been included,
2947if the `<module>_AUTOINIT` symbol is defined, a header is included which is
2948intended to provide the `VTK_MODULE_AUTOINIT` macro. This macro is given the
2949module name and should use `<module>_AUTOINIT` to fill in the factories in the
2950module with those from the `IMPLEMENTS` modules listed in that symbol.
2952The `<module>_AUTOINIT` symbol's value is:
2955<count>(<module1>,<module2>,<module3>)
2958where `<count>` is the number of modules in the parentheses and each module
2959listed need to register something to `<module>`.
2961If not provided via the `AUTOINIT_INCLUDE` argument to the
2962@ref vtk_module_add_module function, the header to use is fetched from the
2963`_vtk_module_autoinit_include` global property. This only needs to be managed
2964in modules that `IMPLEMENTS` or are `IMPLEMENTABLE`. This should be provided by
2965projects using the module system at its lowest level. Projects not implementing
2966the `VTK_MODULE_AUTOINIT` macro should have its value provided by
2967`find_package` dependencies in some way.
2972@brief Linking to autoinit-using modules
2974When linking to modules, in order for the autoinit system to work, modules need
2975to declare their registration. In order to do this, defines may need to be
2976provided to targets in order to trigger registration. These defines may be
2977added to targets by using this function.
2982 MODULES <module>...)
2985After this call, the targets given to the `TARGETS` argument will gain the
2986preprocessor definitions to trigger registrations properly.
2988function (vtk_module_autoinit)
2989 cmake_parse_arguments(PARSE_ARGV 0 _vtk_autoinit
2994 if (_vtk_autoinit_UNRECOGNIZED_ARGUMENTS)
2997 "${_vtk_autoinit_UNRECOGNIZED_ARGUMENTS}.
")
3000 if (NOT _vtk_autoinit_TARGETS)
3002 "The `TARGETS` argument is required.
")
3005 if (NOT _vtk_autoinit_MODULES)
3006 message(AUTHOR_WARNING
3007 "No `MODULES` passed to `vtk_modules_autoinit`.
")
3010 set(_vtk_autoinit_module_stack
3011 ${_vtk_autoinit_MODULES})
3013 set(_vtk_autoinit_needs_implements)
3014 set(_vtk_autoinit_seen)
3015 while (_vtk_autoinit_module_stack)
3016 list(GET _vtk_autoinit_module_stack 0 _vtk_autoinit_current_module)
3017 list(REMOVE_AT _vtk_autoinit_module_stack 0)
3018 if (_vtk_autoinit_current_module IN_LIST _vtk_autoinit_seen)
3021 list(APPEND _vtk_autoinit_seen
3022 "${_vtk_autoinit_current_module}
")
3024 _vtk_module_real_target(_vtk_autoinit_current_target "${_vtk_autoinit_current_module}
")
3025 get_property(_vtk_autoinit_implements
3026 TARGET "${_vtk_autoinit_current_target}
"
3027 PROPERTY "INTERFACE_vtk_module_implements
")
3029 list(APPEND _vtk_autoinit_needs_implements
3030 ${_vtk_autoinit_implements})
3031 foreach (_vtk_autoinit_implement IN LISTS _vtk_autoinit_implements)
3032 _vtk_module_real_target(_vtk_autoinit_implements_target "${_vtk_autoinit_implement}
")
3033 get_property(_vtk_autoinit_implementable
3034 TARGET "${_vtk_autoinit_implements_target}
"
3035 PROPERTY "INTERFACE_vtk_module_implementable
")
3037 if (NOT _vtk_autoinit_implementable)
3039 "The `${_vtk_autoinit_current_module}` module says that it
"
3040 "implements the `${_vtk_autoinit_implement}` module, but it is not
"
3044 list(APPEND "_vtk_autoinit_implements_${_vtk_autoinit_implement}
"
3045 "${_vtk_autoinit_current_module}
")
3049 if (NOT _vtk_autoinit_needs_implements)
3052 list(REMOVE_DUPLICATES _vtk_autoinit_needs_implements)
3053 list(SORT _vtk_autoinit_needs_implements)
3055 set(_vtk_autoinit_hash_content)
3056 foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
3057 if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
3060 list(SORT "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
")
3062 string(APPEND _vtk_autoinit_hash_content
3063 "${_vtk_autoinit_need_implements}: ${_vtk_autoinit_implements_${_vtk_autoinit_need_implements}}\n
")
3065 string(MD5 _vtk_autoinit_header_tag "${_vtk_autoinit_hash_content}
")
3066 set(_vtk_autoinit_header
3067 "${CMAKE_BINARY_DIR}/CMakeFiles/vtkModuleAutoInit_${_vtk_autoinit_header_tag}.h
")
3069 get_property(_vtk_autoinit_header_generated GLOBAL
3070 PROPERTY "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}
")
3072 set(_vtk_autoinit_defines)
3073 set(_vtk_autoinit_header_content)
3074 foreach (_vtk_autoinit_need_implements IN LISTS _vtk_autoinit_needs_implements)
3075 if (NOT _vtk_autoinit_implements_${_vtk_autoinit_need_implements})
3079 get_property(_vtk_autoinit_implements_library_name
3080 TARGET "${_vtk_autoinit_need_implements}
"
3081 PROPERTY "INTERFACE_vtk_module_library_name
")
3083 if (NOT _vtk_autoinit_header_generated)
3084 list(LENGTH "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
"
3085 _vtk_autoinit_length)
3086 set(_vtk_autoinit_args)
3087 foreach (_vtk_autoinit_arg IN LISTS "_vtk_autoinit_implements_${_vtk_autoinit_need_implements}
")
3088 get_property(_vtk_autoinit_arg_library_name
3089 TARGET "${_vtk_autoinit_arg}
"
3090 PROPERTY "INTERFACE_vtk_module_library_name
")
3091 list(APPEND _vtk_autoinit_args
3092 "${_vtk_autoinit_arg_library_name}
")
3094 string(REPLACE ";
" ",
" _vtk_autoinit_args "${_vtk_autoinit_args}
")
3095 string(APPEND _vtk_autoinit_header_content
3096 "#define ${_vtk_autoinit_implements_library_name}_AUTOINIT ${_vtk_autoinit_length}(${_vtk_autoinit_args})\n
")
3099 list(APPEND _vtk_autoinit_defines
3100 "${_vtk_autoinit_implements_library_name}_AUTOINIT_INCLUDE=\
"${_vtk_autoinit_header}\"")
3103 if (NOT _vtk_autoinit_header_generated)
3105 OUTPUT "${_vtk_autoinit_header}
"
3106 CONTENT "${_vtk_autoinit_header_content}
")
3110 "_vtk_autoinit_generated_${_vtk_autoinit_header_tag}
" TRUE)
3113 foreach (_vtk_autoinit_target IN LISTS _vtk_autoinit_TARGETS)
3114 get_property(_vtk_autoinit_target_type
3115 TARGET "${_vtk_autoinit_target}
"
3117 if (_vtk_autoinit_target_type STREQUAL "INTERFACE_LIBRARY
")
3121 target_compile_definitions("${_vtk_autoinit_target}
"
3123 ${_vtk_autoinit_defines})
3129@brief Generate the hierarchy for a module
3131Write wrap hierarchy files for the module currently being built. This also
3132installs the hierarchy file for use by dependent projects if `INSTALL_HEADERS`
3136_vtk_module_write_wrap_hierarchy()
3139function (_vtk_module_write_wrap_hierarchy)
3140 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}
")
3142 get_property(_vtk_hierarchy_library_name GLOBAL
3143 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
3144 set(_vtk_hierarchy_filename "${_vtk_hierarchy_library_name}-hierarchy.txt
")
3145 set(_vtk_hierarchy_file "${CMAKE_BINARY_DIR}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}
")
3146 set(_vtk_hierarchy_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.$<CONFIGURATION>.args
")
3147 set(_vtk_hierarchy_data_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.data
")
3148 set(_vtk_hierarchy_depends_args_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_hierarchy_library_name}-hierarchy.depends.args
")
3150 set_property(TARGET "${_vtk_add_module_real_target}
"
3152 "INTERFACE_vtk_module_hierarchy
" "${_vtk_hierarchy_file}
")
3154 set(_vtk_add_module_target_name_iface "${_vtk_add_module_target_name}
")
3155 if (_vtk_add_module_build_with_kit)
3156 string(APPEND _vtk_add_module_target_name_iface "-objects
")
3158 set(_vtk_hierarchy_genex_compile_definitions
3159 "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},COMPILE_DEFINITIONS>
")
3160 set(_vtk_hierarchy_genex_include_directories
3161 "$<TARGET_PROPERTY:${_vtk_add_module_target_name_iface},INCLUDE_DIRECTORIES>
")
3163 OUTPUT "${_vtk_hierarchy_args_file}
"
3164 CONTENT "$<$<BOOL:${_vtk_hierarchy_genex_compile_definitions}>:\n-D\
'$<JOIN:${_vtk_hierarchy_genex_compile_definitions},\'\n-D\'>\'>\n
3165$<$<BOOL:${_vtk_hierarchy_genex_include_directories}>:\n-I\'$<JOIN:${_vtk_hierarchy_genex_include_directories},\'\n-I\'>\'>\n")
3167 get_property(_vtk_hierarchy_depends_is_global GLOBAL
3168 PROPERTY "_vtk_module_${_vtk_build_module}_depends"
3170 if (_vtk_hierarchy_depends_is_global)
3171 get_property(_vtk_hierarchy_depends GLOBAL
3172 PROPERTY "_vtk_module_${_vtk_build_module}_depends")
3174 get_property(_vtk_hierarchy_depends GLOBAL
3175 TARGET "${_vtk_add_module_real_target}"
3176 PROPERTY "INTERFACE_vtk_module_depends")
3179 set(_vtk_hierarchy_depends_files)
3180 set(_vtk_hierarchy_depends_targets)
3181 foreach (_vtk_hierarchy_depend IN LISTS _vtk_hierarchy_depends)
3182 _vtk_module_get_module_property("${_vtk_hierarchy_depend}"
3183 PROPERTY "hierarchy"
3184 VARIABLE _vtk_hierarchy_depend_hierarchy)
3185 if (NOT DEFINED _vtk_hierarchy_depend_hierarchy)
3189 list(APPEND _vtk_hierarchy_depends_files
3190 "${_vtk_hierarchy_depend_hierarchy}")
3192 # Find the hierarchy target of the module.
3193 get_property(_vtk_hierarchy_module_is_imported
3194 TARGET "${_vtk_hierarchy_depend}"
3196 # Imported target modules are external and should already have their file
3198 if (_vtk_hierarchy_module_is_imported)
3202 get_property(_vtk_hierarchy_depend_library_name GLOBAL
3203 PROPERTY "_vtk_module_${_vtk_hierarchy_depend}_library_name")
3204 if (TARGET "${_vtk_hierarchy_depend_library_name}-hierarchy")
3205 list(APPEND _vtk_hierarchy_depends_targets
3206 "${_vtk_hierarchy_depend_library_name}-hierarchy")
3210 set(_vtk_hierarchy_depends_files_arg)
3211 if (_vtk_hierarchy_depends_files)
3213 OUTPUT "${_vtk_hierarchy_depends_args_file}"
3214 CONTENT "\"$<JOIN:${_vtk_hierarchy_depends_files},\"\n\">\"\n")
3217 OUTPUT "${_vtk_hierarchy_depends_args_file}"
3221 _vtk_module_get_module_property("${_vtk_build_module}"
3223 VARIABLE _vtk_hierarchy_headers)
3224 set(_vtk_hierarchy_data_content "")
3225 foreach (_vtk_hierarchy_header IN LISTS _vtk_hierarchy_headers)
3226 string(APPEND _vtk_hierarchy_data_content
3227 "${_vtk_hierarchy_header};${_vtk_hierarchy_library_name}\n")
3230 OUTPUT "${_vtk_hierarchy_data_file}"
3231 CONTENT "${_vtk_hierarchy_data_content}")
3233 if (CMAKE_GENERATOR MATCHES "Ninja")
3234 set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_files})
3236 set(_vtk_hierarchy_command_depends ${_vtk_hierarchy_depends_targets})
3239 set(_vtk_hierarchy_tool_target "VTK::WrapHierarchy")
3240 set(_vtk_hierarchy_macros_args)
3241 if (TARGET VTKCompileTools::WrapHierarchy)
3242 set(_vtk_hierarchy_tool_target "VTKCompileTools::WrapHierarchy")
3243 if (TARGET VTKCompileTools_macros)
3244 list(APPEND _vtk_hierarchy_command_depends
3245 "VTKCompileTools_macros")
3246 list(APPEND _vtk_hierarchy_macros_args
3248 -imacros "${_VTKCompileTools_macros_file}")
3253 OUTPUT "${_vtk_hierarchy_file}"
3254 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
3255 "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>"
3256 "@${_vtk_hierarchy_args_file}"
3257 -o "${_vtk_hierarchy_file}"
3258 "${_vtk_hierarchy_data_file}"
3259 "@${_vtk_hierarchy_depends_args_file}"
3260 ${_vtk_hierarchy_macros_args}
3261 COMMENT "Generating the wrap hierarchy for ${_vtk_build_module}"
3263 ${_vtk_hierarchy_headers}
3264 "${_vtk_hierarchy_args_file}"
3265 "${_vtk_hierarchy_data_file}"
3266 "${_vtk_hierarchy_depends_args_file}"
3267 ${_vtk_hierarchy_command_depends})
3268 add_custom_target("${_vtk_add_module_library_name}-hierarchy" ALL
3270 "${_vtk_hierarchy_file}"
3271 "$<TARGET_FILE:${_vtk_hierarchy_tool_target}>")
3272 set_property(TARGET "${_vtk_add_module_real_target}"
3274 "INTERFACE_vtk_module_hierarchy" "${_vtk_hierarchy_file}")
3276 if (_vtk_build_INSTALL_HEADERS)
3277 set(_vtk_hierarchy_headers_component "${_vtk_build_HEADERS_COMPONENT}")
3278 if (_vtk_build_TARGET_SPECIFIC_COMPONENTS)
3279 string(PREPEND _vtk_hierarchy_headers_component "${_vtk_build_module}-")
3280 if (_vtk_build_BUILD_WITH_KITS)
3281 get_property(_vtk_hierarchy_build_with_kit GLOBAL
3282 PROPERTY "_vtk_module_${_vtk_build_module}_kit")
3283 if (_vtk_hierarchy_build_with_kit)
3284 set(_vtk_hierarchy_headers_component "${_vtk_hierarchy_build_with_kit}-${_vtk_build_HEADERS_COMPONENT}")
3288 set_property(TARGET "${_vtk_add_module_real_target}"
3290 "INTERFACE_vtk_module_hierarchy_install" "\${_vtk_module_import_prefix}/${_vtk_build_HIERARCHY_DESTINATION}/${_vtk_hierarchy_filename}")
3292 FILES "${_vtk_hierarchy_file}"
3293 DESTINATION "${_vtk_build_HIERARCHY_DESTINATION}"
3294 RENAME "${_vtk_hierarchy_filename}"
3295 COMPONENT "${_vtk_hierarchy_headers_component}")
3299include(GenerateExportHeader)
3303@brief Create a module library
3306vtk_module_add_module(<name>
3307 [FORCE_STATIC] [HEADER_ONLY] [HEADER_DIRECTORIES]
3308 [EXPORT_MACRO_PREFIX <prefix>]
3309 [HEADERS_SUBDIR <subdir>]
3310 [LIBRARY_NAME_SUFFIX <suffix>]
3311 [CLASSES <class>...]
3312 [TEMPLATE_CLASSES <template class>...]
3313 [NOWRAP_CLASSES <nowrap class>...]
3314 [SOURCES <source>...]
3315 [HEADERS <header>...]
3316 [NOWRAP_HEADERS <header>...]
3317 [TEMPLATES <template>...]
3318 [PRIVATE_CLASSES <class>...]
3319 [PRIVATE_TEMPLATE_CLASSES <template class>...]
3320 [PRIVATE_HEADERS <header>...]
3321 [PRIVATE_TEMPLATES <template>...])
3324The `PRIVATE_` arguments are analogous to their non-`PRIVATE_` arguments, but
3325the associated files are not installed or available for wrapping (`SOURCES` are
3326always private, so there is no `PRIVATE_` variant for that argument).
3328 * `FORCE_STATIC`: For a static library to be created. If not provided,
3329 `BUILD_SHARED_LIBS` will control the library type.
3330 * `HEADER_ONLY`: The module only contains headers (or templates) and contains
3331 no compilation steps. Mutually exclusive with `FORCE_STATIC`.
3332 * `HEADER_DIRECTORIES`: The headers for this module are in a directory
3333 structure which should be preserved in the install tree.
3334 * `EXPORT_MACRO_PREFIX`: The prefix for the export macro definitions.
3335 Defaults to the library name of the module in all uppercase.
3336 * `HEADERS_SUBDIR`: The subdirectory to install headers into in the install
3338 * `LIBRARY_NAME_SUFFIX`: The suffix to the module's library
name if
3339 additional information is required.
3340 * `CLASSES`: A list of classes in the module. This is a shortcut
for adding
3341 `<
class>.cxx` to `SOURCES` and `<
class>.h` to `HEADERS`.
3342 * `TEMPLATE_CLASSES`: A list of
template classes in the module. This is a
3343 shortcut
for adding `<
class>.txx` to `TEMPLATES` and `<
class>.h` to
3345 * `SOURCES`: A list of
source files which require compilation.
3346 * `HEADERS`: A list of header files which will be available
for wrapping and
3348 * `NOWRAP_CLASSES`: A list of classes which will not be available
for
3349 wrapping but installed. This is a shortcut
for adding `<
class>.cxx` to
3350 `SOURCES` and `<
class>.h` to `NOWRAP_HEADERS`.
3351 * `NOWRAP_HEADERS`: A list of header files which will not be available
for
3352 wrapping but installed.
3353 * `TEMPLATES`: A list of
template files which will be installed.
3356 if (NOT name STREQUAL _vtk_build_module)
3358 "The ${_vtk_build_module}'s CMakeLists.txt may not add the ${name} module.")
3361 set(_vtk_add_module_source_keywords)
3362 foreach (_vtk_add_module_kind IN ITEMS CLASSES TEMPLATE_CLASSES HEADERS TEMPLATES)
3363 list(APPEND _vtk_add_module_source_keywords
3364 "${_vtk_add_module_kind}
"
3365 "PRIVATE_${_vtk_add_module_kind}
")
3368 cmake_parse_arguments(PARSE_ARGV 1 _vtk_add_module
3369 "FORCE_STATIC;HEADER_ONLY;HEADER_DIRECTORIES
"
3370 "EXPORT_MACRO_PREFIX;HEADERS_SUBDIR;LIBRARY_NAME_SUFFIX
"
3371 "${_vtk_add_module_source_keywords};SOURCES;NOWRAP_CLASSES;NOWRAP_HEADERS
")
3373 if (_vtk_add_module_UNPARSED_ARGUMENTS)
3376 "${_vtk_add_module_UNPARSED_ARGUMENTS}
")
3379 if (NOT DEFINED _vtk_add_module_EXPORT_MACRO_PREFIX)
3380 _vtk_module_default_export_macro_prefix(_vtk_add_module_EXPORT_MACRO_PREFIX)
3383 if (_vtk_add_module_HEADER_ONLY AND _vtk_add_module_FORCE_STATIC)
3385 "The ${_vtk_build_module} module cannot be header only yet forced
"
3389 foreach (_vtk_add_module_class IN LISTS _vtk_add_module_CLASSES)
3390 list(APPEND _vtk_add_module_SOURCES
3391 "${_vtk_add_module_class}.cxx
")
3392 list(APPEND _vtk_add_module_HEADERS
3393 "${_vtk_add_module_class}.h
")
3396 foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_TEMPLATE_CLASSES)
3397 list(APPEND _vtk_add_module_TEMPLATES
3398 "${_vtk_add_module_template_class}.txx
")
3399 list(APPEND _vtk_add_module_HEADERS
3400 "${_vtk_add_module_template_class}.h
")
3403 foreach (_vtk_add_module_class IN LISTS _vtk_add_module_NOWRAP_CLASSES)
3404 list(APPEND _vtk_add_module_SOURCES
3405 "${_vtk_add_module_class}.cxx
")
3406 list(APPEND _vtk_add_module_NOWRAP_HEADERS
3407 "${_vtk_add_module_class}.h
")
3410 foreach (_vtk_add_module_class IN LISTS _vtk_add_module_PRIVATE_CLASSES)
3411 list(APPEND _vtk_add_module_SOURCES
3412 "${_vtk_add_module_class}.cxx
")
3413 list(APPEND _vtk_add_module_PRIVATE_HEADERS
3414 "${_vtk_add_module_class}.h
")
3417 foreach (_vtk_add_module_template_class IN LISTS _vtk_add_module_PRIVATE_TEMPLATE_CLASSES)
3418 list(APPEND _vtk_add_module_PRIVATE_TEMPLATES
3419 "${_vtk_add_module_template_class}.txx
")
3420 list(APPEND _vtk_add_module_PRIVATE_HEADERS
3421 "${_vtk_add_module_template_class}.h
")
3424 if (NOT _vtk_add_module_SOURCES AND NOT _vtk_add_module_HEADER_ONLY)
3426 "The ${_vtk_build_module} module has no
source files.
")
3429 get_property(_vtk_add_module_third_party GLOBAL
3430 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
3432 get_property(_vtk_add_module_library_name GLOBAL
3433 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
3434 set(_vtk_add_module_module_header_name
3435 "${_vtk_add_module_library_name}Module.h
")
3436 if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3437 set(_vtk_add_module_generated_header
3438 "${CMAKE_CURRENT_BINARY_DIR}/${_vtk_add_module_module_header_name}
")
3439 list(APPEND _vtk_add_module_HEADERS
3440 "${_vtk_add_module_generated_header}
")
3443 set(_vtk_add_module_use_relative_paths)
3444 if (_vtk_add_module_HEADER_DIRECTORIES)
3445 set(_vtk_add_module_use_relative_paths
3449 vtk_module_install_headers(
3450 ${_vtk_add_module_use_relative_paths}
3451 FILES ${_vtk_add_module_HEADERS}
3452 ${_vtk_add_module_NOWRAP_HEADERS}
3453 ${_vtk_add_module_TEMPLATES}
3454 SUBDIR "${_vtk_add_module_HEADERS_SUBDIR}
")
3456 set(_vtk_add_module_type)
3457 if (_vtk_add_module_FORCE_STATIC)
3458 set(_vtk_add_module_type STATIC)
3461 set(_vtk_add_module_build_with_kit)
3462 if (_vtk_build_BUILD_WITH_KITS)
3463 get_property(_vtk_add_module_build_with_kit GLOBAL
3464 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
3467 get_property(_vtk_add_module_namespace GLOBAL
3468 PROPERTY "_vtk_module_${_vtk_build_module}_namespace
")
3469 get_property(_vtk_add_module_target_name GLOBAL
3470 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
3471 set(_vtk_add_module_real_target "${_vtk_add_module_target_name}
")
3472 if (_vtk_add_module_HEADER_ONLY)
3473 if (_vtk_add_module_build_with_kit)
3475 "The module ${_vtk_build_module} is header-only, but is part of the
"
3476 "${_vtk_add_module_build_with_kit} kit. Header-only modules
do not
"
3480 add_library("${_vtk_add_module_real_target}
" INTERFACE)
3482 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3483 add_library("${_vtk_build_module}
" ALIAS
3484 "${_vtk_add_module_real_target}
")
3487 if (_vtk_add_module_build_with_kit)
3488 add_library("${_vtk_add_module_real_target}
" INTERFACE)
3489 target_link_libraries("${_vtk_add_module_real_target}
"
3491 # For usage requirements.
3492 "${_vtk_add_module_real_target}-objects
"
3493 # For the implementation.
3494 "$<LINK_ONLY:${_vtk_add_module_build_with_kit}>
")
3496 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3497 add_library("${_vtk_build_module}
" ALIAS
3498 "${_vtk_add_module_real_target}
")
3501 # Set up properties necessary for other infrastructure.
3502 set_property(TARGET "${_vtk_add_module_real_target}
"
3504 "INTERFACE_vtk_module_library_name
" "${_vtk_add_module_library_name}
")
3506 add_library("${_vtk_add_module_real_target}-objects
" OBJECT
3507 ${_vtk_add_module_SOURCES}
3508 ${_vtk_add_module_TEMPLATES}
3509 ${_vtk_add_module_PRIVATE_TEMPLATES}
3510 ${_vtk_add_module_HEADERS}
3511 ${_vtk_add_module_NOWRAP_HEADERS}
3512 ${_vtk_add_module_PRIVATE_HEADERS})
3514 if (_vtk_build_UTILITY_TARGET)
3515 target_link_libraries("${_vtk_add_module_real_target}-objects
"
3517 "${_vtk_build_UTILITY_TARGET}
")
3520 set_target_properties("${_vtk_add_module_real_target}-objects
"
3522 # Emulate the regular library as much as possible.
3523 DEFINE_SYMBOL "${_vtk_add_module_real_target}_EXPORT
"
3524 POSITION_INDEPENDENT_CODE ON)
3525 target_compile_definitions("${_vtk_add_module_real_target}-objects
"
3527 "${_vtk_add_module_real_target}_EXPORT
")
3528 string(APPEND _vtk_add_module_real_target "-objects
")
3530 add_library("${_vtk_add_module_real_target}
" ${_vtk_add_module_type}
3531 ${_vtk_add_module_SOURCES}
3532 ${_vtk_add_module_TEMPLATES}
3533 ${_vtk_add_module_HEADERS}
3534 ${_vtk_add_module_PRIVATE_HEADERS})
3536 if (_vtk_build_UTILITY_TARGET)
3537 target_link_libraries("${_vtk_add_module_real_target}
"
3539 "${_vtk_build_UTILITY_TARGET}
")
3542 set_property(TARGET "${_vtk_add_module_real_target}
"
3544 POSITION_INDEPENDENT_CODE ON)
3546 if (NOT _vtk_build_module STREQUAL _vtk_add_module_real_target)
3547 add_library("${_vtk_build_module}
" ALIAS
3548 "${_vtk_add_module_real_target}
")
3553 set_property(TARGET "${_vtk_add_module_real_target}
"
3555 "INTERFACE_vtk_module_library_name
" "${_vtk_add_module_library_name}
")
3557 get_property(_vtk_add_module_depends GLOBAL
3558 PROPERTY "_vtk_module_${_vtk_build_module}_depends
")
3559 set_property(TARGET "${_vtk_add_module_real_target}
"
3561 "INTERFACE_vtk_module_depends
" "${_vtk_add_module_depends}
")
3562 set(_vtk_add_module_includes_interface)
3563 if (_vtk_add_module_HEADER_ONLY)
3564 target_link_libraries("${_vtk_add_module_real_target}
"
3566 ${_vtk_add_module_depends})
3567 set(_vtk_add_module_includes_interface INTERFACE)
3569 get_property(_vtk_add_module_private_depends GLOBAL
3570 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends
")
3572 # XXX(cmake#18484): Linking dependencies directly currently creates
3573 # circular dependencies. This logic should be removed once the minimum for
3574 # kits contains a fix for the mentioned issue.
3576 # When two modules are part of the same kit, we can get this problem:
3578 # A - iface -> A-objects <- tll - K
3581 # B - iface -> B-objects <- tll -/
3583 # If B depends on A, it ends up with a circular dependency since A has a
3584 # `$<LINK_ONLY:K>` link. instead, munge up dependencies of intra-kit
3585 # dependencies to link to the `-objects` target instead.
3586 if (_vtk_add_module_build_with_kit)
3587 set(_vtk_add_module_depends_link)
3588 set(_vtk_add_module_private_depends_link)
3589 foreach (_vtk_add_module_depend IN LISTS _vtk_add_module_depends)
3590 get_property(_vtk_add_module_depend_kit GLOBAL
3591 PROPERTY "_vtk_module_${_vtk_add_module_depend}_kit
")
3592 if (_vtk_add_module_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3593 # We're in the same kit; depend on the `-objects` library of the
3595 get_property(_vtk_add_module_depend_target_name GLOBAL
3596 PROPERTY "_vtk_module_${_vtk_add_module_depend}_target_name
")
3597 list(APPEND _vtk_add_module_depends_link
3598 "${_vtk_add_module_depend_target_name}-objects
")
3600 # Different kit, just use as normal.
3601 list(APPEND _vtk_add_module_depends_link
3602 "${_vtk_add_module_depend}
")
3605 foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_private_depends)
3606 get_property(_vtk_add_module_private_depend_kit GLOBAL
3607 PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_kit
")
3608 if (_vtk_add_module_private_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3609 # We're in the same kit; depend on the `-objects` library of the
3611 get_property(_vtk_add_module_private_depend_target_name GLOBAL
3612 PROPERTY "_vtk_module_${_vtk_add_module_private_depend}_target_name
")
3613 list(APPEND _vtk_add_module_private_depends_link
3614 "${_vtk_add_module_private_depend_target_name}-objects
")
3616 # Different kit, just use as normal.
3617 list(APPEND _vtk_add_module_private_depends_link
3618 "${_vtk_add_module_private_depend}
")
3622 # Add the `DEFINE_SYMBOL` for all other modules within the same kit which
3623 # have already been processed because the direct dependencies are not
3624 # sufficient: export symbols from any included header needs to be
3625 # correct. Since modules are built in topological order, a module can
3626 # only possibly include modules in the kit which have already been built.
3627 get_property(_vtk_add_module_kit_modules GLOBAL
3628 PROPERTY "_vtk_kit_${_vtk_add_module_build_with_kit}_kit_modules
")
3629 list(REMOVE_ITEM _vtk_add_module_kit_modules "${_vtk_build_module}
")
3630 foreach (_vtk_add_module_kit_module IN LISTS _vtk_add_module_kit_modules)
3631 get_property(_vtk_add_module_kit_module_target_name GLOBAL
3632 PROPERTY "_vtk_module_${_vtk_add_module_kit_module}_target_name
")
3633 if (TARGET "${_vtk_add_module_kit_module_target_name}-objects
")
3634 get_property(_vtk_add_module_kit_module_define_symbol
3635 TARGET "${_vtk_add_module_kit_module_target_name}-objects
"
3636 PROPERTY DEFINE_SYMBOL)
3637 target_compile_definitions("${_vtk_add_module_real_target}
"
3639 "${_vtk_add_module_kit_module_define_symbol}
")
3643 set(_vtk_add_module_depends_link ${_vtk_add_module_depends})
3644 set(_vtk_add_module_private_depends_link ${_vtk_add_module_private_depends})
3646 target_link_libraries("${_vtk_add_module_real_target}
"
3648 ${_vtk_add_module_depends_link}
3650 ${_vtk_add_module_private_depends_link})
3652 set(_vtk_add_module_private_depends_forward_link)
3653 foreach (_vtk_add_module_private_depend IN LISTS _vtk_add_module_depends_link _vtk_add_module_private_depends)
3654 _vtk_module_get_module_property("${_vtk_add_module_private_depend}
"
3655 PROPERTY "forward_link
"
3656 VARIABLE _vtk_add_module_forward_link)
3657 list(APPEND _vtk_add_module_private_depends_forward_link
3658 ${_vtk_add_module_forward_link})
3661 get_property(_vtk_add_module_optional_depends GLOBAL
3662 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends
")
3663 foreach (_vtk_add_module_optional_depend IN LISTS _vtk_add_module_optional_depends)
3664 if (TARGET "${_vtk_add_module_optional_depend}
")
3665 set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend}
")
3666 if (_vtk_add_module_build_with_kit)
3667 get_property(_vtk_add_module_optional_depend_kit GLOBAL
3668 PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_kit
")
3669 if (_vtk_add_module_optional_depend_kit STREQUAL _vtk_add_module_build_with_kit)
3670 # We're in the same kit; depend on the `-objects` library of the
3671 # module to avoid circular dependency (see explanation earlier)
3672 get_property(_vtk_add_module_optional_depend_target_name GLOBAL
3673 PROPERTY "_vtk_module_${_vtk_add_module_optional_depend}_target_name
")
3674 set(_vtk_add_module_optional_depend_link "${_vtk_add_module_optional_depend_target_name}-objects
")
3677 _vtk_module_get_module_property("${_vtk_add_module_optional_depend_link}
"
3678 PROPERTY "forward_link
"
3679 VARIABLE _vtk_add_module_forward_link)
3680 list(APPEND _vtk_add_module_private_depends_forward_link
3681 ${_vtk_add_module_forward_link})
3682 target_link_libraries("${_vtk_add_module_real_target}
"
3684 "${_vtk_add_module_optional_depend_link}
")
3686 string(REPLACE "::
" "_
" _vtk_add_module_optional_depend_safe "${_vtk_add_module_optional_depend}
")
3687 target_compile_definitions("${_vtk_add_module_real_target}
"
3689 "VTK_MODULE_ENABLE_${_vtk_add_module_optional_depend_safe}=$<TARGET_EXISTS:${_vtk_add_module_optional_depend}>
")
3692 if (_vtk_add_module_private_depends_forward_link)
3693 list(REMOVE_DUPLICATES _vtk_add_module_private_depends_forward_link)
3694 _vtk_module_set_module_property("${_vtk_build_module}
" APPEND
3695 PROPERTY "forward_link
"
3696 VALUE "${_vtk_add_module_private_depends_forward_link}
")
3697 target_link_libraries("${_vtk_add_module_real_target}
"
3699 "${_vtk_add_module_private_depends_forward_link}
")
3702 _vtk_module_standard_includes(
3703 TARGET "${_vtk_add_module_real_target}
"
3704 ${_vtk_add_module_includes_interface}
3705 HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}
")
3707 vtk_module_autoinit(
3708 MODULES ${_vtk_add_module_depends}
3709 ${_vtk_add_module_private_depends}
3710 "${_vtk_build_module}
"
3711 TARGETS "${_vtk_add_module_real_target}
")
3713 set(_vtk_add_module_headers_build)
3714 set(_vtk_add_module_headers_install)
3715 # TODO: Perform this in `vtk_module_install_headers` so that manually
3716 # installed headers may participate in wrapping as well.
3717 foreach (_vtk_add_module_header IN LISTS _vtk_add_module_HEADERS)
3718 if (IS_ABSOLUTE "${_vtk_add_module_header}
")
3719 list(APPEND _vtk_add_module_headers_build
3720 "${_vtk_add_module_header}
")
3722 list(APPEND _vtk_add_module_headers_build
3723 "${CMAKE_CURRENT_SOURCE_DIR}/${_vtk_add_module_header}
")
3726 get_filename_component(_vtk_add_module_header_name "${_vtk_add_module_header}
" NAME)
3727 list(APPEND _vtk_add_module_headers_install
3728 "\${_vtk_module_import_prefix}/${_vtk_build_HEADERS_DESTINATION}/${_vtk_add_module_header_name}
")
3731 set_property(TARGET "${_vtk_add_module_real_target}
"
3733 "INTERFACE_vtk_module_headers
" "${_vtk_add_module_headers_build}
")
3734 if (_vtk_build_INSTALL_HEADERS)
3735 set_property(TARGET "${_vtk_add_module_real_target}
"
3737 "INTERFACE_vtk_module_headers_install
" "${_vtk_add_module_headers_install}
")
3740 get_property(_vtk_add_module_exclude_wrap GLOBAL
3741 PROPERTY "_vtk_module_${_vtk_build_module}_exclude_wrap
")
3742 set_property(TARGET "${_vtk_add_module_real_target}
"
3744 "INTERFACE_vtk_module_exclude_wrap
" "${_vtk_add_module_exclude_wrap}
")
3745 if (NOT _vtk_add_module_exclude_wrap AND _vtk_build_ENABLE_WRAPPING)
3746 _vtk_module_write_wrap_hierarchy()
3749 set(_vtk_add_module_module_content)
3751 if (NOT _vtk_add_module_AUTOINIT_INCLUDE)
3752 get_property(_vtk_add_module_AUTOINIT_INCLUDE GLOBAL
3753 PROPERTY "_vtk_module_autoinit_include
")
3756 set(_vtk_add_module_autoinit_include_header)
3757 if (_vtk_add_module_AUTOINIT_INCLUDE)
3758 set(_vtk_add_module_autoinit_include_header
3759 "#include ${_vtk_add_module_AUTOINIT_INCLUDE}
")
3762 set(_vtk_add_module_autoinit_depends_includes)
3763 foreach (_vtk_add_module_autoinit_dependency IN LISTS _vtk_add_module_depends)
3764 get_property(_vtk_add_module_autoinit_dependency_target_name GLOBAL
3765 PROPERTY "_vtk_module_${_vtk_add_module_autoinit_dependency}_target_name
")
3766 if (_vtk_add_module_autoinit_dependency_target_name)
3767 get_property(_vtk_add_module_depends_needs_autoinit
3768 TARGET "${_vtk_add_module_autoinit_dependency_target_name}
"
3769 PROPERTY "INTERFACE_vtk_module_needs_autoinit
")
3771 set(_vtk_add_module_autoinit_dependency_target_name
3772 "${_vtk_add_module_autoinit_dependency}
")
3773 get_property(_vtk_add_module_depends_needs_autoinit
3774 TARGET "${_vtk_add_module_autoinit_dependency}
"
3775 PROPERTY "INTERFACE_vtk_module_needs_autoinit
")
3777 if (NOT _vtk_add_module_depends_needs_autoinit)
3780 get_property(_vtk_add_module_depends_library_name
3781 TARGET "${_vtk_add_module_autoinit_dependency_target_name}
"
3782 PROPERTY "INTERFACE_vtk_module_library_name
")
3784 string(APPEND _vtk_add_module_autoinit_depends_includes
3785 "#include \
"${_vtk_add_module_depends_library_name}Module.h\"\n")
3788 set(_vtk_add_module_autoinit_content)
3789 if (_vtk_add_module_autoinit_depends_includes)
3790 string(APPEND _vtk_add_module_autoinit_content
3791 "\n${_vtk_add_module_autoinit_depends_includes}\n
")
3794 get_property(_vtk_add_module_implementable GLOBAL
3795 PROPERTY "_vtk_module_${_vtk_build_module}_implementable
")
3796 get_property(_vtk_add_module_implements GLOBAL
3797 PROPERTY "_vtk_module_${_vtk_build_module}_implements
")
3798 if (_vtk_add_module_implementable)
3799 set_property(TARGET "${_vtk_add_module_real_target}
"
3801 "INTERFACE_vtk_module_implementable
" 1)
3804 if (_vtk_add_module_implementable OR _vtk_add_module_implements)
3805 set_property(TARGET "${_vtk_add_module_real_target}
"
3807 "INTERFACE_vtk_module_implements
" "${_vtk_add_module_implements}
")
3808 set_property(TARGET "${_vtk_add_module_real_target}
"
3810 "INTERFACE_vtk_module_needs_autoinit
" 1)
3812 string(APPEND _vtk_add_module_autoinit_content
3815#ifdef ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3816#include ${_vtk_add_module_library_name}_AUTOINIT_INCLUDE
3818#ifdef ${_vtk_add_module_library_name}_AUTOINIT
3819${_vtk_add_module_autoinit_include_header}
3824 string(APPEND _vtk_add_module_module_content
3825 "${_vtk_add_module_autoinit_content}
")
3828 if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
3829 generate_export_header("${_vtk_add_module_real_target}
"
3830 EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_EXPORT
"
3831 NO_EXPORT_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_EXPORT
"
3832 DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_DEPRECATED
"
3833 NO_DEPRECATED_MACRO_NAME "${_vtk_add_module_EXPORT_MACRO_PREFIX}_NO_DEPRECATED
"
3834 STATIC_DEFINE "${_vtk_add_module_EXPORT_MACRO_PREFIX}_STATIC_DEFINE
"
3835 EXPORT_FILE_NAME "${_vtk_add_module_module_header_name}
"
3836 CUSTOM_CONTENT_FROM_VARIABLE _vtk_add_module_module_content)
3839 _vtk_module_apply_properties("${_vtk_add_module_target_name}
")
3840 _vtk_module_install("${_vtk_add_module_target_name}
")
3841 _vtk_module_add_header_tests()
3843 if (_vtk_add_module_build_with_kit)
3844 _vtk_module_install("${_vtk_add_module_target_name}-objects
")
3850@brief Add header tests for a module
3852@todo Move this function out to be VTK-specific, probably into
3853`vtkModuleTesting.cmake`. Each module would then need to manually call this
3854function. It currently assumes it is in VTK itself.
3857_vtk_module_add_header_tests()
3860function (_vtk_module_add_header_tests)
3861 if (NOT BUILD_TESTING)
3865 get_property(_vtk_add_header_tests_is_third_party GLOBAL
3866 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
3867 if (_vtk_add_header_tests_is_third_party)
3871 # TODO: Add test compiles which include each header file to ensure that
3872 # public headers have their includes satisfied by a public dependency.
3875 if (NOT Python${VTK_PYTHON_VERSION}_EXECUTABLE)
3880 if (NOT VTK_SOURCE_DIR)
3885 NAME "${_vtk_build_module}-HeaderTest
"
3886 COMMAND "${Python${VTK_PYTHON_VERSION}_EXECUTABLE}
"
3887 # TODO: What to do when using this from a VTK install?
3888 "${VTK_SOURCE_DIR}/Testing/Core/HeaderTesting.py
"
3889 "${CMAKE_CURRENT_SOURCE_DIR}
"
3890 "${_vtk_add_module_EXPORT_MACRO}
")
3895@brief Install headers
3897Installing headers is done for normal modules by the @ref vtk_module_add_module
3898function already. However, sometimes header structures are more complicated and
3899need to be installed manually. This is common for third party modules or
3900projects which use more than a single directory of headers for a module.
3902To facilitate the installation of headers in various ways, the this function is
3903available. This function honors the `INSTALL_HEADERS`, `HEADERS_DESTINATION`,
3904and `HEADERS_COMPONENT` arguments to @ref vtk_module_build.
3907vtk_module_install_headers(
3908 [USE_RELATIVE_PATHS]
3909 [DIRECTORIES <directory>...]
3914Installation of header directories follows CMake's `install` function semantics
3915with respect to trailing slashes.
3917If `USE_RELATIVE_PATHS` is given, the directory part of any listed files will
3918be added to the destination. Absolute paths will be computed relative to
3919`${CMAKE_CURRENT_BINARY_DIR}`.
3921function (vtk_module_install_headers)
3922 cmake_parse_arguments(PARSE_ARGV 0 _vtk_install_headers
3923 "USE_RELATIVE_PATHS
"
3925 "FILES;DIRECTORIES
")
3927 if (_vtk_install_headers_UNPARSED_ARGUMENTS)
3930 "${_vtk_install_headers_UNPARSED_ARGUMENTS}
")
3933 if (NOT _vtk_build_INSTALL_HEADERS)
3937 if (NOT _vtk_install_headers_FILES AND NOT _vtk_install_headers_DIRECTORIES)
3941 set(_vtk_install_headers_destination
3942 "${_vtk_build_HEADERS_DESTINATION}/${_vtk_install_headers_SUBDIR}
")
3943 set(_vtk_install_headers_headers_component "${_vtk_build_HEADERS_COMPONENT}
")
3944 if (_vtk_build_TARGET_SPECIFIC_COMPONENTS)
3945 string(PREPEND _vtk_install_headers_headers_component "${_vtk_build_module}-
")
3946 if (_vtk_build_BUILD_WITH_KITS)
3947 get_property(_vtk_install_headers_build_with_kit GLOBAL
3948 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
3949 if (_vtk_install_headers_build_with_kit)
3950 set(_vtk_install_headers_headers_component "${_vtk_install_headers_build_with_kit}-${_vtk_build_HEADERS_COMPONENT}
")
3954 if (_vtk_install_headers_USE_RELATIVE_PATHS)
3955 set(_vtk_install_headers_destination_file_subdir "")
3956 foreach (_vtk_install_headers_file IN LISTS _vtk_install_headers_FILES)
3957 if (IS_ABSOLUTE "${_vtk_install_headers_file}
")
3958 file(RELATIVE_PATH _vtk_install_headers_destination_file_from_binary_dir
3959 "${CMAKE_CURRENT_BINARY_DIR}
"
3960 "${_vtk_install_headers_file}
")
3961 get_filename_component(_vtk_install_headers_destination_file_subdir "${_vtk_install_headers_destination_file_from_binary_dir}
" DIRECTORY)
3963 get_filename_component(_vtk_install_headers_destination_file_subdir "${_vtk_install_headers_file}
" DIRECTORY)
3966 FILES ${_vtk_install_headers_file}
3967 DESTINATION "${_vtk_install_headers_destination}/${_vtk_install_headers_destination_file_subdir}
"
3968 COMPONENT "${_vtk_install_headers_headers_component}
")
3970 elseif (_vtk_install_headers_FILES)
3972 FILES ${_vtk_install_headers_FILES}
3973 DESTINATION "${_vtk_install_headers_destination}
"
3974 COMPONENT "${_vtk_install_headers_headers_component}
")
3976 set(_vtk_install_headers_destination_directory_subdir "")
3977 foreach (_vtk_install_headers_directory IN LISTS _vtk_install_headers_DIRECTORIES)
3978 if (_vtk_install_headers_USE_RELATIVE_PATHS)
3979 if (IS_ABSOLUTE "${_vtk_install_headers_directory}
")
3980 file(RELATIVE_PATH _vtk_install_headers_destination_directory_from_binary_dir
3981 "${CMAKE_CURRENT_BINARY_DIR}
"
3982 "${_vtk_install_headers_directory}
")
3983 get_filename_component(_vtk_install_headers_destination_directory_subdir "${_vtk_install_headers_destination_directory_from_binary_dir}
" DIRECTORY)
3985 get_filename_component(_vtk_install_headers_destination_directory_subdir "${_vtk_install_headers_directory}
" DIRECTORY)
3989 DIRECTORY "${_vtk_install_headers_directory}
"
3990 DESTINATION "${_vtk_install_headers_destination}/${_vtk_install_headers_destination_directory_subdir}
"
3991 COMPONENT "${_vtk_install_headers_headers_component}
")
3996@ingroup module-internal
3997@brief Apply properties to a module
3999Apply build properties to a target. Generally only useful to wrapping code or
4000other modules that cannot use @ref vtk_module_add_module for some reason.
4003_vtk_module_apply_properties(<target>
4004 [BASENAME <basename>])
4007If `BASENAME` is given, it will be used instead of the target name as the basis
4008for `OUTPUT_NAME`. Full modules (as opposed to third party or other non-module
4009libraries) always use the module's `LIBRARY_NAME` setting.
4011The following target properties are set based on the arguments to the calling
4012@ref vtk_module_build call:
4014 - `OUTPUT_NAME` (based on the module's `LIBRARY_NAME` and
4015 `vtk_module_build(LIBRARY_NAME_SUFFIX)`)
4016 - `VERSION` (based on `vtk_module_build(VERSION)`)
4017 - `SOVERSION` (based on `vtk_module_build(SOVERSION)`)
4018 - `DEBUG_POSTFIX` (on Windows)
4020function (_vtk_module_apply_properties target)
4021 cmake_parse_arguments(PARSE_ARGV 1 _vtk_apply_properties
4026 if (_vtk_apply_properties_UNPARSED_ARGUMENTS)
4029 "${_vtk_apply_properties_UNPARSED_ARGUMENTS}.
")
4032 if (NOT DEFINED _vtk_apply_properties_BASENAME)
4033 set(_vtk_apply_properties_BASENAME "${
target}
")
4036 get_property(_vtk_add_module_type
4039 if (_vtk_add_module_type STREQUAL "OBJECT_LIBRARY
" OR
4040 _vtk_add_module_type STREQUAL "INTERFACE_LIBRARY
")
4044 set(_vtk_add_module_library_name "${_vtk_apply_properties_BASENAME}
")
4045 get_property(_vtk_add_module_target_name GLOBAL
4046 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
4047 if (_vtk_add_module_target_name STREQUAL "${
target}
")
4048 get_property(_vtk_add_module_library_name GLOBAL
4049 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
4051 set(_vtk_add_module_output_name "${_vtk_add_module_library_name}${_vtk_add_module_LIBRARY_NAME_SUFFIX}
")
4052 if (_vtk_build_LIBRARY_NAME_SUFFIX)
4053 string(APPEND _vtk_add_module_output_name "-${_vtk_build_LIBRARY_NAME_SUFFIX}
")
4056 set_target_properties("${
target}
"
4058 OUTPUT_NAME "${_vtk_add_module_output_name}
")
4060 if (_vtk_build_VERSION AND NOT _vtk_add_module_type STREQUAL "EXECUTABLE
")
4061 set_target_properties("${
target}
"
4063 VERSION "${_vtk_build_VERSION}
")
4066 if (_vtk_build_SOVERSION)
4067 set_target_properties("${
target}
"
4069 SOVERSION "${_vtk_build_SOVERSION}
")
4073 set_target_properties("${
target}
"
4080@ingroup module-internal
4081@brief Install a module target
4083Install a target within the module context. Generally only useful to wrapping
4084code, modules that cannot use @ref vtk_module_add_module for some reason, or
4085modules which create utility targets that need installed.
4088_vtk_module_install(<target>)
4091This function uses the various installation options to @ref vtk_module_build
4092function to keep the install uniform.
4094function (_vtk_module_install target)
4095 set(_vtk_install_export)
4096 if (_vtk_build_INSTALL_EXPORT)
4097 list(APPEND _vtk_install_export
4098 EXPORT "${_vtk_build_INSTALL_EXPORT}
")
4101 set(_vtk_install_headers_component "${_vtk_build_HEADERS_COMPONENT}
")
4102 set(_vtk_install_targets_component "${_vtk_build_TARGETS_COMPONENT}
")
4103 if (_vtk_build_TARGET_SPECIFIC_COMPONENTS)
4105 string(PREPEND _vtk_install_headers_component "${_vtk_build_kit}-
")
4106 string(PREPEND _vtk_install_targets_component "${_vtk_build_kit}-
")
4108 string(PREPEND _vtk_install_headers_component "${_vtk_build_module}-
")
4109 string(PREPEND _vtk_install_targets_component "${_vtk_build_module}-
")
4110 if (_vtk_build_BUILD_WITH_KITS)
4111 get_property(_vtk_install_kit GLOBAL
4112 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
4113 if (_vtk_install_kit)
4114 set(_vtk_install_headers_component "${_vtk_install_kit}-${_vtk_build_HEADERS_COMPONENT}
")
4115 set(_vtk_install_targets_component "${_vtk_install_kit}-${_vtk_build_TARGETS_COMPONENT}
")
4123 ${_vtk_install_export}
4126 DESTINATION "${_vtk_build_ARCHIVE_DESTINATION}
"
4127 COMPONENT "${_vtk_install_headers_component}
"
4129 DESTINATION "${_vtk_build_LIBRARY_DESTINATION}
"
4130 COMPONENT "${_vtk_install_targets_component}
"
4131 NAMELINK_COMPONENT "${_vtk_build_HEADERS_COMPONENT}
"
4133 DESTINATION "${_vtk_build_RUNTIME_DESTINATION}
"
4134 COMPONENT "${_vtk_install_targets_component}
")
4139@brief Create a module executable
4141Some modules may have associated executables with them. By using this function,
4142the target will be installed following the options given to the associated
4143@ref vtk_module_build command. Its name will also be changed according to the
4144`LIBRARY_NAME_SUFFIX` option.
4147vtk_module_add_executable(<name>
4150 [BASENAME <basename>]
4154If `NO_INSTALL` is specified, the executable will not be installed. If
4155`BASENAME` is given, it will be used as the name of the executable rather than
4158If `DEVELOPMENT` is given, it marks the executable as a development tool and
4159will not be installed if `INSTALL_HEADERS` is not set for the associated
4160@ref vtk_module_build command.
4162If the executable being built is the module, its module properties are used
4163rather than `BASENAME`. In addition, the dependencies of the module will be
4166function (vtk_module_add_executable name)
4167 cmake_parse_arguments(PARSE_ARGV 1 _vtk_add_executable
4168 "NO_INSTALL;DEVELOPMENT
"
4172 if (NOT _vtk_add_executable_UNPARSED_ARGUMENTS)
4174 "The ${name} executable must have at least one
source file.
")
4177 if (_vtk_add_executable_NO_INSTALL AND _vtk_add_executable_DEVELOPMENT)
4179 "Both `NO_INSTALL` and `DEVELOPMENT` may not be specified.
")
4182 set(_vtk_add_executable_target_name "${
name}
")
4183 set(_vtk_add_executable_library_name "${
name}
")
4184 if (name STREQUAL _vtk_build_module)
4185 if (_vtk_add_executable_NO_INSTALL)
4187 "The executable ${_vtk_build_module} module may not use `NO_INSTALL`.
")
4189 if (DEFINED _vtk_add_executable_BASENAME)
4191 "The executable ${_vtk_build_module} module may not pass `BASENAME`
"
4192 "when adding the executable; it is controlled via `LIBRARY_NAME` in
"
4193 "the associated `
vtk.module` file.
")
4195 get_property(_vtk_add_executable_target_name GLOBAL
4196 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
4197 get_property(_vtk_add_executable_library_name GLOBAL
4198 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
4201 if (_vtk_add_executable_DEVELOPMENT AND NOT _vtk_build_INSTALL_HEADERS)
4202 set(_vtk_add_executable_NO_INSTALL ON)
4206 set(CMAKE_BUILD_RPATH_USE_ORIGIN 1)
4208 file(RELATIVE_PATH _vtk_add_executable_relpath
4209 "/prefix/${_vtk_build_RUNTIME_DESTINATION}
"
4210 "/prefix/${_vtk_build_LIBRARY_DESTINATION}
")
4212 set(_vtk_add_executable_origin_rpath_prefix
4215 set(_vtk_add_executable_origin_rpath_prefix
4219 list(APPEND CMAKE_INSTALL_RPATH
4220 "${_vtk_add_executable_origin_rpath_prefix}/${_vtk_add_executable_relpath}
")
4223 add_executable("${_vtk_add_executable_target_name}
"
4224 ${_vtk_add_executable_UNPARSED_ARGUMENTS})
4226 if (name STREQUAL _vtk_build_module AND NOT _vtk_add_executable_target_name STREQUAL _vtk_build_module)
4227 add_executable("${_vtk_build_module}
" ALIAS
4228 "${_vtk_add_executable_target_name}
")
4231 if (name STREQUAL _vtk_build_module)
4232 get_property(_vtk_real_target_kit GLOBAL
4233 PROPERTY "_vtk_module_${_vtk_build_module}_kit
")
4234 if (_vtk_real_target_kit)
4236 "Executable module ${_vtk_build_module} is declared to be part of a
"
4237 "kit;
this is not possible.
")
4240 get_property(_vtk_add_executable_depends GLOBAL
4241 PROPERTY "_vtk_module_${_vtk_build_module}_depends
")
4242 get_property(_vtk_add_executable_private_depends GLOBAL
4243 PROPERTY "_vtk_module_${_vtk_build_module}_private_depends
")
4244 target_link_libraries("${_vtk_add_executable_target_name}
"
4246 ${_vtk_add_executable_depends}
4248 ${_vtk_add_executable_private_depends})
4249 get_property(_vtk_add_executable_optional_depends GLOBAL
4250 PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends
")
4251 foreach (_vtk_add_executable_optional_depend IN LISTS _vtk_add_executable_optional_depends)
4252 string(REPLACE "::
" "_
" _vtk_add_executable_optional_depend_safe "${_vtk_add_executable_optional_depend}
")
4253 target_compile_definitions("${_vtk_add_executable_target_name}
"
4255 "VTK_MODULE_ENABLE_${_vtk_add_executable_optional_depend_safe}=$<TARGET_EXISTS:{_vtk_add_executable_optional_depend}>
")
4258 if (_vtk_module_warnings)
4259 if (_vtk_add_executable_depends)
4261 "Executable module ${_vtk_build_module} has
public dependencies;
this "
4262 "shouldn
't be necessary.")
4267 if (_vtk_build_UTILITY_TARGET)
4268 target_link_libraries("${_vtk_add_executable_target_name}"
4270 "${_vtk_build_UTILITY_TARGET}")
4273 set(_vtk_add_executable_property_args)
4274 if (DEFINED _vtk_add_executable_BASENAME)
4275 list(APPEND _vtk_add_executable_property_args
4276 BASENAME "${_vtk_add_executable_BASENAME}")
4279 _vtk_module_apply_properties("${_vtk_add_executable_target_name}"
4280 ${_vtk_add_executable_property_args})
4281 _vtk_module_standard_includes(TARGET "${_vtk_add_executable_target_name}")
4283 if (NOT _vtk_add_executable_NO_INSTALL)
4284 _vtk_module_install("${_vtk_add_executable_target_name}")
4290@brief Find a package
4292A wrapper around `find_package` that records information for use so that the
4293same targets may be found when finding this package.
4295Modules may need to find external dependencies. CMake often provides modules to
4296find these dependencies, but when imported targets are involved, these.need to
4297also be found from dependencies of the current project. Since the benefits of
4298imported targets greatly outweighs not using them, it is preferred to use them.
4300The module system provides the @ref vtk_module_find_package function in order
4301to extend `find_package` support to include finding the dependencies from an
4302install of the project.
4305vtk_module_find_package(
4306 [PRIVATE] [CONFIG_MODE]
4309 [COMPONENTS <component>...]
4310 [OPTIONAL_COMPONENTS <component>...]
4311 [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4312 [VERSION_VAR <variable>])
4315 * `PACKAGE`: The name of the package to find.
4316 * `VERSION`: The minimum version of the package that is required.
4317 * `COMPONENTS`: Components of the package which are required.
4318 * `OPTIONAL_COMPONENTS`: Components of the package which may be missing.
4319 * `FORWARD_VERSION_REQ`: If provided, the found version will be promoted to
4320 the minimum version required matching the given version scheme.
4321 * `VERSION_VAR`: The variable to use as the provided version (defaults to
4322 `<PACKAGE>_VERSION`). It may contain `@` in which case it will be
4323 configured. This is useful for modules which only provide components of the
4324 actual version number.
4325 * `CONFIG_MODE`: If present, pass `CONFIG` to the underlying `find_package`
4327 * `PRIVATE`: The dependency should not be exported to the install.
4329The `PACKAGE` argument is the only required argument. The rest are optional.
4331Note that `PRIVATE` is *only* applicable for private dependencies on interface
4332targets (basically, header libraries) because some platforms require private
4333shared libraries dependencies to be present when linking dependent libraries
4334and executables as well. Such usages should additionally be used only via a
4335`$<BUILD_INTERFACE>` generator expression to avoid putting the target name into
4336the install tree at all.
4338macro (vtk_module_find_package)
4339 # This needs to be a macro because find modules typically set variables which
4340 # may need to be available in the calling scope. If we declare that it only
4341 # works with imported targets (which is the primary motivating factor behind
4342 # this function), we can instead make it a function at the cost of any
4343 # non-target variables a module might want to set being available. It is
4344 # unlikely that this will be the case for all callers.
4345 if (NOT _vtk_build_module)
4347 "`vtk_module_find_package` may only be called when building a VTK "
4351 # Note: when adding arguments here, add them to the `unset` block at the end
4353 cmake_parse_arguments(_vtk_find_package
4354 "PRIVATE;CONFIG_MODE"
4355 "PACKAGE;VERSION;FORWARD_VERSION_REQ;VERSION_VAR"
4356 "COMPONENTS;OPTIONAL_COMPONENTS"
4359 if (_vtk_find_package_UNPARSED_ARGUMENTS)
4361 "Unparsed arguments for vtk_module_find_package: "
4362 "${_vtk_find_package_UNPARSED_ARGUMENTS}")
4365 if (NOT DEFINED _vtk_find_package_PACKAGE)
4367 "The `PACKAGE` argument is required.")
4370 if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4371 if (_vtk_find_package_PRIVATE)
4373 "The `FORWARD_VERSION_REQ` argument is incompatible with the "
4377 if (NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR" AND
4378 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR" AND
4379 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH" AND
4380 NOT _vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4382 "The `FORWARD_VERSION_REQ` argument must be one of `MAJOR`, `MINOR`, "
4383 "`PATCH`, or `EXACT`.")
4387 if (NOT DEFINED _vtk_find_package_VERSION_VAR)
4388 set(_vtk_find_package_VERSION_VAR
4389 "${_vtk_find_package_PACKAGE}_VERSION")
4392 set(_vtk_find_package_config)
4393 if (_vtk_find_package_CONFIG_MODE)
4394 set(_vtk_find_package_config "CONFIG")
4397 find_package("${_vtk_find_package_PACKAGE}"
4398 ${_vtk_find_package_VERSION}
4399 ${_vtk_find_package_config}
4400 COMPONENTS ${_vtk_find_package_COMPONENTS}
4401 OPTIONAL_COMPONENTS ${_vtk_find_package_OPTIONAL_COMPONENTS})
4402 if (NOT ${_vtk_find_package_PACKAGE}_FOUND)
4404 "Could not find the ${_vtk_find_package_PACKAGE} external dependency.")
4408 set(_vtk_find_package_optional_components_found)
4409 foreach (_vtk_find_package_optional_component IN LISTS _vtk_find_package_OPTIONAL_COMPONENTS)
4410 if (${_vtk_find_package_PACKAGE}_${_vtk_find_package_optional_component}_FOUND)
4411 list(APPEND _vtk_find_package_optional_components_found
4412 "${_vtk_find_package_optional_component}")
4416 set_property(GLOBAL APPEND
4418 "_vtk_module_find_packages_${_vtk_build_PACKAGE}" "${_vtk_find_package_PACKAGE}")
4419 set(_vtk_find_package_base "_vtk_module_find_package_${_vtk_build_module}")
4420 set_property(GLOBAL APPEND
4422 "${_vtk_find_package_base}" "${_vtk_find_package_PACKAGE}")
4423 set(_vtk_find_package_base_package "${_vtk_find_package_base}_${_vtk_find_package_PACKAGE}")
4426 "${_vtk_find_package_base_package}_private" "${_vtk_find_package_PRIVATE}")
4429 "${_vtk_find_package_base_package}_version" "${_vtk_find_package_VERSION}")
4432 "${_vtk_find_package_base_package}_config" "${_vtk_find_package_CONFIG_MODE}")
4433 set_property(GLOBAL APPEND
4435 "${_vtk_find_package_base_package}_components" "${_vtk_find_package_COMPONENTS}")
4436 set_property(GLOBAL APPEND
4438 "${_vtk_find_package_base_package}_optional_components" "${_vtk_find_package_OPTIONAL_COMPONENTS}")
4439 set_property(GLOBAL APPEND
4441 "${_vtk_find_package_base_package}_optional_components_found" "${_vtk_find_package_optional_components_found}")
4444 "${_vtk_find_package_base_package}_exact" "0")
4445 if (DEFINED _vtk_find_package_FORWARD_VERSION_REQ)
4446 string(FIND "${_vtk_find_package_VERSION_VAR}" "@" _vtk_find_package_idx)
4447 if (_vtk_find_package_idx EQUAL -1)
4448 if (NOT DEFINED "${_vtk_find_package_VERSION_VAR}")
4450 "The `${_vtk_find_package_VERSION_VAR}` variable is not defined.")
4452 set(_vtk_find_package_version "${${_vtk_find_package_VERSION_VAR}}")
4454 string(CONFIGURE "${_vtk_find_package_VERSION_VAR}" _vtk_find_package_version)
4456 unset(_vtk_find_package_idx)
4458 if ("${_vtk_find_package_version}" STREQUAL "")
4460 "The `${_vtk_find_package_PACKAGE}` version is empty.")
4463 if (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MAJOR")
4464 set(_vtk_find_package_version_regex "^\([^.]*\).*")
4465 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "MINOR")
4466 set(_vtk_find_package_version_regex "^\([^.]*.[^.]*\).*")
4467 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "PATCH")
4468 set(_vtk_find_package_version_regex "^\([^.]*.[^.]*.[^.]*\).*")
4469 elseif (_vtk_find_package_FORWARD_VERSION_REQ STREQUAL "EXACT")
4470 set(_vtk_find_package_version_regex "^\\(.*\\)$")
4473 "${_vtk_find_package_base_package}_exact" "1")
4476 string(REGEX REPLACE "${_vtk_find_package_version_regex}" "\\1"
4477 _vtk_find_package_found_version "${_vtk_find_package_version}")
4478 unset(_vtk_find_package_version_regex)
4479 unset(_vtk_find_package_version)
4483 "${_vtk_find_package_base_package}_version" "${_vtk_find_package_found_version}")
4484 unset(_vtk_find_package_found_version)
4487 unset(_vtk_find_package_base)
4488 unset(_vtk_find_package_base_package)
4489 unset(_vtk_find_package_COMPONENTS)
4490 unset(_vtk_find_package_FORWARD_VERSION_REQ)
4491 unset(_vtk_find_package_OPTIONAL_COMPONENTS)
4492 unset(_vtk_find_package_PACKAGE)
4493 unset(_vtk_find_package_PRIVATE)
4494 unset(_vtk_find_package_UNPARSED_ARGUMENTS)
4495 unset(_vtk_find_package_VERSION)
4496 unset(_vtk_find_package_VERSION_VAR)
4501@brief Export find_package calls for dependencies
4503When installing a project that is meant to be found via `find_package` from
4504CMake, using imported targets in the build means that imported targets need to
4505be created during the `find_package` as well. This function writes a file
4506suitable for inclusion from a `<package>-config.cmake` file to satisfy
4507dependencies. It assumes that the exported targets are named
4508`${CMAKE_FIND_PACKAGE_NAME}::${component}`. Dependent packages will only be
4509found if a requested component requires the package to be found either directly
4513vtk_module_export_find_packages(
4514 CMAKE_DESTINATION <directory>
4515 FILE_NAME <filename>
4516 [COMPONENT <component>]
4517 MODULES <module>...)
4520The file will be named according to the `FILE_NAME` argument will be installed
4521into `CMAKE_DESTINATION` in the build and install trees with the given
4522filename. If not provided, the `development` component will be used.
4524The `vtk_module_find_package` calls made by the modules listed in `MODULES`
4525will be exported to this file.
4527function (vtk_module_export_find_packages)
4528 cmake_parse_arguments(PARSE_ARGV 0 _vtk_export
4530 "CMAKE_DESTINATION;FILE_NAME;COMPONENT"
4533 if (_vtk_export_UNPARSED_ARGUMENTS)
4535 "Unparsed arguments for vtk_module_export_find_packages: "
4536 "${_vtk_export_UNPARSED_ARGUMENTS}")
4539 if (NOT DEFINED _vtk_export_CMAKE_DESTINATION)
4541 "The `CMAKE_DESTINATION` is required.")
4544 if (NOT DEFINED _vtk_export_FILE_NAME)
4546 "The `FILE_NAME` is required.")
4549 if (NOT DEFINED _vtk_export_COMPONENT)
4550 set(_vtk_export_COMPONENT "development")
4553 set(_vtk_export_prelude
4554"set(_vtk_module_find_package_quiet)
4555if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4556 set(_vtk_module_find_package_quiet QUIET)
4559set(_vtk_module_find_package_components_checked)
4560set(_vtk_module_find_package_components_to_check
4561 \${\${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
4562set(_vtk_module_find_package_components)
4563set(_vtk_module_find_package_components_required)
4564while (_vtk_module_find_package_components_to_check)
4565 list(GET _vtk_module_find_package_components_to_check 0 _vtk_module_component)
4566 list(REMOVE_AT _vtk_module_find_package_components_to_check 0)
4567 if (_vtk_module_component IN_LIST _vtk_module_find_package_components_checked)
4570 list(APPEND _vtk_module_find_package_components_checked
4571 \"\${_vtk_module_component}\")
4573 list(APPEND _vtk_module_find_package_components
4574 \"\${_vtk_module_component}\")
4575 if (\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_\${_vtk_module_component})
4576 list(APPEND _vtk_module_find_package_components_required
4577 \"\${_vtk_module_component}\")
4580 if (TARGET \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4581 set(_vtk_module_find_package_component_target \"\${CMAKE_FIND_PACKAGE_NAME}::\${_vtk_module_component}\")
4582 elseif (TARGET \"\${_vtk_module_component}\")
4583 set(_vtk_module_find_package_component_target \"\${_vtk_module_component}\")
4585 # No such target for the component; skip.
4588 get_property(_vtk_module_find_package_depends
4589 TARGET \"\${_vtk_module_find_package_component_target}\"
4590 PROPERTY \"INTERFACE_vtk_module_depends\")
4591 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4592 list(APPEND _vtk_module_find_package_components_to_check
4593 \${_vtk_module_find_package_depends})
4594 get_property(_vtk_module_find_package_depends
4595 TARGET \"\${_vtk_module_find_package_component_target}\"
4596 PROPERTY \"INTERFACE_vtk_module_private_depends\")
4597 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4598 list(APPEND _vtk_module_find_package_components_to_check
4599 \${_vtk_module_find_package_depends})
4600 get_property(_vtk_module_find_package_depends
4601 TARGET \"\${_vtk_module_find_package_component_target}\"
4602 PROPERTY \"INTERFACE_vtk_module_optional_depends\")
4603 foreach (_vtk_module_find_package_depend IN LISTS _vtk_module_find_package_depends)
4604 if (TARGET \"\${_vtk_module_find_package_depend}\")
4605 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depend \"\${_vtk_module_find_package_depend}\")
4606 list(APPEND _vtk_module_find_package_components_to_check
4607 \"\${_vtk_module_find_package_depend}\")
4610 get_property(_vtk_module_find_package_depends
4611 TARGET \"\${_vtk_module_find_package_component_target}\"
4612 PROPERTY \"INTERFACE_vtk_module_forward_link\")
4613 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_depends \"\${_vtk_module_find_package_depends}\")
4614 list(APPEND _vtk_module_find_package_components_to_check
4615 \${_vtk_module_find_package_depends})
4617 get_property(_vtk_module_find_package_kit
4618 TARGET \"\${_vtk_module_find_package_component_target}\"
4619 PROPERTY \"INTERFACE_vtk_module_kit\")
4620 if (_vtk_module_find_package_kit)
4621 get_property(_vtk_module_find_package_kit_modules
4622 TARGET \"\${_vtk_module_find_package_kit}\"
4623 PROPERTY \"INTERFACE_vtk_kit_kit_modules\")
4624 string(REPLACE \"\${CMAKE_FIND_PACKAGE_NAME}::\" \"\" _vtk_module_find_package_kit_modules \"\${_vtk_module_find_package_kit_modules}\")
4625 list(APPEND _vtk_module_find_package_components_to_check
4626 \${_vtk_module_find_package_kit_modules})
4629unset(_vtk_module_find_package_component_target)
4630unset(_vtk_module_find_package_components_to_check)
4631unset(_vtk_module_find_package_components_checked)
4632unset(_vtk_module_component)
4633unset(_vtk_module_find_package_depend)
4634unset(_vtk_module_find_package_depends)
4635unset(_vtk_module_find_package_kit)
4636unset(_vtk_module_find_package_kit_modules)
4638if (_vtk_module_find_package_components)
4639 list(REMOVE_DUPLICATES _vtk_module_find_package_components)
4641if (_vtk_module_find_package_components_required)
4642 list(REMOVE_DUPLICATES _vtk_module_find_package_components_required)
4645 set(_vtk_export_build_content)
4646 set(_vtk_export_install_content)
4647 foreach (_vtk_export_module IN LISTS _vtk_export_MODULES)
4648 get_property(_vtk_export_target_name GLOBAL
4649 PROPERTY "_vtk_module_${_vtk_export_module}_target_name")
4650 # Use the export name of the target if it has one set.
4651 get_property(_vtk_export_target_has_export_name
4652 TARGET "${_vtk_export_target_name}"
4653 PROPERTY EXPORT_NAME SET)
4654 if (_vtk_export_target_has_export_name)
4655 get_property(_vtk_export_target_name
4656 TARGET "${_vtk_export_target_name}"
4657 PROPERTY EXPORT_NAME)
4659 set(_vtk_export_base "_vtk_module_find_package_${_vtk_export_module}")
4660 get_property(_vtk_export_packages GLOBAL
4661 PROPERTY "${_vtk_export_base}")
4662 if (NOT _vtk_export_packages)
4666 set(_vtk_export_module_prelude
4667"set(_vtk_module_find_package_enabled OFF)
4668set(_vtk_module_find_package_is_required OFF)
4669set(_vtk_module_find_package_fail_if_not_found OFF)
4670if (_vtk_module_find_package_components)
4671 if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components)
4672 set(_vtk_module_find_package_enabled ON)
4673 if (\"${_vtk_export_target_name}\" IN_LIST _vtk_module_find_package_components_required)
4674 set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4675 set(_vtk_module_find_package_fail_if_not_found ON)
4679 set(_vtk_module_find_package_enabled ON)
4680 set(_vtk_module_find_package_is_required \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}\")
4681 set(_vtk_module_find_package_fail_if_not_found ON)
4684if (_vtk_module_find_package_enabled)
4685 set(_vtk_module_find_package_required)
4686 if (_vtk_module_find_package_is_required)
4687 set(_vtk_module_find_package_required REQUIRED)
4690 list(REMOVE_DUPLICATES _vtk_export_packages)
4691 set(_vtk_export_module_build_content)
4692 set(_vtk_export_module_install_content)
4693 foreach (_vtk_export_package IN LISTS _vtk_export_packages)
4694 set(_vtk_export_base_package "${_vtk_export_base}_${_vtk_export_package}")
4695 get_property(_vtk_export_private GLOBAL
4696 PROPERTY "${_vtk_export_base_package}_private")
4697 get_property(_vtk_export_version GLOBAL
4698 PROPERTY "${_vtk_export_base_package}_version")
4699 get_property(_vtk_export_config GLOBAL
4700 PROPERTY "${_vtk_export_base_package}_config")
4701 get_property(_vtk_export_exact GLOBAL
4702 PROPERTY "${_vtk_export_base_package}_exact")
4703 get_property(_vtk_export_components GLOBAL
4704 PROPERTY "${_vtk_export_base_package}_components")
4705 get_property(_vtk_export_optional_components GLOBAL
4706 PROPERTY "${_vtk_export_base_package}_optional_components")
4707 get_property(_vtk_export_optional_components_found GLOBAL
4708 PROPERTY "${_vtk_export_base_package}_optional_components_found")
4710 # Assume that any found optional components end up being required.
4711 if (${_vtk_export_base_package}_optional_components_found)
4712 list(REMOVE_ITEM _vtk_export_optional_components
4713 ${_vtk_export_optional_components_found})
4714 list(APPEND _vtk_export_components
4715 ${_vtk_export_optional_components_found})
4718 set(_vtk_export_config_arg)
4719 if (_vtk_export_config)
4720 set(_vtk_export_config_arg CONFIG)
4723 set(_vtk_export_exact_arg)
4724 if (_vtk_export_exact)
4725 set(_vtk_export_exact_arg EXACT)
4728 set(_vtk_export_module_content
4729" find_package(${_vtk_export_package}
4730 ${_vtk_export_version}
4731 ${_vtk_export_exact_arg}
4732 ${_vtk_export_config_arg}
4733 \${_vtk_module_find_package_quiet}
4734 \${_vtk_module_find_package_required}
4735 COMPONENTS ${_vtk_export_components}
4736 OPTIONAL_COMPONENTS ${_vtk_export_optional_components})
4737 if (NOT ${_vtk_export_package}_FOUND AND _vtk_module_find_package_fail_if_not_found)
4738 if (NOT \${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
4740 \"Could not find the \${CMAKE_FIND_PACKAGE_NAME} package due to a \"
4741 \"missing dependency: ${_vtk_export_package}\")
4743 set(\"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_FOUND\" 0)
4744 list(APPEND \"\${CMAKE_FIND_PACKAGE_NAME}_${_vtk_export_target_name}_NOT_FOUND_MESSAGE\"
4745 \"Failed to find the ${_vtk_export_package} package.\")
4748 string(APPEND _vtk_export_module_build_content "${_vtk_export_module_content}")
4749 # Private usages should be guarded by `$<BUILD_INTERFACE>` and can be
4750 # skipped for the install tree regardless of the build mode.
4751 if (NOT _vtk_export_private)
4752 string(APPEND _vtk_export_module_install_content "${_vtk_export_module_content}")
4756 set(_vtk_export_module_trailer
4759unset(_vtk_module_find_package_fail_if_not_found)
4760unset(_vtk_module_find_package_enabled)
4761unset(_vtk_module_find_package_required)\n\n")
4763 if (_vtk_export_module_build_content)
4764 string(APPEND _vtk_export_build_content
4765 "${_vtk_export_module_prelude}${_vtk_export_module_build_content}${_vtk_export_module_trailer}")
4767 if (_vtk_export_module_install_content)
4768 string(APPEND _vtk_export_install_content
4769 "${_vtk_export_module_prelude}${_vtk_export_module_install_content}${_vtk_export_module_trailer}")
4773 set(_vtk_export_trailer
4774 "unset(_vtk_module_find_package_components)
4775unset(_vtk_module_find_package_components_required)
4776unset(_vtk_module_find_package_quiet)\n")
4778 set(_vtk_export_build_file
4779 "${CMAKE_BINARY_DIR}/${_vtk_export_CMAKE_DESTINATION}/${_vtk_export_FILE_NAME}")
4780 set(_vtk_export_install_file
4781 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_vtk_export_FILE_NAME}.install")
4782 if (_vtk_export_build_content)
4783 file(WRITE "${_vtk_export_build_file}"
4784 "${_vtk_export_prelude}${_vtk_export_build_content}${_vtk_export_trailer}")
4786 file(WRITE "${_vtk_export_build_file}" "")
4788 if (_vtk_export_install_content)
4789 file(WRITE "${_vtk_export_install_file}"
4790 "${_vtk_export_prelude}${_vtk_export_install_content}${_vtk_export_trailer}")
4792 file(WRITE "${_vtk_export_install_file}" "")
4796 FILES "${_vtk_export_install_file}"
4797 DESTINATION "${_vtk_export_CMAKE_DESTINATION}"
4798 RENAME "${_vtk_export_FILE_NAME}"
4799 COMPONENT "${_vtk_export_COMPONENT}")
4803@page module-overview
4806@section module-third-party Third party support
4808The module system acknowledges that third party support is a pain and offers
4809APIs to help wrangle them. Sometimes third party code needs a shim introduced
4810to make it behave better, so an `INTERFACE` library to add that in is very
4811useful. Other times, third party code is hard to ensure that it exists
4812everywhere, so it is bundled. When that happens, the ability to select between
4813the bundled copy and an external copy is useful. All three (and more) of these
4816The following functions are used to handle third party modules:
4818 - @ref vtk_module_third_party
4819 - @ref vtk_module_third_party_external
4820 - @ref vtk_module_third_party_internal
4825@brief Third party module
4827When a project has modules which represent third party packages, there are some
4828convenience functions to help deal with them. First, there is the meta-wrapper:
4831vtk_module_third_party(
4832 [INTERNAL <internal arguments>...]
4833 [EXTERNAL <external arguments>...])
4836This offers a cache variable named `VTK_MODULE_USE_EXTERNAL_<module name>` that
4837may be set to trigger between the internal copy and an externally provided
4838copy. This is available as a local variable named
4839`VTK_MODULE_USE_EXTERNAL_<library name>`. See the
4840@ref vtk_module_third_party_external and @ref vtk_module_third_party_internal
4841functions for the arguments supported by the `EXTERNAL` and `INTERNAL`
4842arguments, respectively.
4844function (vtk_module_third_party)
4845 cmake_parse_arguments(PARSE_ARGV 0 _vtk_third_party
4848 "INTERNAL;EXTERNAL")
4850 if (_vtk_third_party_UNPARSED_ARGUMENTS)
4852 "Unparsed arguments for vtk_module_third_party: "
4853 "${_vtk_third_party_UNPARSED_ARGUMENTS}")
4856 string(REPLACE "::" "_" _vtk_build_module_safe "${_vtk_build_module}")
4857 option("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}"
4858 "Use externally provided ${_vtk_build_module}"
4859 "${_vtk_build_USE_EXTERNAL}")
4860 mark_as_advanced("VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}")
4861 get_property(_vtk_third_party_library_name GLOBAL
4862 PROPERTY "_vtk_module_${_vtk_build_module}_library_name")
4863 set("VTK_MODULE_USE_EXTERNAL_${_vtk_third_party_library_name}"
4864 "${VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe}}"
4867 if (VTK_MODULE_USE_EXTERNAL_${_vtk_build_module_safe})
4868 vtk_module_third_party_external(${_vtk_third_party_EXTERNAL})
4870 # Bubble up variables again.
4871 foreach (_vtk_third_party_variable IN LISTS _vtk_third_party_variables)
4872 set("${_vtk_third_party_variable}"
4873 "${${_vtk_third_party_variable}}"
4877 set(_vtk_third_party_has_external_support 1)
4878 vtk_module_third_party_internal(${_vtk_third_party_INTERNAL})
4884@brief Mark a module as being third party
4886Mark a module as being a third party module.
4889_vtk_module_mark_third_party(<target>)
4892function (_vtk_module_mark_third_party target)
4893 # TODO: `_vtk_module_set_module_property` instead.
4894 set_target_properties("${target}"
4896 "INTERFACE_vtk_module_exclude_wrap" 1
4897 "INTERFACE_vtk_module_third_party" 1)
4902@brief External third party package
4904A third party dependency may be expressed as a module using this function.
4905Third party packages are found using CMake's `find_package` function. It is
4906highly recommended that imported targets are used to make usage easier. The
4907module itself will be created as an `INTERFACE` library which exposes the
4911vtk_module_third_party_external(
4914 [COMPONENTS <component>...]
4915 [OPTIONAL_COMPONENTS <component>...]
4916 [TARGETS <target>...]
4917 [INCLUDE_DIRS <path-or-variable>...]
4918 [LIBRARIES <target-or-variable>...]
4919 [DEFINITIONS <variable>...]
4920 [FORWARD_VERSION_REQ <MAJOR|MINOR|PATCH|EXACT>]
4921 [VERSION_VAR <version-spec>]
4922 [USE_VARIABLES <variable>...]
4924 [STANDARD_INCLUDE_DIRS])
4927Only the `PACKAGE` argument is required. The arguments are as follows:
4929 * `PACKAGE`: (Required) The name of the package to find.
4930 * `VERSION`: If specified, the minimum version of the dependency that must be
4932 * `COMPONENTS`: The list of components to request from the package.
4933 * `OPTIONAL_COMPONENTS`: The list of optional components to request from the
4935 * `TARGETS`: The list of targets to search
for when
using this package.
4936 Targets which
do not exist will be ignored to support different versions of
4937 a package
using different
target names.
4938 * `STANDARD_INCLUDE_DIRS`: If present, standard include directories will be
4939 added to the module
target. This is usually only required
if both
internal
4940 and external are supported
for a given dependency.
4941 * `INCLUDE_DIRS`: If specified,
this is added as a `SYSTEM INTERFACE` include
4942 directory
for the
target. If a variable name is given, it will be
4944 * `LIBRARIES`: The libraries to link from the package. If a variable name is
4945 given, it will be dereferenced, however a warning that imported targets are
4946 not being used will be emitted.
4947 * `DEFINITIONS`: If specified, the given variables will be added to the
4948 target compile definitions interface.
4949 * `CONFIG_MODE`: Force `CONFIG` mode.
4950 * `FORWARD_VERSION_REQ` and `VERSION_VAR`: See documentation
for
4952 * `USE_VARIABLES`: List of variables from the `find_package` to make
4953 available to the caller.
4956 cmake_parse_arguments(PARSE_ARGV 0 _vtk_third_party_external
4957 "STANDARD_INCLUDE_DIRS;CONFIG_MODE"
4958 "VERSION;PACKAGE;FORWARD_VERSION_REQ;VERSION_VAR"
4959 "COMPONENTS;OPTIONAL_COMPONENTS;LIBRARIES;INCLUDE_DIRS;DEFINITIONS;TARGETS;USE_VARIABLES")
4961 if (_vtk_third_party_external_UNPARSED_ARGUMENTS)
4963 "Unparsed arguments for vtk_module_third_party_external: "
4964 "${_vtk_third_party_external_UNPARSED_ARGUMENTS}")
4967 get_property(_vtk_third_party_external_is_third_party GLOBAL
4968 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
4969 if (NOT _vtk_third_party_external_is_third_party)
4971 "The ${_vtk_build_module} has not been declared as a third party
"
4975 if (NOT DEFINED _vtk_third_party_external_PACKAGE)
4977 "The `PACKAGE` argument is required.
")
4980 set(_vtk_third_party_external_args)
4981 if (DEFINED _vtk_third_party_external_FORWARD_VERSION_REQ)
4982 list(APPEND _vtk_third_party_external_args
4983 FORWARD_VERSION_REQ "${_vtk_third_party_external_FORWARD_VERSION_REQ}
")
4985 if (DEFINED _vtk_third_party_external_VERSION_VAR)
4986 list(APPEND _vtk_third_party_external_args
4987 VERSION_VAR "${_vtk_third_party_external_VERSION_VAR}
")
4990 if (_vtk_third_party_external_TARGETS)
4991 set(_vtk_third_party_external_config_mode)
4992 if (_vtk_third_party_external_CONFIG_MODE)
4993 set(_vtk_third_party_external_config_mode "CONFIG_MODE
")
4996 # If we have targets, they must be exported to the install as well.
4997 vtk_module_find_package(
4998 PACKAGE "${_vtk_third_party_external_PACKAGE}
"
4999 VERSION "${_vtk_third_party_external_VERSION}
"
5000 COMPONENTS ${_vtk_third_party_external_COMPONENTS}
5001 OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS}
5002 ${_vtk_third_party_external_config_mode}
5003 ${_vtk_third_party_external_args})
5005 set(_vtk_third_party_external_config)
5006 if (_vtk_third_party_external_CONFIG_MODE)
5007 set(_vtk_third_party_external_config "CONFIG
")
5010 # If there are no targets, the install uses strings and therefore does not
5011 # need to find the dependency again.
5012 find_package("${_vtk_third_party_external_PACKAGE}
"
5013 ${_vtk_third_party_external_VERSION}
5014 ${_vtk_third_party_external_config}
5015 COMPONENTS ${_vtk_third_party_external_COMPONENTS}
5016 OPTIONAL_COMPONENTS ${_vtk_third_party_external_OPTIONAL_COMPONENTS})
5019 get_property(_vtk_third_party_external_target_name GLOBAL
5020 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
")
5022 # Check if an imported target of the same name already exists.
5023 set(_vtk_third_party_external_real_target_name
5024 "${_vtk_third_party_external_target_name}
")
5025 set(_vtk_third_party_external_using_mangled_name OFF)
5026 if (TARGET "${_vtk_third_party_external_target_name}
")
5027 # Ensure that the target collision comes from an imported target.
5028 get_property(_vtk_third_party_external_is_imported
5029 TARGET "${_vtk_third_party_external_target_name}
"
5031 if (NOT _vtk_third_party_external_is_imported)
5033 "It appears as though there is a conflicting
target named
"
5034 "`${_vtk_third_party_external_target_name}` expected to be used by
"
5035 "the `${_vtk_build_module}` module already added to the build. This
"
5036 "conflicts with the
target name expected to be used by an external
"
5037 "third party dependency.
")
5040 # If it does, we need to have a module name that is not the same as this
5041 # one. Error out if this is detected.
5042 if (_vtk_build_module STREQUAL _vtk_third_party_external_target_name)
5044 "An imported
target has the same
name used by the module system
for "
5045 "the facade of the external dependency
for `${_vtk_build_module}`.
"
5046 "This module must be either renamed or placed into a
namespace.
")
5049 # Mangle the internal name. The alias is the expected use case anyways and
5050 # since this is an INTERFACE target, there's nothing to break with respect
5051 # to `make $target` anyways.
5052 string(APPEND _vtk_third_party_external_real_target_name
5053 "_vtk_module_mangle
")
5054 set_property(GLOBAL APPEND_STRING
5055 PROPERTY "_vtk_module_${_vtk_build_module}_target_name
"
5056 "_vtk_module_mangle
")
5057 set(_vtk_third_party_external_using_mangled_name ON)
5060 add_library("${_vtk_third_party_external_real_target_name}
" INTERFACE)
5061 if (_vtk_third_party_external_using_mangled_name)
5062 set_property(TARGET "${_vtk_third_party_external_real_target_name}
"
5064 EXPORT_NAME "${_vtk_third_party_external_target_name}
")
5066 if (NOT _vtk_build_module STREQUAL _vtk_third_party_external_target_name)
5067 add_library("${_vtk_build_module}
" ALIAS
5068 "${_vtk_third_party_external_real_target_name}
")
5071 if (_vtk_third_party_external_STANDARD_INCLUDE_DIRS)
5072 _vtk_module_standard_includes(TARGET "${_vtk_third_party_external_real_target_name}
"
5076 # Try to use targets if they're specified and available.
5077 set(_vtk_third_party_external_have_targets FALSE)
5078 set(_vtk_third_party_external_used_targets FALSE)
5079 if (_vtk_third_party_external_TARGETS)
5080 set(_vtk_third_party_external_have_targets TRUE)
5081 foreach (_vtk_third_party_external_target IN LISTS _vtk_third_party_external_TARGETS)
5082 if (TARGET "${_vtk_third_party_external_target}
")
5083 target_link_libraries("${_vtk_third_party_external_real_target_name}
"
5085 "${_vtk_third_party_external_target}
")
5086 set(_vtk_third_party_external_used_targets TRUE)
5091 if (NOT _vtk_third_party_external_used_targets)
5092 if (NOT _vtk_third_party_external_have_targets)
5094 "A third party dependency
for ${_vtk_build_module} was found externally
"
5095 "using paths rather than targets; it is recommended to use imported
"
5096 "targets rather than find_library and such.
")
5099 set(_vtk_third_party_external_have_includes FALSE)
5100 foreach (_vtk_third_party_external_include_dir IN LISTS _vtk_third_party_external_INCLUDE_DIRS)
5101 if (DEFINED "${_vtk_third_party_external_include_dir}
")
5102 if (${_vtk_third_party_external_include_dir})
5103 set(_vtk_third_party_external_have_includes TRUE)
5105 target_include_directories("${_vtk_third_party_external_real_target_name}
" SYSTEM
5106 INTERFACE "${${_vtk_third_party_external_include_dir}}
")
5110 if (_vtk_third_party_external_have_targets AND
5111 NOT _vtk_third_party_external_have_includes)
5113 "A third party dependency
for ${_vtk_build_module} has external targets
"
5114 "which were not found and no `INCLUDE_DIRS` were found either.
"
5115 "Including
this module may not work.
")
5118 foreach (_vtk_third_party_external_define IN LISTS _vtk_third_party_external_DEFINITIONS)
5119 if (DEFINED "${_vtk_third_party_external_define}
")
5120 target_compile_definitions("${_vtk_third_party_external_real_target_name}
"
5121 INTERFACE "${${_vtk_third_party_external_define}}
")
5125 set(_vtk_third_party_external_have_libraries FALSE)
5126 foreach (_vtk_third_party_external_library IN LISTS _vtk_third_party_external_LIBRARIES)
5127 if (DEFINED "${_vtk_third_party_external_library}
")
5128 if (${_vtk_third_party_external_library})
5129 set(_vtk_third_party_external_have_libraries TRUE)
5131 target_link_libraries("${_vtk_third_party_external_real_target_name}
"
5132 INTERFACE "${${_vtk_third_party_external_library}}
")
5136 if (_vtk_third_party_external_have_targets AND
5137 NOT _vtk_third_party_external_have_libraries)
5139 "A third party dependency
for ${_vtk_build_module} has external targets
"
5140 "which were not found and no `LIBRARIES` were found either. Linking to
"
5141 "this this module may not work.
")
5145 if (DEFINED _vtk_third_party_external_USE_VARIABLES)
5146 # If we're called from `vtk_module_third_party`, the variables need bubbled
5148 if (DEFINED _vtk_third_party_EXTERNAL)
5149 set(_vtk_third_party_variables
5150 "${_vtk_third_party_external_USE_VARIABLES}
"
5154 foreach (_vtk_third_party_external_variable IN LISTS _vtk_third_party_external_USE_VARIABLES)
5155 if (NOT DEFINED "${_vtk_third_party_external_variable}
")
5157 "The variable `${_vtk_third_party_external_variable}` was expected
"
5158 "to have been available, but was not defined.
")
5161 set("${_vtk_third_party_external_variable}
"
5162 "${${_vtk_third_party_external_variable}}
"
5167 _vtk_module_mark_third_party("${_vtk_third_party_external_real_target_name}
")
5168 _vtk_module_install("${_vtk_third_party_external_real_target_name}
")
5173@brief Internal third party package
5175Third party modules may also be bundled with the project itself. In this case,
5176it is an internal third party dependency. The dependency is assumed to be in a
5177subdirectory that will be used via `add_subdirectory`. Unless it is marked as
5178`HEADERS_ONLY`, it is assumed that it will create a target with the name of the
5182vtk_module_third_party_internal(
5183 [SUBDIRECTORY <path>]
5184 [HEADERS_SUBDIR <subdir>]
5185 [LICENSE_FILES <file>...]
5189 [STANDARD_INCLUDE_DIRS])
5192All arguments are optional, however warnings are emitted if `LICENSE_FILES` or
5193`VERSION` is not specified. They are as follows:
5195 * `SUBDIRECTORY`: (Defaults to the library name of the module) The
5196 subdirectory containing the `CMakeLists.txt` for the dependency.
5197 * `HEADERS_SUBDIR`: If non-empty, the subdirectory to use for installing
5199 * `LICENSE_FILES`: A list of license files to install for the dependency. If
5200 not given, a warning will be emitted.
5201 * `VERSION`: The version of the library that is included.
5202 * `HEADER_ONLY`: The dependency is header only and will not create a target.
5203 * `INTERFACE`: The dependency is an `INTERFACE` library.
5204 * `STANDARD_INCLUDE_DIRS`: If present, module-standard include directories
5205 will be added to the module target.
5207function (vtk_module_third_party_internal)
5208 # TODO: Support scanning for third-party modules which don't support an
5211 cmake_parse_arguments(PARSE_ARGV 0 _vtk_third_party_internal
5212 "INTERFACE;HEADER_ONLY;STANDARD_INCLUDE_DIRS
"
5213 "SUBDIRECTORY;HEADERS_SUBDIR;VERSION
"
5216 if (_vtk_third_party_internal_UNPARSED_ARGUMENTS)
5219 "${_vtk_third_party_internal_UNPARSED_ARGUMENTS}
")
5222 get_property(_vtk_third_party_internal_is_third_party GLOBAL
5223 PROPERTY "_vtk_module_${_vtk_build_module}_third_party
")
5224 if (NOT _vtk_third_party_internal_is_third_party)
5226 "The ${_vtk_build_module} has not been declared as a third party
"
5230 get_property(_vtk_third_party_internal_library_name GLOBAL
5231 PROPERTY "_vtk_module_${_vtk_build_module}_library_name
")
5232 if (NOT DEFINED _vtk_third_party_internal_SUBDIRECTORY)
5233 set(_vtk_third_party_internal_SUBDIRECTORY "${_vtk_third_party_internal_library_name}
")
5236 if (NOT DEFINED _vtk_third_party_internal_LICENSE_FILES)
5238 "The ${_vtk_build_module} third party
package is embedded, but does not "
5239 "specify any license files.")
5242 if (NOT DEFINED _vtk_third_party_internal_VERSION)
5244 "The ${_vtk_build_module} third party package is embedded, but does not "
5245 "specify the version it is based on.")
5248 get_property(_vtk_third_party_internal_target_name GLOBAL
5249 PROPERTY "_vtk_module_${_vtk_build_module}_target_name")
5250 set(_vtk_third_party_internal_include_type)
5251 if (_vtk_third_party_internal_INTERFACE)
5252 set(_vtk_third_party_internal_include_type INTERFACE)
5253 elseif (_vtk_third_party_internal_HEADER_ONLY)
5254 add_library("${_vtk_third_party_internal_target_name}" INTERFACE)
5255 if (NOT _vtk_build_module STREQUAL _vtk_third_party_internal_target_name)
5256 add_library("${_vtk_build_module}" ALIAS
5257 "${_vtk_third_party_internal_target_name}")
5259 set(_vtk_third_party_internal_include_type INTERFACE)
5260 set(_vtk_third_party_internal_STANDARD_INCLUDE_DIRS 1)
5263 add_subdirectory("${_vtk_third_party_internal_SUBDIRECTORY}")
5265 if (NOT TARGET "${_vtk_build_module}")
5267 "The ${_vtk_build_module} is being built as an internal third party "
5268 "library, but a matching target was not created.")
5271 if (_vtk_third_party_internal_STANDARD_INCLUDE_DIRS)
5272 _vtk_module_standard_includes(
5273 TARGET "${_vtk_third_party_internal_target_name}"
5274 SYSTEM ${_vtk_third_party_internal_include_type}
5275 HEADERS_DESTINATION "${_vtk_build_HEADERS_DESTINATION}/${_vtk_third_party_internal_HEADERS_SUBDIR}")
5278 _vtk_module_apply_properties("${_vtk_third_party_internal_target_name}")
5279 if (_vtk_third_party_internal_INTERFACE)
5281 elseif (_vtk_third_party_internal_HEADER_ONLY)
5282 _vtk_module_install("${_vtk_third_party_internal_target_name}")
5285 if (_vtk_third_party_internal_LICENSE_FILES)
5286 set(_vtk_third_party_internal_license_component "license")
5287 if (_vtk_build_TARGET_SPECIFIC_COMPONENTS)
5288 string(PREPEND _vtk_third_party_internal_license_component "${_vtk_build_module}-")
5291 FILES ${_vtk_third_party_internal_LICENSE_FILES}
5292 DESTINATION "${_vtk_build_LICENSE_DESTINATION}/${_vtk_third_party_internal_library_name}/"
5293 COMPONENT "${_vtk_third_party_internal_license_component}")
5296 _vtk_module_mark_third_party("${_vtk_third_party_internal_target_name}")
function _vtk_module_target_function(prefix)
Generate arguments for target function wrappers.
function _vtk_private_kit_link_target(module)
Manage the private link target for a module.
function _vtk_module_apply_properties(target)
Apply properties to a module.
function _vtk_module_real_target(var, module)
The real target for a module.
function _vtk_module_export_properties()
Export properties on modules and targets.
function _vtk_module_debug(domain, format)
Conditionally output debug statements.
macro vtk_module_find_package()
Find a package.
function vtk_module_link(module)
Add link libraries to a module.
function vtk_module_third_party_internal()
Internal third party package.
function vtk_module_definitions(module)
Add compile definitions to a module.
function vtk_module_include(module)
Add include directories to a module.
function vtk_module_scan()
Scan modules and kits.
function vtk_module_depend(module)
Add dependencies to a module.
function vtk_module_third_party_external()
External third party package.
function vtk_module_build()
Build modules and kits.
function vtk_module_compile_options(module)
Add compile options to a module.
function vtk_module_autoinit()
Linking to autoinit-using modules.
function vtk_module_install_headers()
Install headers.
function vtk_module_add_module(name)
Create a module library.
function vtk_module_compile_features(module)
Add compile features to a module.
function vtk_module_link_options(module)
Add link options to a module.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
#define VTK_MODULE_AUTOINIT
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)