qt5base-lts/mkspecs/features/qml_module.prf
Andy Shaw c808a6978b Add a means to handle dynamically created qmldir files
This will enable modules like QtWebView which needs to generate its
qmldir at qmake time since it changes depending on whether QtWebEngine
is available or not. This ensures that it is not created in the sources
directory and in the build directory and correctly picked up.

Task-number: QTBUG-65092
Change-Id: Iac628b97145d29778f554510e8e07102d588df64
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2019-03-20 08:37:59 +00:00

77 lines
2.2 KiB
Plaintext

#
# W A R N I N G
# -------------
#
# This file is not part of the Qt API. It exists purely as an
# implementation detail. It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#
equals(TEMPLATE, app): TEMPLATE = aux
isEmpty(TARGETPATH): error("Must set TARGETPATH (QML import name)")
!isEmpty(DYNAMIC_QMLDIR) {
qmldir_path = $$OUT_PWD
write_file($${qmldir_path}/qmldir, DYNAMIC_QMLDIR)|error("Aborting.")
} else {
qmldir_path = $$_PRO_FILE_PWD_
}
qmldir_file = $${qmldir_path}/qmldir
fq_qml_files =
for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
fq_aux_qml_files =
for(qmlf, AUX_QML_FILES): fq_aux_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
load(qt_build_paths)
DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
static: \
CONFIG += builtin_resources
else: \
CONFIG += install_qml_files
builtin_resources {
URITARGET = $$replace(URI, "\\.", "_")
# In static builds, the QML engine reads also the qmldir file from the resources.
static: $${URITARGET}.files = $$qmldir_file
# Ensure the QML files are included in the resources.
$${URITARGET}.files += $$fq_qml_files
# qt-project.org/imports is the path used for locating imports inside the resources
$${URITARGET}.prefix = /qt-project.org/imports/$$TARGETPATH
RESOURCES += $${URITARGET}
}
# Install rules
qmldir.base = $$qmldir_path
# Tools need qmldir and plugins.qmltypes always installed on the file system
qmldir.files = $$qmldir_file
install_qml_files: qmldir.files += $$fq_qml_files
qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH
INSTALLS += qmldir
qmlfiles.base = $$_PRO_FILE_PWD_
qmlfiles.files = $$fq_aux_qml_files
install_qml_files: qmlfiles.files += $$fq_qml_files
qmlfiles.path = $${qmldir.path}
INSTALLS += qmlfiles
!debug_and_release|!build_all|CONFIG(release, debug|release) {
!prefix_build {
COPIES += qmldir
} else {
# For non-installed static builds, tools need qmldir and plugins.qmltypes
# files in the build dir
qmldir2build.files = $$qmldir_file $$fq_aux_qml_files
qmldir2build.path = $$DESTDIR
COPIES += qmldir2build
}
}