How to command line build a proper dmg from a Qt app

I have Qt app lets say MyApp with a list of libraries it links to. Note that all libraries are linked statically linked. I have a master project file called MyMasterProjectFile.pro which loads all of these into QtCreator and yes the whole code builds well from QtCreator. I am using Qt 5.9.4 commercial version.

I want to build my app+libraries command line into a dmg for MacOS High Sierra. I am doing this support CI builds on my build system.

So, following is what my script does:

// MyBuildScript.sh
BuildDMGForMacOS() {

    /path/to/qmake MyMasterProjectFile.pro -spec macx-clang CONFIG+=Release CONFIG+=x86_64 $EXTRA_SETTINGS CONFIG+=qml_debug
    make -j2

    // Go inside the directory where my main app build folder is created
    /path/to/macdeployqt MyApp.app -verbose=2 -dmg
}

Issue:
The dmg that is generated is not correct. But this is because if I double click and try to run the .app that is generated, I get the following error

You can’t open the application “MyApp.app” because it is not supported on this type of Mac.

This build script anyways builds a dmg and a .app which does not work.

If I open BuildFolder/MyApp/MyApp.app/Contents/MacOS/MyApp then it complains the following on console and gives up with a crash

QQmlApplicationEngine failed to load component
qrc:/qml/main.qml:1 module "QtQuick" is not installed
qrc:/qml/main.qml:4 module "QtWebView" is not installed
qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
qrc:/qml/main.qml:1 module "QtQuick" is not installed
qrc:/qml/main.qml:4 module "QtWebView" is not installed
qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
qrc:/qml/main.qml:1 module "QtQuick" is not installed
qrc:/qml/main.qml:4 module "QtWebView" is not installed
qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
qrc:/qml/main.qml:1 module "QtQuick" is not installed
qrc:/qml/main.qml:4 module "QtWebView" is not installed
qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed

[1]    57951 segmentation fault  /Volumes/MyApp/MyApp.app/Contents/MacOS/MyApp

Note:
Note that the dmg will be installed on OSX machines which wont have Qt installed on them.