C++QED  v2 Milestone 10
a framework for simulating open quantum dynamics
GetGitRevisionDescription.cmake.in
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.txt or copy at
14 # http://www.boost.org/LICENSE_1_0.txt)
15 
16 #! \file
17 #! \ingroup Helpers
18 #! \brief Helper file for GetGitRevisionDescription.cmake.
19 
20 set(HEAD_HASH)
21 
22 file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
23 
24 string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
25 if(HEAD_CONTENTS MATCHES "ref")
26  # named branch
27  string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
28  if(EXISTS "@GIT_DIR@/${HEAD_REF}")
29  configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
30  elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
31  configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
32  set(HEAD_HASH "${HEAD_REF}")
33  endif()
34 else()
35  # detached HEAD
36  configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
37 endif()
38 
39 if(NOT HEAD_HASH)
40  file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
41  string(STRIP "${HEAD_HASH}" HEAD_HASH)
42 endif()