aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake2
-rw-r--r--src/qml/Qt6QmlMacros.cmake20
-rw-r--r--src/qmltyperegistrar/qmltyperegistrar.cpp12
-rw-r--r--src/qmltyperegistrar/qmltypes.prf4
4 files changed, 38 insertions, 0 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index a9b20235ad..d25c987fc9 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -42,6 +42,7 @@ function(qt_internal_add_qml_module target)
OPTIONAL_IMPORTS
TYPEINFO
DEPENDENCIES
+ PAST_MAJOR_VERSIONS
)
qt_parse_all_arguments(arg "qt_add_qml_module"
@@ -143,6 +144,7 @@ function(qt_internal_add_qml_module target)
TARGET_PATH ${arg_TARGET_PATH}
URI ${arg_URI}
VERSION ${arg_VERSION}
+ PAST_MAJOR_VERSIONS ${arg_PAST_MAJOR_VERSIONS}
QML_FILES ${arg_QML_FILES}
IMPORTS "${arg_IMPORTS}"
OPTIONAL_IMPORTS "${arg_OPTIONAL_IMPORTS}"
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index c6b11d5ba1..51fe4cac14 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -41,6 +41,9 @@
# DEPENDENCIES: List of QML Module dependencies and their versions. The module
# and its version must be separated via a slash(/). E.g. QtQuick/2.0
#
+# PAST_MAJOR_VERSIONS: List of past major versions this QML module was available
+# in. Ensures that the module can be imported when using these major versions.
+#
# QML_FILES: List of Qml files. See qt6_target_qml_files for more information
# on how to specify additional properties on qml files. (OPTIONAL)
#
@@ -117,6 +120,7 @@ function(qt6_add_qml_module target)
IMPORTS
OPTIONAL_IMPORTS
DEPENDENCIES
+ PAST_MAJOR_VERSIONS
)
cmake_parse_arguments(arg
@@ -439,6 +443,10 @@ function(qt6_add_qml_module target)
endif()
endif()
+ if (arg_PAST_MAJOR_VERSIONS)
+ set_target_properties(${target} PROPERTIES QT_QML_PAST_MAJOR_VERSIONS "${arg_PAST_MAJOR_VERSIONS}")
+ endif()
+
# Generate meta types data
if (arg_GENERATE_QMLTYPES)
qt6_qml_type_registration(${target})
@@ -664,6 +672,18 @@ function(qt6_qml_type_registration target)
--minor-version=${minor_version}
)
+ # Add past minor versions
+ get_target_property(past_major_versions ${target} QT_QML_PAST_MAJOR_VERSIONS)
+
+ if (past_major_versions OR past_major_versions STREQUAL "0")
+ foreach (past_major_version ${past_major_versions})
+ list(APPEND cmd_args
+ --past-major-version ${past_major_version}
+ )
+ endforeach()
+ endif()
+
+
# Run a script to recursively evaluate all the metatypes.json files in order
# to collect all foreign types.
string(TOLOWER "${target}_qmltyperegistrations.cpp" type_registration_cpp_file_name)
diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp
index bf3c4c94d4..07d7955727 100644
--- a/src/qmltyperegistrar/qmltyperegistrar.cpp
+++ b/src/qmltyperegistrar/qmltyperegistrar.cpp
@@ -106,6 +106,12 @@ int main(int argc, char **argv)
importNameOption.setValueName(QStringLiteral("module name"));
parser.addOption(importNameOption);
+ QCommandLineOption pastMajorVersionOption(QStringLiteral("past-major-version"));
+ pastMajorVersionOption.setDescription(QStringLiteral("Past major version to use for type and module "
+ "registrations."));
+ pastMajorVersionOption.setValueName(QStringLiteral("past major version"));
+ parser.addOption(pastMajorVersionOption);
+
QCommandLineOption majorVersionOption(QStringLiteral("major-version"));
majorVersionOption.setDescription(QStringLiteral("Major version to use for type and module "
"registrations."));
@@ -188,8 +194,14 @@ int main(int argc, char **argv)
fprintf(output, "void %s()\n{", qPrintable(functionName));
const auto majorVersion = parser.value(majorVersionOption);
+ const auto pastMajorVersions = parser.values(pastMajorVersionOption);
const auto minorVersion = parser.value(minorVersionOption);
+ for (const auto &version : pastMajorVersions) {
+ fprintf(output, "\n qmlRegisterModule(\"%s\", %s, 0);\n qmlRegisterModule(\"%s\", %s, 254);",
+ qPrintable(module), qPrintable(version), qPrintable(module), qPrintable(version));
+ }
+
if (minorVersion.toInt() != 0) {
fprintf(output, "\n qmlRegisterModule(\"%s\", %s, 0);",
qPrintable(module), qPrintable(majorVersion));
diff --git a/src/qmltyperegistrar/qmltypes.prf b/src/qmltyperegistrar/qmltypes.prf
index e02d425f2a..0b857ad099 100644
--- a/src/qmltyperegistrar/qmltypes.prf
+++ b/src/qmltyperegistrar/qmltypes.prf
@@ -63,6 +63,10 @@ QML_TYPEREGISTRAR_FLAGS = \
--minor-version=$$QML_IMPORT_MINOR_VERSION \
--foreign-types=$$join(QML_FOREIGN_METATYPES, ',')
+!isEmpty(QML_PAST_MAJOR_VERSIONS) {
+ for(past_major_version,QML_PAST_MAJOR_VERSIONS): QML_TYPEREGISTRAR_FLAGS += --past-major-version $$past_major_version
+}
+
!isEmpty(MODULE_PRIVATE_INCLUDES): QML_TYPEREGISTRAR_FLAGS += --private-includes
METATYPES_JSON = $${TARGET_BASENAME}_metatypes.json