Actually I was able to make CPack work with https://doc.qt.io/qt-6/qt-generate-deploy-qml-app-script.html by adding set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") and then setting CMAKE_INSTALL_PREFIX to /opt/myApplication .
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
CMAKE_INSTALL_PREFIX
/opt/myApplication