# Adds version control information to the variable VERS. For
# determining the Version Control System used (if any) it inspects the
# existence of certain subdirectories under SOURCE_DIR (if provided as an
# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
function(get_source_info path revision repository
)
WORKING_DIRECTORY ${path}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_QUIET)
string(STRIP "${git_output}" git_output
)
WORKING_DIRECTORY ${path}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
string(STRIP "${git_output}" git_output
)
set(${revision} ${git_output} PARENT_SCOPE)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref --symbolic-full-name @{upstream}
WORKING_DIRECTORY ${path}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_QUIET)
string(REPLACE "/" ";" branch
${git_output})
list(GET branch 0 remote
)
WORKING_DIRECTORY ${path}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_QUIET)
string(STRIP "${git_output}" git_output
)
set(${repository} ${git_output} PARENT_SCOPE)
set(${repository} ${path} PARENT_SCOPE)
message(WARNING
"Git not found. Version cannot be determined.")