Building VTK with Qt support - VTK looks in the wrong place for qmlplugindump

I have installed Qt 5.15 via the official installer and not the package manager of my Xubuntu 20.04. According to cmake all the required cmake variables are set (Qt5_DIR, Qt5Core_DIR etc.).

The build goes without any issues up to the point when qmlplugindump is requested:

[100%] Built target qmlvtkplugin_autogen
[100%] Linking CXX shared module ../../../lib/qml/VTK.9.0/
Generating qmltypes file using qmlplugindump
/bin/sh: 1: /usr/bin/qmlplugindump: not found
make[2]: *** [GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/build.make:136: lib/qml/VTK.9.0/] Error 127
make[2]: *** Deleting file 'lib/qml/VTK.9.0/'
make[1]: *** [CMakeFiles/Makefile2:17327: GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

At first I got scared since I did have a previous Qt 5 installation (via the package manager) that I needed for QGIS. However nm gave me a piece of mind:

:~/BUILDS/VTK/build$ nm lib/ | grep 5.15
                 U qt_version_tag@@Qt_5.15

This means that the linking is done correctly however for some reason the building process attempts to execute qmlplugindump from the wrong path. The only qmlplugindump I have is in /opt/Qt/5.15.2/gcc_64/bin, which is also part of the Qt that I am using for the whole build.

Since I’m not familiar with VTK I’m reaching out to you hoping to resolve this. If it is an error in my environment - perfect. However if it is not, this would mean that the VTK build process is broken, when it comes to the Qt integration. This is why I tagged it as Development and not Support.

The location is attempted based on QtCore’s location, but we do find_program, so there is the QMLPLUGINDUMP_EXECUTABLE cache variable to select something new. You might need to remove the value from the cache to have it search again, but I’d guess you have a stale location from when you might have had a Qt5 there.

Yes, I found it and it works. However I don’t understand why it is not retrieved properly. I guess the issue here is the separation between libs and executables on a standard Linux installation. If you install Qt using the official installer normally it packs everything together in a folder. There is still a separation but the root folder is enough to deduce where each component is located.

AFAIK, Qt doesn’t give us a target to use and we have to find it ourselves. Hence the HINTS we pass based on the Qt5::Core target’s location. But, that’s only a guess and we are prone to finding a wrong one.