danicoin/src/version.cmake

30 lines
1.3 KiB
CMake
Raw Normal View History

execute_process(COMMAND "${GIT}" rev-parse --short HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
2014-03-03 22:07:58 +00:00
if(RET)
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
set(VERSIONTAG "unknown")
2014-03-03 22:07:58 +00:00
configure_file("src/version.h.in" "${TO}")
else()
message(STATUS "You are currently on commit ${COMMIT}")
2014-09-15 18:15:26 +00:00
execute_process(COMMAND "${GIT}" show-ref --tags -d --abbrev RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMITOUT OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE " refs/" "\n" TAGGEDCOMMITOUT2 ${TAGGEDCOMMITOUT})
string(REPLACE "\n" ";" TAGGEDCOMMITLIST ${TAGGEDCOMMITOUT2})
list(GET TAGGEDCOMMITLIST -2 TAGGEDCOMMIT)
if(RET OR NOT TAGGEDCOMMIT)
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
set(VERSIONTAG "${COMMIT}")
else()
message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
2014-09-12 11:27:30 +00:00
if(${COMMIT} MATCHES ${TAGGEDCOMMIT})
message(STATUS "You are building a tagged release")
set(VERSIONTAG "release")
else()
message(STATUS "You are ahead or behind of a tagged release")
set(VERSIONTAG "${COMMIT}")
endif()
endif()
2014-03-03 22:07:58 +00:00
configure_file("src/version.h.in" "${TO}")
endif()