diff options
author | Brad King <brad.king@kitware.com> | 2023-11-22 12:19:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-11-22 12:20:05 (GMT) |
commit | 874b62abb4fd76127262181ef5253bddb295ef1a (patch) | |
tree | 6261cbd03c82a06ebad8e68eadfa3b630d2dd66a /Modules/Compiler | |
parent | 1db4d34694ec595952b88f95182a363f815a4c45 (diff) | |
parent | 77a7edb73fcfee88c4998bd8e4d72aaddc5524e5 (diff) | |
download | CMake-874b62abb4fd76127262181ef5253bddb295ef1a.zip CMake-874b62abb4fd76127262181ef5253bddb295ef1a.tar.gz CMake-874b62abb4fd76127262181ef5253bddb295ef1a.tar.bz2 |
Merge topic 'clang-scan-deps-failed-scan'
77a7edb73f Clang-CXX: copy into the dyndep output on success
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Namniav W <namniav@gmail.com>
Merge-request: !8991
Diffstat (limited to 'Modules/Compiler')
-rw-r--r-- | Modules/Compiler/Clang-CXX.cmake | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index c0d2356..a1ce6a1 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -32,6 +32,13 @@ endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if (CMAKE_HOST_WIN32) + # `rename` doesn't overwrite and doesn't retry in case of "target file is + # busy". + set(_clang_scan_deps_mv "\"${CMAKE_COMMAND}\" -E rename") + else () + set(_clang_scan_deps_mv "mv") + endif () string(CONCAT CMAKE_CXX_SCANDEP_SOURCE "\"${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}\"" " -format=p1689" @@ -40,7 +47,15 @@ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) " -x c++ <SOURCE> -c -o <OBJECT>" " -MT <DYNDEP_FILE>" " -MD -MF <DEP_FILE>" - " > <DYNDEP_FILE>") + # Write to a temporary file. If the scan fails, we do not want to update + # the actual output file as `ninja` (at least) assumes that failed + # commands either delete or leave output files alone. See Issue#25419. + " > <DYNDEP_FILE>.tmp" + # We cannot use `copy_if_different` as the rule does not have a feature + # analogous to `ninja`'s `restat = 1`. It would also leave behind the + # `.tmp` file. + " && ${_clang_scan_deps_mv} <DYNDEP_FILE>.tmp <DYNDEP_FILE>") + unset(_clang_scan_deps_mv) set(CMAKE_CXX_MODULE_MAP_FORMAT "clang") set(CMAKE_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>") set(CMAKE_CXX_MODULE_BMI_ONLY_FLAG "--precompile") |