TOUCH.cmake 449 B

1234567891011121314151617
  1. set(file "${CMAKE_CURRENT_BINARY_DIR}/file-to-touch")
  2. file(REMOVE "${file}")
  3. file(TOUCH_NOCREATE "${file}")
  4. if(EXISTS "${file}")
  5. message(FATAL_ERROR "error: TOUCH_NOCREATE created a file!")
  6. endif()
  7. file(TOUCH "${file}")
  8. if(NOT EXISTS "${file}")
  9. message(FATAL_ERROR "error: TOUCH did not create a file!")
  10. endif()
  11. file(REMOVE "${file}")
  12. # Empty arguments used to be an error, but this is valid since CMake 3.30
  13. file(TOUCH)
  14. file(TOUCH_NOCREATE)