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 113f1ad324
Task-number: QTBUG-88004
Change-Id: Icd95b28ca3642434cf21e5c49dcbd1ec65d76252
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
bb10
parent
4d9658b7cd
commit
2da301fe46
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
@qt_core_configure_file_contents@
|
||||
|
|
@ -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}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue