aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlMacros.cmake
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-11-04 15:19:03 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2020-11-10 18:14:48 +0100
commita4d956048b4679bf5b448340d1f3428793699990 (patch)
treefd382c2b6cadb813ac1939bf8a6149beecb60b2e /src/qml/Qt6QmlMacros.cmake
parentd01ec7ebe3853faabc8843d169d288b4998bb209 (diff)
qmltyperegistrar: Add past-major-version option
Adds the option to specify past major versions of modules to be registered. This is necessary for modules that don't export any types themselves to work when built statically. Change-Id: I4b4a379f92707ec64cbb32f91db9d010440b95a2 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r--src/qml/Qt6QmlMacros.cmake20
1 files changed, 20 insertions, 0 deletions
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)