aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-06-21 16:28:30 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-24 12:53:07 +0000
commit6bab1731e3beaa79e8fceecfd50d7a11cb7eeca7 (patch)
treedd38f46d0b987cc6a3325ebc9faf6125cfb49278
parentef265596e9d6b610a6f6e180c75075b392593161 (diff)
CMake: Copy RESOURCES files to the build directory, too
We need to treat them exactly like QML_FILES. Change-Id: I5582ad933c844c55f9015478672607e6d1218d84 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit c9e901db891336434b682dd92ec8e2d18a8e7c03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/Qt6QmlMacros.cmake59
-rw-r--r--tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp1
2 files changed, 29 insertions, 31 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index cecb728d76..7fd4a5b94f 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -1177,52 +1177,51 @@ function(qt6_target_qml_sources target)
set(non_qml_files)
set(output_targets)
- foreach(qml_file_src IN LISTS arg_FILES)
- # This is to facilitate updating code that used the earlier tech preview
- # API function qt6_target_qml_files()
- if(NOT qml_file_src MATCHES "\\.(js|mjs|qml)$")
- list(APPEND non_qml_files ${qml_file_src})
- continue()
- endif()
-
+ foreach(file_src IN LISTS arg_FILES arg_RESOURCES)
# We need to copy the file to the build directory now so that when
# qmlimportscanner is run in qt6_import_qml_plugins() as part of
- # target finalizers, the qml files will be there. We need to do this
+ # target finalizers, the files will be there. We need to do this
# in a way that CMake doesn't create a dependency on the source or it
- # will re-run CMake every time the qml file is modified. We also don't
+ # will re-run CMake every time the file is modified. We also don't
# want to update the file's timestamp if its contents won't change.
- # We still enforce the dependency on the qml source file by adding a
+ # We still enforce the dependency on the source file by adding a
# build-time rule. This avoids having to re-run CMake just to re-copy
# the file.
- get_filename_component(file_absolute ${qml_file_src} ABSOLUTE)
- __qt_get_relative_resource_path_for_file(file_resource_path ${qml_file_src})
- set(qml_file_out ${output_dir}/${file_resource_path})
+ get_filename_component(file_absolute ${file_src} ABSOLUTE)
+ __qt_get_relative_resource_path_for_file(file_resource_path ${file_src})
+
+ set(file_out ${output_dir}/${file_resource_path})
# Don't generate or copy the file in an in-source build if the source
# and destination paths are the same, it will cause a ninja dependency
# cycle at build time.
- if(NOT qml_file_out STREQUAL file_absolute)
- get_filename_component(file_out_dir ${qml_file_out} DIRECTORY)
+ if(NOT file_out STREQUAL file_absolute)
+ get_filename_component(file_out_dir ${file_out} DIRECTORY)
file(MAKE_DIRECTORY ${file_out_dir})
- set(need_write TRUE)
- file(READ ${qml_file_src} new_contents)
- if(EXISTS ${qml_file_out})
- file(READ ${qml_file_out} old_contents)
- if("${new_contents}" STREQUAL "${old_contents}")
- set(need_write FALSE)
- endif()
- endif()
- if(need_write)
- file(WRITE ${qml_file_out} "${new_contents}")
- endif()
+ execute_process(COMMAND
+ ${CMAKE_COMMAND} -E copy_if_different ${file_absolute} ${file_out}
+ )
- add_custom_command(OUTPUT ${qml_file_out}
- COMMAND ${CMAKE_COMMAND} -E copy ${qml_file_src} ${qml_file_out}
- DEPENDS ${qml_file_src}
+ add_custom_command(OUTPUT ${file_out}
+ COMMAND ${CMAKE_COMMAND} -E copy ${file_src} ${file_out}
+ DEPENDS ${file_src}
WORKING_DIRECTORY $<TARGET_PROPERTY:${target},SOURCE_DIR>
)
endif()
+ endforeach()
+
+ foreach(qml_file_src IN LISTS arg_FILES)
+ # This is to facilitate updating code that used the earlier tech preview
+ # API function qt6_target_qml_files()
+ if(NOT qml_file_src MATCHES "\\.(js|mjs|qml)$")
+ list(APPEND non_qml_files ${qml_file_src})
+ continue()
+ endif()
+
+ get_filename_component(file_absolute ${qml_file_src} ABSOLUTE)
+ __qt_get_relative_resource_path_for_file(file_resource_path ${qml_file_src})
+ set(qml_file_out ${output_dir}/${file_resource_path})
# For the tooling steps below, run the tools on the copied qml file in
# the build directory, not the source directory. This is required
diff --git a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
index bd3584ba37..9f027c3d8a 100644
--- a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
+++ b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
@@ -75,7 +75,6 @@ void tst_basicapp::fileSystemFiles()
QVERIFY(QFile::exists(basedir + QStringLiteral("/main.qml")));
QVERIFY(QFile::exists(basedir + QStringLiteral("/TimeExample/Clock.qml")));
- QEXPECT_FAIL(nullptr, "Does not install RESOURCES in qrc", Abort);
QVERIFY(QFile::exists(basedir + QStringLiteral("/TimeExample/center.png")));
QVERIFY(QFile::exists(basedir + QStringLiteral("/TimeExample/clock.png")));
QVERIFY(QFile::exists(basedir + QStringLiteral("/TimeExample/hour.png")));