1 #! \brief Extract version information from a local working copy
3 #! If the source_dir variable points to a git repository, this function
4 #! extracts the current revision hash and branch/tag name.
6 #! If the source_dir variable points to a subversion repository, this
7 #! function extracts the current svn revision.
9 #! The information is provided in
11 #! <li> ${prefix}_REVISION_ID The git hash or svn revision value
12 #! <li> ${prefix}_REVISION_NAME The git branch/tag name or empty
13 #! <li> ${prefix}_WC_TYPE The working copy type, one of "local", "git", or "svn"
16 #! \param source_dir The directory containing a working copy
17 #! \param prefix A prefix to prepend to the variables containing
18 #! the extracted information.
23 message(FATAL_ERROR
"prefix argument not specified")
26 # initialize variables
40 set(_wc_id ${${prefix}_WC_REVISION_HASH})
42 string(REPLACE
" " ";" hash_name ${${prefix}_WC_REVISION_NAME})
43 list(GET hash_name 1 name)
50 # test for svn working copy
51 if(_wc_type STREQUAL
"local")
53 find_package(Subversion)
55 execute_process(COMMAND ${Subversion_SVN_EXECUTABLE}
info
56 WORKING_DIRECTORY ${source_dir}
57 RESULT_VARIABLE _subversion_result
61 if(NOT _subversion_result)
63 Subversion_WC_INFO(${source_dir} ${prefix})
64 set(_wc_id ${${prefix}_WC_REVISION})
70 set(${prefix}_WC_TYPE ${_wc_type} PARENT_SCOPE)
71 set(${prefix}_REVISION_ID ${_wc_id} PARENT_SCOPE)
72 set(_shortid ${_wc_id})
73 if(_wc_type STREQUAL
"git")
74 string(SUBSTRING ${_shortid} 0 8 _shortid)
76 set(${prefix}_REVISION_SHORTID ${_shortid} PARENT_SCOPE)
77 set(${prefix}_REVISION_NAME ${_wc_name} PARENT_SCOPE)
79 # For backwards compatibility
80 set(${prefix}_WC_REVISION_HASH ${_wc_id} PARENT_SCOPE)
81 set(${prefix}_WC_REVISION_NAME ${_wc_name} PARENT_SCOPE)
mitkFunctionGetVersion(source_dir, prefix)
Extract version information from a local working copy.
GIT_IS_REPO(dir, result_var)
static void info(const char *fmt,...)