Files
CMake/Tests/RunCMake/file/RENAME-file-replace.cmake
Brad King 9bf40d8027 file(RENAME): Add option to not replace existing path
Add a `NO_REPLACE` option that prevents overwriting `<newname>`
if it exists.
2021-03-04 08:49:48 -05:00

10 lines
351 B
CMake

set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input")
set(newname "${CMAKE_CURRENT_BINARY_DIR}/output")
file(WRITE "${oldname}" "a")
file(WRITE "${newname}" "b")
file(RENAME "${oldname}" "${newname}")
file(READ "${newname}" new)
if(NOT "${new}" STREQUAL "a")
message(FATAL_ERROR "New name:\n ${newname}\ndoes not contain expected content 'a'.")
endif()