diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-04-21 14:37:58 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-07 21:23:39 +0000 |
commit | f1e3a3b7e56dfe18cee2b39b24b018bd9b40177c (patch) | |
tree | d106a43a00ad53d89f9793be619c24694fd951b9 | |
parent | c504581bc0b348b7edaae604828e891aedcf7e87 (diff) |
CMake: Fix qmlimportscanner call for conan
QtQuick examples could not be built properly when qtdeclarative was
installed via conan. This was, because we passed the qtbase
installation prefix + "/qml" to qmlimportscanner as QML import path.
However, the qtbase installation prefix doesn't contain QML imports in
the conan case.
When using conan, we have multiple install prefixes. We must check each
of these prefixes for a "qml" subdirectory and pass it to
qmlimportscanner.
Fixes: QTBUG-102339
Change-Id: Ife769774d0ff7d0a580314781b525a71b03c0c8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
(cherry picked from commit 8bf916bfcbd5a05ec7370179317cd6d3a7dbd905)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 7ea9aa2dc6..d50d66f801 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -2399,10 +2399,27 @@ but this file does not exist. Possible reasons include: ") endif() - # Find location of qml dir. - # TODO: qt.prf implies that there might be more than one qml import path to - # pass to qmlimportscanner. - set(qml_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}") + # Find QML import paths. + if("${_qt_additional_packages_prefix_paths}" STREQUAL "") + # We have one installation prefix for all Qt modules. Add the "<prefix>/qml" directory. + set(qml_import_paths "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}") + else() + # We have multiple installation prefixes: one per Qt repository (conan). Add those that have + # a "qml" subdirectory. + set(qml_import_paths) + foreach(root IN ITEMS "${QT6_INSTALL_PREFIX};${_qt_additional_packages_prefix_paths}") + set(candidate "${root}/${QT6_INSTALL_QML}") + if(IS_DIRECTORY "${candidate}") + list(APPEND qml_import_paths "${candidate}") + endif() + endforeach() + endif() + + # Construct the -importPath arguments. + set(import_path_arguments) + foreach(path IN LISTS qml_import_paths) + list(APPEND import_path_arguments -importPath ${path}) + endforeach() # Run qmlimportscanner to generate the cmake file that records the import entries get_target_property(target_source_dir ${target} SOURCE_DIR) @@ -2416,7 +2433,7 @@ but this file does not exist. Possible reasons include: -rootPath "${target_source_dir}" -cmake-output -output-file "${imports_file}" - -importPath "${qml_path}" + ${import_path_arguments} ) get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH) |