aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlMacros.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2024-03-21 16:52:46 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2024-03-22 18:11:40 +0100
commit4bc6c8e3704aeaf45316523a55ca19226ae10fb0 (patch)
tree2e6c76663f251c81fb84ac51bddf3b6970943a83 /src/qml/Qt6QmlMacros.cmake
parent8d691ac3577aa35a5be41087df17ca62310a0f21 (diff)
CMake: Fix re-running of qmlimportscanner during ninja clean
When calling ninja clean multiple times in a qml example project, one would see output like: $ ninja clean [1/2] Running qmlimportscanner for example Cannot open input file example/Foo.qml:No such file or directory Cannot open input file example/Bar.qml:No such file or directory [1/2] Re-running CMake... This happened because we generated the output imports.cmake file both at configure and build time into the same location, cause problematic dependency rules. Make sure that the output (and response) files are generated into separate paths to avoid this issue. As a drive-by, move the files into the .qt/qml_imports subdirectory instead of the .qt_plugins one. Pick-to: 6.7 Change-Id: Ifb092a5ab3894211de58334f405608ca516e96cd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r--src/qml/Qt6QmlMacros.cmake15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 9b1a7d5329..8ac700aa2f 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -3233,9 +3233,11 @@ function(_qt_internal_scan_qml_imports target imports_file_var when_to_scan)
if(when_to_scan STREQUAL "BUILD_PHASE")
set(scan_at_build_time TRUE)
set(scan_at_configure_time FALSE)
+ set(imports_file_infix "build")
elseif(when_to_scan STREQUAL "IMMEDIATELY")
set(scan_at_build_time FALSE)
set(scan_at_configure_time TRUE)
+ set(imports_file_infix "conf")
else()
message(FATAL_ERROR "Unexpected value for when_to_scan: ${when_to_scan}")
endif()
@@ -3244,8 +3246,15 @@ function(_qt_internal_scan_qml_imports target imports_file_var when_to_scan)
get_target_property(target_source_dir ${target} SOURCE_DIR)
get_target_property(target_binary_dir ${target} BINARY_DIR)
- set(out_dir "${target_binary_dir}/.qt_plugins")
- set(imports_file "${out_dir}/Qt6_QmlPlugins_Imports_${target}.cmake")
+ set(out_dir "${target_binary_dir}/.qt/qml_imports")
+
+ # Create separate files for scanning at build time vs configure time. Otherwise calling
+ # ninja clean will re-run qmlimportscanner directly after the clean, which is
+ # both weird and sometimes prints warnings due to the tool not finding qml files that were
+ # cleaned from the build dir.
+ set(file_base_name "${target}_${imports_file_infix}")
+
+ set(imports_file "${out_dir}/${file_base_name}.cmake")
set(${imports_file_var} "${imports_file}" PARENT_SCOPE)
file(MAKE_DIRECTORY ${out_dir})
@@ -3284,7 +3293,7 @@ function(_qt_internal_scan_qml_imports target imports_file_var when_to_scan)
# of arguments on the command line
string(LENGTH "${cmd_args}" length)
if(length GREATER 240)
- set(rsp_file "${out_dir}/Qt6_QmlPlugins_Imports_${target}.rsp")
+ set(rsp_file "${out_dir}/${file_base_name}.rsp")
list(JOIN cmd_args "\n" rsp_file_content)
file(WRITE ${rsp_file} "${rsp_file_content}")
set(cmd_args "@${rsp_file}")