summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 16:46:40 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 17:19:27 +0100
commit2da301fe46450eedabfde7860338a2c0066c550b (patch)
treece876155783111928c75e40cb1bf70508f55e35c /src
parent4d9658b7cd2b072dd8b24d9bb6844b7cbcf22ad0 (diff)
CMake: Fix unnecessary rebuilding upon reconfiguration
The following MR in upstream CMake makes sure that the autogen targets depend on the CMakeLists.txt file associated with the autogen target, as well as any files it includes. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5166 When doing a no-op reconfiguration in the build dir (call 'cmake .') we used file(WRITE) to prepare the contents of a file to be used with configure_file() for creation of a .qrc resource file. Because this file was always rewritten on reconfiguration, its timestamp was newer than then autogen target's timestamp which caused the autogen targets to-be rerun, as well as some compilation and relinking. To avoid this, instead of using file(WRITE) ship a template file next to the Qt6CoreMacros.cmake file, and use it as a template for the qrc configure_file() call. This ensures that a reconfiguration doesn't necessarily rebuild things it shouldn't rebuild. Amends 113f1ad324202ea2b861a3dbdec2ee7ef716c283 Task-number: QTBUG-88004 Change-Id: Icd95b28ca3642434cf21e5c49dcbd1ec65d76252 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/CMakeLists.txt1
-rw-r--r--src/corelib/Qt6CoreConfigureFileTemplate.in1
-rw-r--r--src/corelib/Qt6CoreMacros.cmake7
3 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 2703ec5913..968d379277 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -259,6 +259,7 @@ qt_internal_add_module(Core
# Generated in QtBaseGlobalTargets
EXTRA_CMAKE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CTestMacros.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreConfigureFileTemplate.in"
${corelib_extra_cmake_files}
# special case end
)
diff --git a/src/corelib/Qt6CoreConfigureFileTemplate.in b/src/corelib/Qt6CoreConfigureFileTemplate.in
new file mode 100644
index 0000000000..5ed5cae0a7
--- /dev/null
+++ b/src/corelib/Qt6CoreConfigureFileTemplate.in
@@ -0,0 +1 @@
+@qt_core_configure_file_contents@
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 1066d72332..15a60756eb 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -38,6 +38,8 @@
include(CMakeParseArguments)
+set(__qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
+
# macro used to create the names of output files preserving relative dirs
macro(_qt_internal_make_output_file infile prefix ext outfile )
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
@@ -1180,8 +1182,9 @@ function(_qt_internal_process_resource target resourceName)
# </qresource></RCC>
string(APPEND qrcContents " </qresource>\n</RCC>\n")
- file(WRITE "${generatedResourceFile}.in" "${qrcContents}")
- configure_file("${generatedResourceFile}.in" "${generatedResourceFile}")
+ set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
+ set(qt_core_configure_file_contents "${qrcContents}")
+ configure_file("${template_file}" "${generatedResourceFile}")
set_property(TARGET ${target} APPEND PROPERTY _qt_generated_qrc_files "${generatedResourceFile}")