aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-10-21 10:30:05 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-10-29 17:49:13 +0200
commit9cd3191d4eb42dbf7847ffccb178fe5402968464 (patch)
treea1eb1249a3b79dc25d2da811e46254d2ea025da4
parentc3999f96536ac359ba94d80755230e85238d578a (diff)
qt_add_qml_module: Add FOLLOW_FOREIGN_VERSIONING option
This option allows modules to follow the versioning scheme of their foreign base types when it comes to exposing revisioned properties. It is enabled it by default for our internal Qt modules. Task-number: QTBUG-91706 Change-Id: Ie2a660289d2b4c14800f3394321898eae3718425 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake6
-rw-r--r--src/qml/Qt6QmlMacros.cmake12
-rw-r--r--src/qml/doc/src/cmake/qt_add_qml_module.qdoc16
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml2
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml2
5 files changed, 36 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index bfc01b3cc0..ee535d51c9 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -9,6 +9,7 @@ macro(qt_internal_get_internal_add_qml_module_keywords
internal_option_args internal_single_args internal_multi_args)
set(${option_args}
DESIGNER_SUPPORTED
+ FOLLOW_FOREIGN_VERSIONING
NO_PLUGIN
NO_PLUGIN_OPTIONAL
NO_CREATE_PLUGIN_TARGET
@@ -290,6 +291,10 @@ function(qt_internal_add_qml_module target)
endif()
endforeach()
+ if (arg_FOLLOW_FOREIGN_VERSIONING)
+ message(FATAL_ERROR "Do not set FOLLOW_FOREIGN_VERSIONING for module ${target}. It is already set by default for internal modules.")
+ endif()
+
# Update the backing and plugin targets with qml-specific things.
qt6_add_qml_module(${target}
${add_qml_module_args}
@@ -297,6 +302,7 @@ function(qt_internal_add_qml_module target)
OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}
RESOURCE_PREFIX "/qt-project.org/imports"
OUTPUT_TARGETS output_targets
+ FOLLOW_FOREIGN_VERSIONING
)
if(output_targets)
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index f724646718..72500a3d57 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -9,6 +9,7 @@ function(qt6_add_qml_module target)
STATIC
SHARED
DESIGNER_SUPPORTED
+ FOLLOW_FOREIGN_VERSIONING
NO_PLUGIN
NO_PLUGIN_OPTIONAL
NO_CREATE_PLUGIN_TARGET
@@ -441,6 +442,7 @@ function(qt6_add_qml_module target)
QT_QML_MODULE_NO_GENERATE_QMLDIR "${arg_NO_GENERATE_QMLDIR}"
QT_QML_MODULE_NO_PLUGIN "${arg_NO_PLUGIN}"
QT_QML_MODULE_NO_PLUGIN_OPTIONAL "${arg_NO_PLUGIN_OPTIONAL}"
+ QT_QML_MODULE_FOLLOW_FOREIGN_VERSIONING "${arg_FOLLOW_FOREIGN_VERSIONING}"
QT_QML_MODULE_URI "${arg_URI}"
QT_QML_MODULE_TARGET_PATH "${arg_TARGET_PATH}"
QT_QML_MODULE_VERSION "${arg_VERSION}"
@@ -1927,6 +1929,16 @@ function(_qt_internal_qml_type_registration target)
--minor-version=${minor_version}
)
+
+ # Add --follow-foreign-versioning if requested
+ get_target_property(follow_foreign_versioning ${target} QT_QML_MODULE_FOLLOW_FOREIGN_VERSIONING)
+
+ if (follow_foreign_versioning)
+ list(APPEND cmd_args
+ --follow-foreign-versioning
+ )
+ endif()
+
# Add past minor versions
get_target_property(past_major_versions ${target} QT_QML_MODULE_PAST_MAJOR_VERSIONS)
diff --git a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
index d02c5eb1b3..b9d5052cf0 100644
--- a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
+++ b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
@@ -57,6 +57,7 @@ qt_add_qml_module(
[RESOURCES ...]
[OUTPUT_TARGETS out_targets_var]
[DESIGNER_SUPPORTED]
+ [FOLLOW_FOREIGN_VERSIONING]
[NO_PLUGIN_OPTIONAL]
[NO_CREATE_PLUGIN_TARGET]
[NO_GENERATE_PLUGIN_SOURCE]
@@ -494,4 +495,19 @@ Qt Quick Designer. When present, the generated \c qmldir file will contain
a \c designersupported line. See \l{Module Definition qmldir Files} for how
this affects the way Qt Quick Designer handles the plugin.
+The \c FOLLOW_FOREIGN_VERSIONING keyword relates to base types of your own
+C++-defined QML types that live in different QML modules. Typically, the
+versioning scheme of your module does not match that of the module providing
+the base types. Therefore, by default all revisions of the base types are
+made available in any import of your module. If \c FOLLOW_FOREIGN_VERSIONING
+is given, the version information attached to the base types and their
+properties is respected. So, an \c {import MyModule 2.8} will then only make
+available versioned properties up to version \c{2.8} of any base types outside
+\c{MyModule}.
+
+This is mostly useful if you want to keep your module version in sync
+with other modules you're basing types on. In that case you might want your custom
+types to not expose properties from a module's base type version greater than the one being
+imported.
+
*/
diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
index 46d18a4384..1df04a11e8 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
@@ -1139,7 +1139,7 @@ Item {
function test_columnIsOutsideGrid()
{
- ignoreWarning(/QML Item: Layout: column \(2\) should be less than the number of columns \(2\)/);
+ ignoreWarning(/.*: Layout: column \(2\) should be less than the number of columns \(2\)/);
var layout = layout_columnIsOutsideGrid_Component.createObject(container);
layout.width = layout.implicitWidth
layout.height = layout.implicitHeight
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index d18c830254..a442e3b91f 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -126,7 +126,7 @@ Item {
function test_warnAboutLayoutItemsWithAnchors()
{
- var regex = new RegExp("QML Item: Detected anchors on an item that is managed by a layout. "
+ var regex = new RegExp(".*: Detected anchors on an item that is managed by a layout. "
+ "This is undefined behavior; use Layout.alignment instead.")
for (var i = 0; i < 7; ++i) {
ignoreWarning(regex)