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.

67 lines
2.2 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. --- a/CMakeLists.txt
  8. +++ b/CMakeLists.txt
  9. @@ -13,27 +13,37 @@ if(MINIMAL)
  10. add_definitions(-DTINI_MINIMAL=1)
  11. endif()
  12. -# Extract git version and dirty-ness
  13. -execute_process (
  14. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  15. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  16. - RESULT_VARIABLE git_version_check_ret
  17. - OUTPUT_VARIABLE tini_VERSION_GIT
  18. -)
  19. +# Set the git version
  20. +if (NOT "${TINI_VERSION_GIT}" STREQUAL "")
  21. + # Set by the user directly
  22. + set(tini_VERSION_GIT "${TINI_VERSION_GIT}")
  23. +else()
  24. + # Extract git version
  25. + execute_process (
  26. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  27. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  28. + RESULT_VARIABLE git_version_check_ret
  29. + OUTPUT_VARIABLE tini_VERSION_GIT
  30. + )
  31. -execute_process(
  32. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  33. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  34. - OUTPUT_VARIABLE git_dirty_check_out
  35. -)
  36. + if("${git_version_check_ret}" EQUAL 0)
  37. + # Extract git dirty-ness
  38. + execute_process(
  39. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  40. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  41. + OUTPUT_VARIABLE git_dirty_check_out
  42. + )
  43. -if("${git_version_check_ret}" EQUAL 0)
  44. - set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  45. - if(NOT "${git_dirty_check_out}" STREQUAL "")
  46. - set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  47. - endif()
  48. -else()
  49. - set(tini_VERSION_GIT "")
  50. + if(NOT "${git_dirty_check_out}" STREQUAL "")
  51. + set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  52. + endif()
  53. + else()
  54. + set(tini_VERSION_GIT "")
  55. + endif()
  56. +endif()
  57. +
  58. +if(NOT ${tini_VERSION_GIT} STREQUAL "")
  59. + set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  60. endif()
  61. # Flags