diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-04-26 14:26:31 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-04-26 20:02:12 +0000 |
commit | 97fcdc22ff20a7f8188b5a76e39cd51924fc2305 (patch) | |
tree | c43e74b867edda2f19ee0e52b74c5d0c02d8e6e1 | |
parent | 2d61b3f8fc64f516189fb0246fccea221b847840 (diff) | |
download | qtbase-97fcdc22ff20a7f8188b5a76e39cd51924fc2305.tar.gz |
CMake: Fully rebuild dirty configure-time executables
Problem: "ninja clean" does not fully clean the build directories of
configure-time executables (e.g. syncqt). This can lead to problems when
building with compiler and linker launchers: on configure time, the
launchers are not used (compare CMake issue #20762). After a "ninja
clean", the executable might be removed but the object files are still
there. This leads to a situation where the object files have been
created without the compiler launcher but are linked with the linker
launcher. We encountered a situation however, where the linker launcher
requires the usage of the compiler launcher.
The configure-time executable has a ${target}_build custom command that
runs "cmake --build" and creates a timestamp file to track when to build
the target. To circumvent the problem of stale object files we add the
"--clean-first" argument to that target to fully rebuild configure-time
executables if the timestamp file is out of date.
The performance this imposes is negligible, because
1. Those configure-time executables are seldom out of date.
2. They are supposed to be "tiny executables with system dependencies
only" anyway.
Change-Id: I701f9089f5ad941ffdf235aeccc3119b68c4e3e3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit aad3b1f063e68cfdcbc099e0ae5c001319d99dcc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | cmake/QtExecutableHelpers.cmake | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake index 8be1186464..8ebcadf30e 100644 --- a/cmake/QtExecutableHelpers.cmake +++ b/cmake/QtExecutableHelpers.cmake @@ -402,7 +402,7 @@ function(qt_internal_add_configure_time_executable target) set(timestamp_file "${target_binary_dir}/${target_binary}_timestamp") add_custom_command(OUTPUT "${target_binary_path}" "${timestamp_file}" COMMAND - ${CMAKE_COMMAND} --build "${target_binary_dir}" ${config_build_arg} + ${CMAKE_COMMAND} --build "${target_binary_dir}" --clean-first ${config_build_arg} COMMAND ${CMAKE_COMMAND} -E touch "${timestamp_file}" DEPENDS |