aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmeta/CMakeLists.txt
blob: 473cf063cd95005b69872028cedd85b88cf8540b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

set(qmlmeta_imports
    QML/1.0
    QtQml.Models/auto
)

set(qmlmeta_public_dependencies
    Qt::Qml
    Qt::QmlModels
)

set(qmlmeta_private_dependencies
    Qt::QmlPrivate
    Qt::QmlModelsPrivate
)

if (QT_FEATURE_qml_worker_script)
    list(APPEND qmlmeta_imports
        QtQml.WorkerScript/auto
    )
    list(APPEND qmlmeta_public_dependencies
        Qt::QmlWorkerScript
    )
    list(APPEND qmlmeta_private_dependencies
        Qt::QmlWorkerScriptPrivate
    )
endif()

qt_internal_add_qml_module(QmlMeta
    URI "QtQml"
    VERSION "${PROJECT_VERSION}"
    DESIGNER_SUPPORTED
    PLUGIN_TARGET qmlplugin
    CLASS_NAME QtQmlPlugin
    PAST_MAJOR_VERSIONS 2
    IMPORTS
        ${qmlmeta_imports}
    SOURCES
        types/qqmlmetadependencies.cpp types/qqmlmetadependencies_p.h
        types/qqmlbind.cpp types/qqmlbind_p.h
        types/qqmlconnections.cpp types/qqmlconnections_p.h
        types/qqmlloggingcategory.cpp types/qqmlloggingcategory_p.h
    LIBRARIES
        ${qmlmeta_private_dependencies}
    PUBLIC_LIBRARIES
        ${qmlmeta_public_dependencies}
    PRIVATE_MODULE_INTERFACE
        ${qmlmeta_private_dependencies}
)

add_dependencies(QmlMeta BuiltinsOutput)

# Linking to the static qml plugin should also automatically link to the worker script
# static plugin otherwise you get errors like
#  module "QtQml.WorkerScript" plugin "workerscriptplugin" not found
#     import QtQuick 2.0
#     ^
if(QT_FEATURE_qml_worker_script)
    _qt_internal_add_qml_static_plugin_dependency(qmlplugin workerscriptplugin)
endif()

# Same for the QmlModels qml plugin, otherwise you get
#  module "QtQuick" version 6.6 cannot be imported because:
#  module "QtQml.Models" plugin "modelsplugin" not found
#     import QtQuick
#     ^
_qt_internal_add_qml_static_plugin_dependency(qmlplugin modelsplugin)

qt_internal_extend_target(QmlMeta CONDITION QT_FEATURE_qml_animation
    SOURCES
        types/qqmltimer.cpp types/qqmltimer_p.h
    INCLUDE_DIRECTORIES
        ../qml/animations
)

qt_internal_extend_target(QmlMeta CONDITION QT_FEATURE_qml_locale
    SOURCES
        types/qqmllocaleenums_p.h
)

# The Qml_sync_headers target doesn't exist when this CMakeLists is executed. So the qmlplugin
# plugin target misses the dependency on Qml_sync_headers target. This leads to the
# "unknown IID" issue when moc processes plugin sources, because of missing header aliases.
# Qml_sync_headers target is created later by the finalizer in the directory scope so we add this
# dependency manually instead of relying on qt_internal_add_qml_module logic. Same is applicable
# for the QmlMeta target.
set_property(TARGET qmlplugin APPEND PROPERTY AUTOGEN_TARGET_DEPENDS Qml_sync_headers)
set_property(TARGET QmlMeta APPEND PROPERTY AUTOGEN_TARGET_DEPENDS Qml_sync_headers)