Warning, /education/labplot/src/3rdparty/Qt-Advanced-Docking-System/cmake/modules/GetGitRevisionDescription.cmake is written in an unsupported language. File is not indexed.
0001 # - Returns a version string from Git 0002 # 0003 # These functions force a re-configure on each git commit so that you can 0004 # trust the values of the variables in your build system. 0005 # 0006 # get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...]) 0007 # 0008 # Returns the refspec and sha hash of the current head revision 0009 # 0010 # git_describe(<var> [<additional arguments to git describe> ...]) 0011 # 0012 # Returns the results of git describe on the source tree, and adjusting 0013 # the output so that it tests false if an error occurs. 0014 # 0015 # git_get_exact_tag(<var> [<additional arguments to git describe> ...]) 0016 # 0017 # Returns the results of git describe --exact-match on the source tree, 0018 # and adjusting the output so that it tests false if there was no exact 0019 # matching tag. 0020 # 0021 # git_local_changes(<var>) 0022 # 0023 # Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. 0024 # Uses the return code of "git diff-index --quiet HEAD --". 0025 # Does not regard untracked files. 0026 # 0027 # Requires CMake 2.6 or newer (uses the 'function' command) 0028 # 0029 # Original Author: 0030 # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> 0031 # http://academic.cleardefinition.com 0032 # Iowa State University HCI Graduate Program/VRAC 0033 # 0034 # Copyright Iowa State University 2009-2010. 0035 # Distributed under the Boost Software License, Version 1.0. 0036 # (See accompanying file LICENSE_1_0.txt or copy at 0037 # http://www.boost.org/LICENSE_1_0.txt) 0038 0039 if(__get_git_revision_description) 0040 return() 0041 endif() 0042 set(__get_git_revision_description YES) 0043 0044 # We must run the following at "include" time, not at function call time, 0045 # to find the path to this module rather than the path to a calling list file 0046 get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) 0047 0048 function(get_git_head_revision _refspecvar _hashvar) 0049 set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 0050 set(GIT_DIR "${GIT_PARENT_DIR}/.git") 0051 while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories 0052 set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") 0053 get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) 0054 if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) 0055 # We have reached the root directory, we are not in git 0056 set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 0057 set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 0058 return() 0059 endif() 0060 set(GIT_DIR "${GIT_PARENT_DIR}/.git") 0061 endwhile() 0062 # check if this is a submodule 0063 if(NOT IS_DIRECTORY ${GIT_DIR}) 0064 file(READ ${GIT_DIR} submodule) 0065 string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) 0066 get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) 0067 get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) 0068 endif() 0069 if(NOT IS_DIRECTORY "${GIT_DIR}") 0070 file(READ ${GIT_DIR} worktree) 0071 string(REGEX REPLACE "gitdir: (.*)worktrees(.*)\n$" "\\1" GIT_DIR ${worktree}) 0072 endif() 0073 set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") 0074 if(NOT EXISTS "${GIT_DATA}") 0075 file(MAKE_DIRECTORY "${GIT_DATA}") 0076 endif() 0077 0078 if(NOT EXISTS "${GIT_DIR}/HEAD") 0079 return() 0080 endif() 0081 set(HEAD_FILE "${GIT_DATA}/HEAD") 0082 configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) 0083 0084 configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" 0085 "${GIT_DATA}/grabRef.cmake" 0086 @ONLY) 0087 include("${GIT_DATA}/grabRef.cmake") 0088 0089 set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) 0090 set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) 0091 endfunction() 0092 0093 function(git_describe _var) 0094 if(NOT GIT_FOUND) 0095 find_package(Git QUIET) 0096 endif() 0097 get_git_head_revision(refspec hash) 0098 if(NOT GIT_FOUND) 0099 set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) 0100 return() 0101 endif() 0102 if(NOT hash) 0103 set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) 0104 return() 0105 endif() 0106 0107 # TODO sanitize 0108 #if((${ARGN}" MATCHES "&&") OR 0109 # (ARGN MATCHES "||") OR 0110 # (ARGN MATCHES "\\;")) 0111 # message("Please report the following error to the project!") 0112 # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") 0113 #endif() 0114 0115 #message(STATUS "Arguments to execute_process: ${ARGN}") 0116 0117 execute_process(COMMAND 0118 "${GIT_EXECUTABLE}" 0119 describe 0120 ${hash} 0121 ${ARGN} 0122 WORKING_DIRECTORY 0123 "${CMAKE_CURRENT_SOURCE_DIR}" 0124 RESULT_VARIABLE 0125 res 0126 OUTPUT_VARIABLE 0127 out 0128 ERROR_QUIET 0129 OUTPUT_STRIP_TRAILING_WHITESPACE) 0130 if(NOT res EQUAL 0) 0131 set(out "${out}-${res}-NOTFOUND") 0132 endif() 0133 0134 set(${_var} "${out}" PARENT_SCOPE) 0135 endfunction() 0136 0137 function(git_get_exact_tag _var) 0138 git_describe(out --exact-match ${ARGN}) 0139 set(${_var} "${out}" PARENT_SCOPE) 0140 endfunction() 0141 0142 function(git_local_changes _var) 0143 if(NOT GIT_FOUND) 0144 find_package(Git QUIET) 0145 endif() 0146 get_git_head_revision(refspec hash) 0147 if(NOT GIT_FOUND) 0148 set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) 0149 return() 0150 endif() 0151 if(NOT hash) 0152 set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) 0153 return() 0154 endif() 0155 0156 execute_process(COMMAND 0157 "${GIT_EXECUTABLE}" 0158 diff-index --quiet HEAD -- 0159 WORKING_DIRECTORY 0160 "${CMAKE_CURRENT_SOURCE_DIR}" 0161 RESULT_VARIABLE 0162 res 0163 OUTPUT_VARIABLE 0164 out 0165 ERROR_QUIET 0166 OUTPUT_STRIP_TRAILING_WHITESPACE) 0167 if(res EQUAL 0) 0168 set(${_var} "CLEAN" PARENT_SCOPE) 0169 else() 0170 set(${_var} "DIRTY" PARENT_SCOPE) 0171 endif() 0172 endfunction()