diff options
author | Brad King <brad.king@kitware.com> | 2022-11-17 18:27:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-17 20:05:07 (GMT) |
commit | efa9eec0402adacc7ac8b0dc17660a8bd968b06a (patch) | |
tree | 4faf3121039e17ea3d951912b2aede27ef939f1e /Tests/RunCMake/file | |
parent | fa518188d8aeffa176109bc960173b06fa1e135e (diff) | |
download | CMake-efa9eec0402adacc7ac8b0dc17660a8bd968b06a.zip CMake-efa9eec0402adacc7ac8b0dc17660a8bd968b06a.tar.gz CMake-efa9eec0402adacc7ac8b0dc17660a8bd968b06a.tar.bz2 |
file(COPY_FILE): Add option to retry on Windows if input access fails
On Windows, a file may be inaccessible for a short time after it is
created. This occurs for various reasons, including indexing, antivirus
tools, and NTFS's asynchronous semantics. Add an `INPUT_MAY_BE_RECENT`
option to tell CMake that the input file may have been recently created
so that we can retry a few times to read it.
Diffstat (limited to 'Tests/RunCMake/file')
-rw-r--r-- | Tests/RunCMake/file/COPY_FILE-file-INPUT_MAY_BE_RECENT.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/file/RunCMakeTest.cmake | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Tests/RunCMake/file/COPY_FILE-file-INPUT_MAY_BE_RECENT.cmake b/Tests/RunCMake/file/COPY_FILE-file-INPUT_MAY_BE_RECENT.cmake new file mode 100644 index 0000000..88bf448 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-INPUT_MAY_BE_RECENT.cmake @@ -0,0 +1,10 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(COPY_FILE "${oldname}" "${newname}" INPUT_MAY_BE_RECENT) +if(NOT EXISTS "${oldname}") + message(FATAL_ERROR "The old name does not exist:\n ${oldname}") +endif() +if(NOT EXISTS "${newname}") + message(FATAL_ERROR "The new name does not exist:\n ${newname}") +endif() diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 4ad00ff..0c4c174 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -59,6 +59,7 @@ run_cmake_script(COPY_FILE-dirlink-to-file-fail) run_cmake_script(COPY_FILE-file-to-file) run_cmake_script(COPY_FILE-file-to-dir-capture) run_cmake_script(COPY_FILE-file-to-dir-fail) +run_cmake_script(COPY_FILE-file-INPUT_MAY_BE_RECENT) run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-capture) run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-fail) run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite) |