Yes there is, if you build VTK yourself then, for VTK 9+, there is this Python script FindNeededModules.py. This will look at your code and determine what modules are needed. To do this, it needs modules.json
found in your build directory. This is probably the best approach. It does mean that you have two sets of modules, one for VTK 9+ and one for the old version of VTK.
For example, for CylinderExample, running the above Python script will give you:
find_package(VTK
COMPONENTS
CommonColor
CommonCore
FiltersSources
RenderingCore
# These modules are suggested since they implement an existing module.
# Uncomment those you need.
# InteractionStyle # implements VTK::RenderingCore
# RenderingFreeType # implements VTK::RenderingCore
# RenderingOpenGL2 # implements VTK::RenderingCore
# RenderingUI # implements VTK::RenderingCore
)