1
0

hgclone.cmake.in 1.3 KB

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