VTK module system links optional dependencies wrongly in PV with external VTK
Observed error:
CMake Error at D:/installed/x64-windows-static-md/share/vtk/VTK-targets.cmake:1119 (set_target_properties):
The link interface of target "VTK::pegtl" contains:
PEGTL::PEGTL
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
D:/installed/x64-windows-static-md/share/vtk/vtk-config.cmake:143 (include)
C:/a/1/s/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:65 (find_package)
Reason for PEGTL being linked: VTK::pegtl -> VTK::IOMotionFX
VTK::IOMotionFX
is an optional dependency in ParaView guarded by PARAVIEW_ENABLE_MOTIONFX
resulting in: CMake/ParaViewOptions.cmake(346): list(APPEND paraview_rejected_modules VTK::IOMotionFX )
disabling it for paraview and disableing the lookup of the corresponding VTK component.
However, the module system in VTK will link the target if it exists although it has been disabled. As such optional dependency can not be guarded by a if(TARGET)
they always need to be guarded by a variable since VTK always provides all targets independent of which COMPONENTS have been requested.