From e01ab6373b5cf550d9010a96e21646083bce1059 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 8 Sep 2022 11:33:42 +0200 Subject: CMake: Harden construction of QML import paths for qmlimportscanner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In certain cases where QT6_INSTALL_PREFIX/qml might not exist, we wouldn't add the -importPath argument itself, but would still try to add import paths, which would then confuse qmlimportscanner and trigger an error. qmlimportscanner: Invalid argument: ... Make sure to prepend -importPath for each passed import path. Task-number: QTBUG-96232 Task-number: QTBUG-106431 Change-Id: Iae2b02a0b50e75a297df8fbaf0427df2b6b30c93 Reviewed-by: Ulf Hermann Reviewed-by: Jörg Bornemann (cherry picked from commit 300074edaacdad3f2ffacb87c3e718db620c564a) --- src/qml/Qt6QmlMacros.cmake | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/qml') diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 63acf650a9..73b7335dd2 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -2000,7 +2000,7 @@ but this file does not exist. Possible reasons include: ") endif() - # Find QML import paths. + # Find Qt provided QML import paths. if("${_qt_additional_packages_prefix_paths}" STREQUAL "") # We have one installation prefix for all Qt modules. Add the "/qml" directory. set(qml_import_paths "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}") @@ -2016,11 +2016,6 @@ but this file does not exist. Possible reasons include: 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() # Small macro to avoid duplicating code in two different loops. macro(_qt6_QmlImportScanner_parse_entry) @@ -2044,7 +2039,6 @@ but this file does not exist. Possible reasons include: set(cmd_args -rootPath "${arg_PATH_TO_SCAN}" -cmake-output - ${import_path_arguments} ) get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH) @@ -2055,18 +2049,26 @@ but this file does not exist. Possible reasons include: # Facilitate self-import so we can find the qmldir file get_target_property(module_out_dir ${target} QT_QML_MODULE_OUTPUT_DIRECTORY) if(module_out_dir) - list(APPEND cmd_args "${module_out_dir}") + list(APPEND qml_import_paths "${module_out_dir}") endif() # Find qmldir files we copied to the build directory if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "") if(EXISTS "${QT_QML_OUTPUT_DIRECTORY}") - list(APPEND cmd_args "${QT_QML_OUTPUT_DIRECTORY}") + list(APPEND qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}") endif() else() - list(APPEND cmd_args "${CMAKE_CURRENT_BINARY_DIR}") + list(APPEND qml_import_paths "${CMAKE_CURRENT_BINARY_DIR}") endif() + # Construct the -importPath arguments. + set(import_path_arguments) + foreach(path IN LISTS qml_import_paths) + list(APPEND import_path_arguments -importPath ${path}) + endforeach() + + list(APPEND cmd_args ${import_path_arguments}) + # All of the module's .qml files will be listed in one of the generated # .qrc files, so there's no need to list the files individually. We provide # the .qrc files instead because they have the additional information for -- cgit v1.2.3