Commit cf8d2a36 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

vtkModule: support optional dependencies

They are treated as private dependencies to incentivize not making
optional public dependencies.
parent 8b8da4c6
......@@ -102,6 +102,8 @@ supported:
using this module.
* `PRIVATE_DEPENDS`: A list of modules which are required by this module, but
not by those using this module.
* `OPTIONAL_DEPENDS`: A list of modules which are used by this module if
enabled; these are treated as `PRIVATE_DEPENDS` if they exist.
* `IMPLEMENTS`: A list of modules for which this module needs to register
with.
* `TEST_DEPENDS`: Modules required by the test suite for this module.
......@@ -128,7 +130,7 @@ macro (_vtk_module_parse_module_args name_output)
cmake_parse_arguments("${_name_NAME}"
"IMPLEMENTABLE;EXCLUDE_WRAP;THIRD_PARTY"
"NAME;KIT"
"GROUPS;DEPENDS;PRIVATE_DEPENDS;TEST_DEPENDS;TEST_LABELS;DESCRIPTION;CONDITION;IMPLEMENTS"
"GROUPS;DEPENDS;PRIVATE_DEPENDS;OPTIONAL_DEPENDS;TEST_DEPENDS;TEST_LABELS;DESCRIPTION;CONDITION;IMPLEMENTS"
${ARGN})
if (${_name_NAME}_UNPARSED_ARGUMENTS)
......@@ -473,6 +475,9 @@ function (vtk_module_scan)
set_property(GLOBAL
PROPERTY
"_vtk_module_${_vtk_scan_module_name}_private_depends" "${${_vtk_scan_module_name}_PRIVATE_DEPENDS}")
set_property(GLOBAL
PROPERTY
"_vtk_module_${_vtk_scan_module_name}_optional_depends" "${${_vtk_scan_module_name}_OPTIONAL_DEPENDS}")
set_property(GLOBAL
PROPERTY
"_vtk_module_${_vtk_scan_module_name}_test_depends" "${${_vtk_scan_module_name}_TEST_DEPENDS}")
......@@ -1055,15 +1060,23 @@ function (vtk_module_build)
PROPERTY "_vtk_module_${_vtk_build_module}_depends")
get_property("_vtk_build_${_vtk_build_module}_private_depends" GLOBAL
PROPERTY "_vtk_module_${_vtk_build_module}_private_depends")
get_property("_vtk_build_${_vtk_build_module}_optional_depends" GLOBAL
PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
set("_vtk_build_${_vtk_build_module}_all_depends"
${_vtk_build_${_vtk_build_module}_depends}
${_vtk_build_${_vtk_build_module}_private_depends})
${_vtk_build_${_vtk_build_module}_private_depends}
${_vtk_build_${_vtk_build_module}_optional_depends})
endforeach ()
set(_vtk_build_sorted_modules "${_vtk_build_MODULES}")
topological_sort(_vtk_build_sorted_modules "_vtk_build_" "_all_depends")
foreach (_vtk_build_module IN LISTS _vtk_build_sorted_modules)
list(FIND _vtk_build_MODULES "${_vtk_build_module}" _vtk_build_idx)
if (_vtk_build_idx EQUAL "-1")
continue ()
endif ()
if (TARGET "${_vtk_build_module}")
get_property(_vtk_build_is_imported
TARGET "${_vtk_build_module}"
......@@ -1778,6 +1791,22 @@ function (vtk_module_add_module name)
${_vtk_add_module_depends}
PRIVATE
${_vtk_add_module_private_depends})
get_property(_vtk_add_module_optional_depends GLOBAL
PROPERTY "_vtk_module_${_vtk_build_module}_optional_depends")
foreach (_vtk_add_module_optional_depend IN LISTS _vtk_add_module_optional_depends)
if (TARGET "${_vtk_add_module_optional_depend}")
set(_vtk_add_module_have_optional_depend 1)
target_link_libraries("${_vtk_add_module_real_target}"
PRIVATE
"${_vtk_add_module_optional_depend}")
else ()
set(_vtk_add_module_have_optional_depend 0)
endif ()
target_compile_definitions("${_vtk_add_module_real_target}"
PRIVATE
"VTK_MODULE_ENABLE_${_vtk_add_module_optional_depend}=${_vtk_add_module_have_optional_depend}")
endforeach ()
endif ()
_vtk_module_standard_includes(
${_vtk_add_module_includes_interface}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment