aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlMacros.cmake
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-09-08 16:03:12 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-08 21:59:58 +0000
commit75bc0b8319442ee07d25929bbe56cb4e65e3fe4a (patch)
tree8d68c8a43cda65a4ce673c7bcb5ed9957b217f55 /src/qml/Qt6QmlMacros.cmake
parent7a70ebf952016dd5be344c8cba0b64df4641b9fc (diff)
Fix generation of names in qmldir files
Dots in QML module names are useless because you cannot instantiate a component with a dot in its name. We might as well strip all the extensions when adding components to a qmldir file. This takes care of .ui.qml as well. Furthermore, JavaScript files must not be listed because they cannot be instantiated as QML components. Change-Id: I9782420ea79fef1d5eedef97cf7a748b96ddbe2b Fixes: QTBUG-96301 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Tapani Mattila <tapani.mattila@qt.io> (cherry picked from commit 14a3b34906be5b749ebc6b6c1d8f6807fff8fd88) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r--src/qml/Qt6QmlMacros.cmake14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index d3f37e324d..a50d0342ab 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -1459,11 +1459,21 @@ function(qt6_target_qml_sources target)
if(NOT no_qmldir AND NOT skip_qmldir)
get_source_file_property(qml_file_typename ${qml_file_src} QT_QML_SOURCE_TYPENAME)
if (NOT qml_file_typename)
- get_filename_component(qml_file_typename ${qml_file_src} NAME_WLE)
+ get_filename_component(qml_file_ext ${qml_file_src} EXT)
+ if (NOT qml_file_ext STREQUAL ".js" AND NOT qml_file_ext STREQUAL ".mjs")
+ get_filename_component(qml_file_typename ${qml_file_src} NAME_WE)
+ endif()
endif()
# Do not add qmldir entries for lowercase names. Those are not components.
- if (qml_file_typename MATCHES "^[A-Z]")
+ if (qml_file_typename AND qml_file_typename MATCHES "^[A-Z]")
+ if (qml_file_ext AND NOT qml_file_ext STREQUAL ".qml" AND NOT qml_file_ext STREQUAL ".ui.qml")
+ message(AUTHOR_WARNING
+ "${qml_file_src} has a file extension different from .qml and .ui.qml. "
+ "This leads to unexpected component names."
+ )
+ endif()
+
# We previously accepted the singular form of this property name
# during tech preview. Issue a warning for that, but still
# honor it. The plural form will override it if both are set.