Nav apraksta

GetGitRevisionDescription.cmake.in 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Internal file for GetGitRevisionDescription.cmake
  3. #
  4. # Requires CMake 2.6 or newer (uses the 'function' command)
  5. #
  6. # Original Author:
  7. # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
  8. # http://academic.cleardefinition.com
  9. # Iowa State University HCI Graduate Program/VRAC
  10. #
  11. # Copyright Iowa State University 2009-2010.
  12. # Distributed under the Boost Software License, Version 1.0.
  13. # (See accompanying file LICENSE_1_0.txt or copy at
  14. # http://www.boost.org/LICENSE_1_0.txt)
  15. set(HEAD_HASH)
  16. file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
  17. string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
  18. if(HEAD_CONTENTS MATCHES "ref")
  19. # named branch
  20. string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
  21. if(EXISTS "@GIT_DIR@/${HEAD_REF}")
  22. configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
  23. elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
  24. configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
  25. set(HEAD_HASH "${HEAD_REF}")
  26. endif()
  27. else()
  28. # detached HEAD
  29. configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
  30. endif()
  31. if(NOT HEAD_HASH)
  32. file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
  33. string(STRIP "${HEAD_HASH}" HEAD_HASH)
  34. endif()