tini-cmake-fixes.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From a8f82ea60cde15cbbd0ebcf729062de6bad9859c Mon Sep 17 00:00:00 2001
  2. From: Thomas Orozco <thomas@orozco.fr>
  3. Date: Tue, 28 Mar 2017 21:59:07 +0200
  4. Subject: [PATCH] Allow setting VERSION_GIT
  5. Fixes: #79
  6. ---
  7. CMakeLists.txt | 48 +++++++++++++++++++++++++++++-------------------
  8. 1 file changed, 29 insertions(+), 19 deletions(-)
  9. diff --git a/CMakeLists.txt b/CMakeLists.txt
  10. index 8936f18..06c180c 100644
  11. --- a/CMakeLists.txt
  12. +++ b/CMakeLists.txt
  13. @@ -6,34 +6,44 @@ set (tini_VERSION_MAJOR 0)
  14. set (tini_VERSION_MINOR 14)
  15. set (tini_VERSION_PATCH 0)
  16. +set (GIT_PREFIX " - git.")
  17. +
  18. # Build options
  19. option(MINIMAL "Disable argument parsing and verbose output" OFF)
  20. +# Set VERSION_GIT to INTERNAL so it does not persist across runs of CMake, just
  21. +# like the auto-discovery would.
  22. +set(VERSION_GIT "" CACHE INTERNAL "Override the git revision")
  23. +
  24. if(MINIMAL)
  25. add_definitions(-DTINI_MINIMAL=1)
  26. endif()
  27. # Extract git version and dirty-ness
  28. -execute_process (
  29. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  30. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  31. - RESULT_VARIABLE git_version_check_ret
  32. - OUTPUT_VARIABLE tini_VERSION_GIT
  33. -)
  34. -
  35. -execute_process(
  36. - COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  37. - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  38. - OUTPUT_VARIABLE git_dirty_check_out
  39. -)
  40. -
  41. -if("${git_version_check_ret}" EQUAL 0)
  42. - set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  43. - if(NOT "${git_dirty_check_out}" STREQUAL "")
  44. - set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  45. - endif()
  46. +if(VERSION_GIT)
  47. + set(tini_VERSION_GIT "${GIT_PREFIX}${VERSION_GIT}")
  48. else()
  49. - set(tini_VERSION_GIT "")
  50. + execute_process (
  51. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  52. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  53. + RESULT_VARIABLE git_version_check_ret
  54. + OUTPUT_VARIABLE tini_VERSION_GIT
  55. + )
  56. +
  57. + execute_process(
  58. + COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  59. + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  60. + OUTPUT_VARIABLE git_dirty_check_out
  61. + )
  62. +
  63. + if("${git_version_check_ret}" EQUAL 0)
  64. + set(tini_VERSION_GIT "${GIT_PREFIX}${tini_VERSION_GIT}")
  65. + if(NOT "${git_dirty_check_out}" STREQUAL "")
  66. + set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  67. + endif()
  68. + else()
  69. + set(tini_VERSION_GIT "")
  70. + endif()
  71. endif()
  72. # Flags