SystemTools: use CopyFile on Windows
Tested on my Windows 10 machine
Copied a 2 046 749 KB file 10 times with and without optimization
PS C:\projects\experiments> cmake -P copy_speed_test.cmake
Start time: 2025-02-10 17:17:50
End time: 2025-02-10 17:18:24
PS C:\projects\experiments> C:/projects/cmake/build/bin/Release/cmake.exe -P copy_speed_test.cmake
Start time: 2025-02-10 17:19:00
End time: 2025-02-10 17:19:16
Test script:
# C:/projects/cmake/build/bin/Release/cmake.exe -P copy_speed_test.cmake
# cmake -P copy_speed_test.cmake
# get time before copy (windows way)
execute_process(
COMMAND "powershell" "-Command" "(Get-Date).ToString('yyyy-MM-dd HH:mm:ss')"
OUTPUT_VARIABLE start_time
OUTPUT_STRIP_TRAILING_WHITESPACE
)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-2.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-3.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-4.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-5.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-6.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-7.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-8.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-9.bin)
file(COPY_FILE ./InstallSkyMP-349d526-1.bin ./InstallSkyMP-349d526-1-copy-10.bin)
# get time after copy (windows way)
execute_process(
COMMAND "powershell" "-Command" "(Get-Date).ToString('yyyy-MM-dd HH:mm:ss')"
OUTPUT_VARIABLE end_time
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("Start time: ${start_time}")
message("End time: ${end_time}")
Issue: cmake/cmake#26378
Topic-rename: SystemTools-windows-CopyFile
Edited by Brad King