hgclone.cmake.in 1.5 KB

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