From b92a8b53e001c37c6397caeee7d5ed44bc73fc0b Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 15 Sep 2014 20:15:26 +0200 Subject: [PATCH] fix CMake for multiplatform versioning --- src/version.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/version.cmake b/src/version.cmake index c115b9d36..e851cdf01 100644 --- a/src/version.cmake +++ b/src/version.cmake @@ -6,7 +6,12 @@ if(RET) configure_file("src/version.h.in" "${TO}") else() message(STATUS "You are currently on commit ${COMMIT}") - execute_process(COMMAND "${GIT}" show-ref --tags -d --abbrev COMMAND awk "END{print $1}" RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) + 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}")