hgclone.cmake.in 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. set(quiet "@quiet@")
  5. set(script_dir "@CMAKE_CURRENT_FUNCTION_LIST_DIR@/ExternalProject")
  6. include(${script_dir}/captured_process_setup.cmake)
  7. if(EXISTS "@hgclone_stampfile@" AND EXISTS "@hgclone_infofile@" AND
  8. "@hgclone_stampfile@" IS_NEWER_THAN "@hgclone_infofile@")
  9. if(NOT quiet)
  10. message(STATUS
  11. "Avoiding repeated hg clone, stamp file is up to date: "
  12. "'@hgclone_stampfile@'"
  13. )
  14. endif()
  15. return()
  16. endif()
  17. execute_process(
  18. COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
  19. RESULT_VARIABLE error_code
  20. ${capture_output}
  21. )
  22. _ep_command_check_result(
  23. error_code "Failed to remove directory: '@source_dir@'"
  24. )
  25. execute_process(
  26. COMMAND "@hg_EXECUTABLE@" clone -U "@hg_repository@" "@src_name@"
  27. WORKING_DIRECTORY "@work_dir@"
  28. RESULT_VARIABLE error_code
  29. ${capture_output}
  30. )
  31. _ep_command_check_result(
  32. error_code "Failed to clone repository: '@hg_repository@'"
  33. )
  34. execute_process(
  35. COMMAND "@hg_EXECUTABLE@" update @hg_tag@
  36. WORKING_DIRECTORY "@work_dir@/@src_name@"
  37. RESULT_VARIABLE error_code
  38. ${capture_output}
  39. )
  40. _ep_command_check_result(
  41. error_code "Failed to checkout tag: '@hg_tag@'"
  42. )
  43. # Complete success, update the script-last-run stamp file:
  44. #
  45. execute_process(
  46. COMMAND ${CMAKE_COMMAND} -E copy "@hgclone_infofile@" "@hgclone_stampfile@"
  47. RESULT_VARIABLE error_code
  48. ${capture_output}
  49. )
  50. _ep_command_check_result(
  51. error_code "Failed to copy script-last-run stamp file: '@hgclone_stampfile@'"
  52. )