diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-04-26 14:26:31 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-04-26 20:09:38 +0200 |
commit | aad3b1f063e68cfdcbc099e0ae5c001319d99dcc (patch) | |
tree | 9b6ae89ec6bd059f937393129e34bf31c856ec55 /cmake/QtExecutableHelpers.cmake | |
parent | be4de03b37206dd654bf90342636838d3ed3abc1 (diff) |
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 <alexey.edelev@qt.io>
Diffstat (limited to 'cmake/QtExecutableHelpers.cmake')
-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 |