diff --git a/rpcs3/git-version.cmake b/rpcs3/git-version.cmake index 087a3c1bda..3a7ccaef12 100644 --- a/rpcs3/git-version.cmake +++ b/rpcs3/git-version.cmake @@ -10,13 +10,19 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/") OUTPUT_VARIABLE RPCS3_GIT_VERSION) if(NOT ${exit_code} EQUAL 0) message(WARNING "git rev-list failed, unable to include version.") + else() + string(STRIP ${RPCS3_GIT_VERSION} RPCS3_GIT_VERSION) endif() execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE exit_code + RESULT_VARIABLE exit_code2 OUTPUT_VARIABLE GIT_VERSION_) - if(NOT ${exit_code} EQUAL 0) + if(NOT ${exit_code2} EQUAL 0) message(WARNING "git rev-parse failed, unable to include version.") + string(STRIP ${GIT_VERSION_} GIT_VERSION_) + if(${exit_code} EQUAL 0) + string(STRIP ${RPCS3_GIT_VERSION}-${GIT_VERSION_} RPCS3_GIT_VERSION) + endif() endif() execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -24,6 +30,8 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/") OUTPUT_VARIABLE RPCS3_GIT_BRANCH) if(NOT ${exit_code} EQUAL 0) message(WARNING "git rev-parse failed, unable to include git branch.") + else() + string(STRIP ${RPCS3_GIT_BRANCH} RPCS3_GIT_BRANCH) endif() execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -31,14 +39,11 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/") OUTPUT_VARIABLE RPCS3_GIT_TAG) if(NOT ${exit_code} EQUAL 0) message(WARNING "git describe failed, unable to include git tag.") - endif() - - string(STRIP ${RPCS3_GIT_VERSION} RPCS3_GIT_VERSION) - string(STRIP ${GIT_VERSION_} GIT_VERSION_) - string(STRIP ${RPCS3_GIT_VERSION}-${GIT_VERSION_} RPCS3_GIT_VERSION) - string(STRIP ${RPCS3_GIT_BRANCH} RPCS3_GIT_BRANCH) - string(STRIP ${RPCS3_GIT_TAG} RPCS3_GIT_TAG) - string(REPLACE "v" "" RPCS3_GIT_TAG ${RPCS3_GIT_TAG}) + else() + string(STRIP ${RPCS3_GIT_TAG} RPCS3_GIT_TAG) + string(REPLACE "v" "" RPCS3_GIT_TAG ${RPCS3_GIT_TAG}) + endif() + else() message(WARNING "git not found, unable to include version.") endif() @@ -69,7 +74,8 @@ function(gen_git_version rpcs3_src_dir) set(code_string "// This is a generated file.\n\n" "#define RPCS3_GIT_VERSION \"${RPCS3_GIT_VERSION}\"\n" - "#define RPCS3_GIT_BRANCH \"${RPCS3_GIT_BRANCH}\"\n\n" + "#define RPCS3_GIT_BRANCH \"${RPCS3_GIT_BRANCH}\"\n" + "#define RPCS3_GIT_TAG \"${RPCS3_GIT_TAG}\"\n\n" "// If you don't want this file to update/recompile, change to 1.\n" "#define RPCS3_GIT_VERSION_NO_UPDATE 0\n")