From aad3b1f063e68cfdcbc099e0ae5c001319d99dcc Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 26 Apr 2023 14:26:31 +0200 Subject: [PATCH] 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. Pick-to: 6.5 Change-Id: I701f9089f5ad941ffdf235aeccc3119b68c4e3e3 Reviewed-by: Alexey Edelev --- cmake/QtExecutableHelpers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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