CMake: pro2cmake: Use latest project version for qml import version

Use PROJECT_VERSION instead of CMAKE_PROJECT_VERSION when setting the
version of a qml module, which extracts the version of the latest
project() call rather than the top-level one.

Using CMAKE_PROJECT_VERSION caused issues in top-level builds where
the qtdeclarative version is 6.2, but the top-level project version is
still 6.1 and hasn't been updated to 6.2, causing qml module import
errors.

This was probably an oversight during initial implementation of qml
support in pro2cmake.
So projects that define qml modules should be adapted accordingly.

Amends cce8ada814
Amends 28fff4a551

Pick-to: 6.1 6.0
Task-number: QTBUG-92861
Change-Id: I494784694e997501a5bc4fd0c0eac458ddc248aa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
bb10
Alexandru Croitor 2021-04-15 12:12:45 +02:00
parent e7bdf7273c
commit cf27a23937
1 changed files with 2 additions and 2 deletions

View File

@ -4041,8 +4041,8 @@ def get_qml_import_version(scope: Scope, target: str) -> str:
if import_version:
replacements = [
("$$QT_MINOR_VERSION", "${CMAKE_PROJECT_VERSION_MINOR}"),
("$$QT_VERSION", "${CMAKE_PROJECT_VERSION}"),
("$$QT_MINOR_VERSION", "${PROJECT_VERSION_MINOR}"),
("$$QT_VERSION", "${PROJECT_VERSION}"),
]
for needle, replacement in replacements:
import_version = import_version.replace(needle, replacement)