You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.3 KiB

  1. commit 31b0908a5eff3926195670beecc8548c429ceff5
  2. Author: Gerard Ryan <G.M0N3Y.2503@gmail.com>
  3. Date: Sat Oct 31 16:53:39 2020 +1000
  4. Added support for setting git version externally
  5. * This to help when building from source snapshots
  6. that don't have the .git file structure.
  7. diff --git a/CMakeLists.txt b/CMakeLists.txt
  8. index 332b361..3f6f44b 100644
  9. --- a/CMakeLists.txt
  10. +++ b/CMakeLists.txt
  11. @@ -13,27 +13,37 @@ if(MINIMAL)
  12. add_definitions(-DTINI_MINIMAL=1)
  13. endif()
  14. -# Extract git version and dirty-ness
  15. -execute_process (
  16. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  17. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  18. - RESULT_VARIABLE git_version_check_ret
  19. - OUTPUT_VARIABLE tini_VERSION_GIT
  20. -)
  21. -
  22. -execute_process(
  23. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  24. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  25. - OUTPUT_VARIABLE git_dirty_check_out
  26. -)
  27. -
  28. -if("${git_version_check_ret}" EQUAL 0)
  29. - set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  30. - if(NOT "${git_dirty_check_out}" STREQUAL "")
  31. - set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  32. - endif()
  33. +# Set the git version
  34. +if (NOT "${TINI_VERSION_GIT}" STREQUAL "")
  35. + # Set by the user directly
  36. + set(tini_VERSION_GIT "${TINI_VERSION_GIT}")
  37. else()
  38. - set(tini_VERSION_GIT "")
  39. + # Extract git version
  40. + execute_process (
  41. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  42. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  43. + RESULT_VARIABLE git_version_check_ret
  44. + OUTPUT_VARIABLE tini_VERSION_GIT
  45. + )
  46. +
  47. + if("${git_version_check_ret}" EQUAL 0)
  48. + # Extract git dirty-ness
  49. + execute_process(
  50. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  51. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  52. + OUTPUT_VARIABLE git_dirty_check_out
  53. + )
  54. +
  55. + if(NOT "${git_dirty_check_out}" STREQUAL "")
  56. + set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  57. + endif()
  58. + else()
  59. + set(tini_VERSION_GIT "")
  60. + endif()
  61. +endif()
  62. +
  63. +if(NOT ${tini_VERSION_GIT} STREQUAL "")
  64. + set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  65. endif()
  66. # Flags