Installing Qt libraries on Linux

What I actually did was this… First, I worked backwards from the Qt5::Core target to find the directory where the Qt installation had been found:

get_property(QT_CORE_INCLUDE_DIRS TARGET Qt5::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
list(GET QT_CORE_INCLUDE_DIRS 0 QT_CORE_MAIN_INCLUDE_DIR)
get_filename_component(QT_MAIN_DIR ${QT_CORE_MAIN_INCLUDE_DIR}/.. ABSOLUTE)	

Then in the first instance I did what’s described here.

That didn’t quite get me out of the woods, though, because especially once I’d installed PySide2 as well and realised that people could now write scripts using any components of Qt, not just the ones I was using in my C++ application, I decided I’d better just go for it and install the whole Qt directory:

    install(DIRECTORY   ${QT_MAIN_DIR}/lib/
            DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
            USE_SOURCE_PERMISSIONS)    
    install(DIRECTORY   ${QT_MAIN_DIR}/plugins/imageformats/
            DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/qt/plugins/imageformats
            USE_SOURCE_PERMISSIONS) 
    install(DIRECTORY   ${QT_MAIN_DIR}/plugins/platforms/
            DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/qt/plugins/platforms
            USE_SOURCE_PERMISSIONS) 

This works nicely now.