1#
2#  W A R N I N G
3#  -------------
4#
5# This file is not part of the Qt API.  It exists purely as an
6# implementation detail.  It may change from version to version
7# without notice, or even be removed.
8#
9# We mean it.
10#
11
12equals(TEMPLATE, app): TEMPLATE = aux
13
14isEmpty(TARGETPATH): error("Must set TARGETPATH (QML import name)")
15
16!isEmpty(DYNAMIC_QMLDIR) {
17    qmldir_path = $$OUT_PWD
18    write_file($${qmldir_path}/qmldir, DYNAMIC_QMLDIR)|error("Aborting.")
19} else {
20    qmldir_path = $$_PRO_FILE_PWD_
21}
22
23qmldir_file = $${qmldir_path}/qmldir
24
25fq_qml_files =
26for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
27
28fq_aux_qml_files =
29for(qmlf, AUX_QML_FILES): fq_aux_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
30
31load(qt_build_paths)
32
33DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
34
35static: \
36    CONFIG += builtin_resources
37else: \
38    CONFIG += install_qml_files
39
40builtin_resources {
41    URITARGET = $$replace(URI, "\\.", "_")
42    # In static builds, the QML engine reads also the qmldir file from the resources.
43    static: $${URITARGET}.files = $$qmldir_file
44    # Ensure the QML files are included in the resources.
45    $${URITARGET}.files += $$fq_qml_files
46    # qt-project.org/imports is the path used for locating imports inside the resources
47    $${URITARGET}.prefix = /qt-project.org/imports/$$TARGETPATH
48    RESOURCES += $${URITARGET}
49}
50
51# Install rules
52qmldir.base = $$qmldir_path
53qmldir.files = $$qmldir_file
54qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH
55
56qmlfiles.base = $$_PRO_FILE_PWD_
57qmlfiles.files = $$fq_aux_qml_files
58install_qml_files: qmlfiles.files += $$fq_qml_files
59qmlfiles.path = $${qmldir.path}
60
61INSTALL_QML_FILES = false
62
63android {
64    single_android_abi|build_pass {
65        isEmpty(ANDROID_ABIS): ANDROID_ABIS = $$ALL_ANDROID_ABIS
66        ABI = $$first(ANDROID_ABIS)
67        equals(ABI,  $$QT_ARCH): INSTALL_QML_FILES = true
68    }
69} else: !debug_and_release|!build_all|CONFIG(release, debug|release): INSTALL_QML_FILES = true
70
71equals(INSTALL_QML_FILES, true) {
72    INSTALLS += qmldir
73    INSTALLS += qmlfiles
74
75    !prefix_build {
76        COPIES += qmldir qmlfiles
77    } else {
78        # For non-installed static builds, tools need qmldir and plugins.qmltypes
79        # files in the build dir
80        qml2build.files = $$qmldir_file $$fq_aux_qml_files
81        qml2build.path = $$DESTDIR
82        COPIES += qml2build
83    }
84}
85