Computer Assisted Medical Intervention Tool Kit  version 5.2
GetGitInfo.h
Go to the documentation of this file.
1 get_git_info(){ PATH_TO_SOURCE_DIR)
15  unset(CAMITK_GIT_COMMIT_COUNT)
16  execute_process(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
17  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
18  OUTPUT_VARIABLE CAMITK_GIT_COMMIT_COUNT
19  OUTPUT_STRIP_TRAILING_WHITESPACE
20  )
21 
22  unset(CAMITK_GIT_BRANCH)
23  execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
24  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
25  OUTPUT_VARIABLE CAMITK_GIT_BRANCH
26  OUTPUT_STRIP_TRAILING_WHITESPACE
27  )
28 
29  unset(CAMITK_GIT_ABBREVIATED_HASH)
30  execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
31  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
32  OUTPUT_VARIABLE CAMITK_GIT_ABBREVIATED_HASH
33  OUTPUT_STRIP_TRAILING_WHITESPACE
34  )
35 
36  unset(CAMITK_GIT_HASH)
37  execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
38  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
39  OUTPUT_VARIABLE CAMITK_GIT_HASH
40  OUTPUT_STRIP_TRAILING_WHITESPACE
41  )
42 
43  unset(CAMITK_GIT_COMMITER_DATE)
44  execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd
45  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
46  OUTPUT_VARIABLE CAMITK_GIT_COMMITER_DATE
47  OUTPUT_STRIP_TRAILING_WHITESPACE
48  )
49 
50  unset(CAMITK_ORIGIN_DEVELOP_GIT_HASH)
51  execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse origin/develop
52  WORKING_DIRECTORY ${PATH_TO_SOURCE_DIR}
53  OUTPUT_VARIABLE CAMITK_ORIGIN_DEVELOP_GIT_HASH
54  OUTPUT_STRIP_TRAILING_WHITESPACE
55  )
56 
57  string(SUBSTRING ${CAMITK_ORIGIN_DEVELOP_GIT_HASH} 0 8 CAMITK_ORIGIN_DEVELOP_GIT_ABBREVIATED_HASH)
58 
59  if(NOT CAMITK_GIT_COMMIT_COUNT)
60  message(WARNING "Unable to find the commit number using git : ${GIT_EXECUTABLE}")
61  set(CAMITK_GIT_COMMIT_COUNT "unknown")
62  set(CAMITK_GIT_BRANCH "unknown")
63  set(CAMITK_GIT_HASH "unknown")
64  set(CAMITK_GIT_ABBREVIATED_HASH "unknown")
65  set(CAMITK_ORIGIN_DEVELOP_GIT_HASH "unknown")
66  set(CAMITK_ORIGIN_DEVELOP_GIT_ABBREVIATED_HASH "unknown")
67  endif()
68 
69 end(){)
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
iwyu out CACHE PATH Output filename for include what you use set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE}) if(NOT EXISTS $
Definition: CamiTKIncludeWhatYouUse.h:22
test result unset(PREVIOUS_ATTEMPTS) file(GLOB ALL_OUTPUT_FILES $
Definition: CamiTKTestActionStateMachine.h:16
test result execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CAMITK_TEST_COMMAND_FILE} ${CAMITK_TEST_COMMAND_RESULT_FILE} ${CAMITK_TEST_COMMAND_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_COMMAND_FILE} ${CAMITK_TEST_PASS_FILE_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_RESULT_FILE}) file(WRITE $
Definition: CamiTKTestPassFile.h:21
get_git_info()
macro get_git_info get the last value of commit count.
Definition: GetGitInfo.h:14