aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-09-08 11:33:42 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-09 13:09:02 +0000
commit6949fec1cc0299a84815a3f070867eb626e6f19b (patch)
tree2f8f93b10ea473f2045a93d79206858df2bbe4c0
parenta53b3dc883661a86b0e90e03b53f1ec63664dbec (diff)
CMake: Harden construction of QML import paths for qmlimportscanner
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 <ulf.hermann@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 300074edaacdad3f2ffacb87c3e718db620c564a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/Qt6QmlMacros.cmake22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index dcf6478399..79d13bc6f8 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -2399,7 +2399,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 "<prefix>/qml" directory.
set(qml_import_paths "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}")
@@ -2415,11 +2415,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()
# Run qmlimportscanner to generate the cmake file that records the import entries
get_target_property(target_source_dir ${target} SOURCE_DIR)
@@ -2433,7 +2428,6 @@ but this file does not exist. Possible reasons include:
-rootPath "${target_source_dir}"
-cmake-output
-output-file "${imports_file}"
- ${import_path_arguments}
)
get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH)
@@ -2444,18 +2438,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