hgclone.cmake.in 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. cmake_minimum_required(VERSION 3.5)
  4. if(EXISTS "@hgclone_stampfile@" AND EXISTS "@hgclone_infofile@" AND
  5. "@hgclone_stampfile@" IS_NEWER_THAN "@hgclone_infofile@")
  6. message(STATUS
  7. "Avoiding repeated hg clone, stamp file is up to date: "
  8. "'@hgclone_stampfile@'"
  9. )
  10. return()
  11. endif()
  12. execute_process(
  13. COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
  14. RESULT_VARIABLE error_code
  15. )
  16. if(error_code)
  17. message(FATAL_ERROR "Failed to remove directory: '@source_dir@'")
  18. endif()
  19. execute_process(
  20. COMMAND "@hg_EXECUTABLE@" clone -U "@hg_repository@" "@src_name@"
  21. WORKING_DIRECTORY "@work_dir@"
  22. RESULT_VARIABLE error_code
  23. )
  24. if(error_code)
  25. message(FATAL_ERROR "Failed to clone repository: '@hg_repository@'")
  26. endif()
  27. execute_process(
  28. COMMAND "@hg_EXECUTABLE@" update @hg_tag@
  29. WORKING_DIRECTORY "@work_dir@/@src_name@"
  30. RESULT_VARIABLE error_code
  31. )
  32. if(error_code)
  33. message(FATAL_ERROR "Failed to checkout tag: '@hg_tag@'")
  34. endif()
  35. # Complete success, update the script-last-run stamp file:
  36. #
  37. execute_process(
  38. COMMAND ${CMAKE_COMMAND} -E copy "@hgclone_infofile@" "@hgclone_stampfile@"
  39. RESULT_VARIABLE error_code
  40. )
  41. if(error_code)
  42. message(FATAL_ERROR "Failed to copy script-last-run stamp file: '@hgclone_stampfile@'")
  43. endif()