diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-27 11:38:31 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-27 21:58:58 +0000 |
commit | 6a71dc31bb80322e6f2a9dbf14a0c02068716cf7 (patch) | |
tree | 7e4592747d73a8a4303d507f9d8e9935ca21077e /src/qml/Qt6QmlMacros.cmake | |
parent | b002a1a7f1f27dfd37995a05dfcc0a215915daa7 (diff) |
Use <major>.0 as default version for QML files
Using the full module versions presents problems if you bump the minor
version of your module. Bumping the minor version then bumps the
versions of all QML files not explicitly versioned. This is certainly
not what you want as the files should still be available to imports of
the old version.
Having it default to minor version 0 is more practical because many QML
files are available from version 0 of their respective modules. Now you
need to add version entries for files you add after .0 in order for them
not to show up in imports of earlier versions. This is less of a
problem, though, even if you forget it.
In addition, use PAST_MAJOR_VERSIONS to derive additional versions to be
added to the QML files. This allows us to drop a lot of boiler plate
code from our own modules.
Change-Id: I8e4cfc16180af30e8bafc0a62137e9018f7eaee8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit de27215766f13cb5c870e6a1285836164d6e574c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 985a6a3a06..3277322746 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -1230,7 +1230,9 @@ endif() # customize the file's type details: # # QT_QML_SOURCE_VERSION: Version(s) for this qml file. If not present the module -# version will be used. +# major version and minor version 0 will be used. If any PAST_MAJOR_VERSIONS +# are given, those will be amended with minor version 0 and also added to the +# default. # # QT_QML_SOURCE_TYPENAME: Override the file's type name. If not present, the # type name will be deduced using the file's basename. @@ -1243,7 +1245,7 @@ endif() # e.g.: # set_source_files_properties(my_qml_file.qml # PROPERTIES -# QT_QML_SOURCE_VERSION "2.0;6.0" +# QT_QML_SOURCE_VERSION "2.3;6.0" # QT_QML_SOURCE_TYPENAME MyQmlFile # # qt6_target_qml_sources(my_qml_module @@ -1251,9 +1253,10 @@ endif() # my_qml_file.qml # ) # -# The above will produce the following entry in the qmldir file: +# The above will produce the following entries in the qmldir file: # -# MyQmlFile 2.0 my_qml_file.qml +# MyQmlFile 2.3 my_qml_file.qml +# MyQmlFile 6.0 my_qml_file.qml # function(qt6_target_qml_sources target) @@ -1308,6 +1311,7 @@ function(qt6_target_qml_sources target) get_target_property(no_qmldir ${target} QT_QML_MODULE_NO_GENERATE_QMLDIR) get_target_property(resource_prefix ${target} QT_QML_MODULE_RESOURCE_PREFIX) get_target_property(qml_module_version ${target} QT_QML_MODULE_VERSION) + get_target_property(past_major_versions ${target} QT_QML_MODULE_PAST_MAJOR_VERSIONS) if(NOT output_dir) # Probably not a qml module. We still want to support tooling for this @@ -1331,6 +1335,19 @@ function(qt6_target_qml_sources target) string(APPEND arg_PREFIX "/") endif() + if (qml_module_version MATCHES "^([0-9]+)\\.") + set(qml_module_files_versions "${CMAKE_MATCH_1}.0") + else() + message(FATAL_ERROR + "No major version found in '${qml_module_version}'." + ) + endif() + if (past_major_versions OR past_major_versions STREQUAL "0") + foreach (past_major_version ${past_major_versions}) + list(APPEND qml_module_files_versions "${past_major_version}.0") + endforeach() + endif() + # Linting and cachegen can still occur for a target that isn't a qml module, # but for such targets, there is no qmldir file to update. if(arg_NO_LINT) @@ -1469,7 +1486,7 @@ function(qt6_target_qml_sources target) get_source_file_property(qml_file_internal ${qml_file_src} QT_QML_INTERNAL_TYPE) if (NOT qml_file_versions) - set(qml_file_versions ${qml_module_version}) + set(qml_file_versions ${qml_module_files_versions}) endif() set(qmldir_file_contents "") |