2021-12-08 11:32:04 +00:00
|
|
|
set(MYX_CMAKE_GIT_REV "N/A")
|
|
|
|
set(MYX_CMAKE_GIT_DIFF "")
|
|
|
|
set(MYX_CMAKE_GIT_TAG "N/A")
|
|
|
|
set(MYX_CMAKE_GIT_BRANCH "N/A")
|
|
|
|
|
|
|
|
find_program(GIT_EXECUTABLE git)
|
|
|
|
if(GIT_EXECUTABLE)
|
|
|
|
execute_process(COMMAND git log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE MYX_CMAKE_GIT_REV ERROR_QUIET)
|
|
|
|
|
|
|
|
# Check whether we got any revision (which isn't always the case,
|
|
|
|
# e.g. when someone downloaded a zip file from Github instead of a checkout)
|
|
|
|
if(NOT "${MYX_CMAKE_GIT_REV}" STREQUAL "")
|
|
|
|
execute_process(COMMAND bash -c "git diff --quiet --exit-code || echo +" OUTPUT_VARIABLE MYX_CMAKE_GIT_DIFF)
|
|
|
|
execute_process(COMMAND git describe --exact-match --tags OUTPUT_VARIABLE MYX_CMAKE_GIT_TAG ERROR_QUIET)
|
|
|
|
execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE MYX_CMAKE_GIT_BRANCH)
|
|
|
|
|
|
|
|
string(STRIP "${MYX_CMAKE_GIT_REV}" MYX_CMAKE_GIT_REV)
|
|
|
|
string(SUBSTRING "${MYX_CMAKE_GIT_REV}" 1 7 MYX_CMAKE_GIT_REV)
|
|
|
|
string(STRIP "${MYX_CMAKE_GIT_DIFF}" MYX_CMAKE_GIT_DIFF)
|
|
|
|
string(STRIP "${MYX_CMAKE_GIT_TAG}" MYX_CMAKE_GIT_TAG)
|
|
|
|
string(STRIP "${MYX_CMAKE_GIT_BRANCH}" MYX_CMAKE_GIT_BRANCH)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-09 11:41:26 +00:00
|
|
|
configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/hpp/myx_cmake_git_info.hpp.in ${MYX_CMAKE_GIT_INFO_FILE})
|