Install rules for external plugins in ParaView 5.7

I would like to have install rules for my external plugins, such that I can simply run cmake --build --target install and have the plugins installed into a directory, where ParaView automatically loads them (i.e., I set CMAKE_PREFIX_PATH to ParaView’s install directory).

In ParaView versions before 5.7, I used CMake code like

add_paraview_plugin(MyPlugin ...)
install(TARGETS MyPlugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins)

However, in ParaView 5.7, the paraview_add_plugin command already creates an install rule. For example,

paraview_plugin_build(
  PLUGINS ${my_plugins}
  LIBRARY_DESTINATION "${CMAKE_INSTALL_BINDIR}"
  LIBRARY_SUBDIRECTORY "plugins") 

would install a plugin MyPlugin into the directory bin/plugins/MyPlugin/Myplugin.so, and ParaView would not load this automatically, since it only seems to look for plugins in bin/plugins, but not in subdirectories.

My current workaround adds a second install rule

paraview_add_plugin(MyPlugin ...)
install(TARGETS MyPlugin DESTINATION ${CMAKE_INSTALL_BINDIR}/plugins)

but this would install the plugin twice.

paraview_plugin_build can also create a .plugins file, such as the one in lib/paraview-5.7/plugins, but as far as I know, there is no way to load such a file from an external location.

Is there an intended way to create install rules for external plugins?

Just use PV_PLUGIN_CONFIG_FILE env var.

https://www.paraview.org/Wiki/ParaView/Plugin_HowTo#Using_Plugins

How does ParaView find the plugin if it is just in that directory? AFAIK, ParaView doesn’t list the directory itself.

In any case, further work for better exporting plugins in underway in https://gitlab.kitware.com/paraview/paraview/merge_requests/3454. It won’t help with ParaView using external plugins so much (but will help clients wanting to use plugins from other packages a lot). Better installation of plugins is also in there, but mostly related to the find_package side of the installation.