all repos — mgba @ 0d6efaa3dc3ab5a19b0a2e7a0d93fad50a53e324

mGBA Game Boy Advance Emulator

CMake: Clean up version.cmake git checking
Vicki Pfau vi@endrift.com
Thu, 26 Jan 2017 21:54:52 -0800
commit

0d6efaa3dc3ab5a19b0a2e7a0d93fad50a53e324

parent

12a5b6c0bd52c3a827a8c0a3186e3dc791fa175c

1 files changed, 12 insertions(+), 9 deletions(-)

jump to
M version.cmakeversion.cmake

@@ -8,21 +8,24 @@ set(LIB_VERSION_ABI 0.6)

set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}) set(SUMMARY "${PROJECT_NAME} Game Boy Advance Emulator") -execute_process(COMMAND git describe --always --abbrev=40 --dirty OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git describe --always --dirty OUTPUT_VARIABLE GIT_COMMIT_SHORT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git symbolic-ref --short HEAD OUTPUT_VARIABLE GIT_BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git rev-list HEAD --count OUTPUT_VARIABLE GIT_REV ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git describe --tag --exact-match OUTPUT_VARIABLE GIT_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) +find_program(GIT git) +if(GIT AND NOT SKIP_GIT) + execute_process(COMMAND ${GIT} describe --always --abbrev=40 --dirty OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT} describe --always --dirty OUTPUT_VARIABLE GIT_COMMIT_SHORT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT} symbolic-ref --short HEAD OUTPUT_VARIABLE GIT_BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT} rev-list HEAD --count OUTPUT_VARIABLE GIT_REV ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT} describe --tag --exact-match OUTPUT_VARIABLE GIT_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() -if(GIT_REV STREQUAL "") +if(NOT GIT_REV) set(GIT_REV -1) endif() -if(NOT GIT_TAG STREQUAL "") +if(GIT_TAG) set(VERSION_STRING ${GIT_TAG}) -elseif(GIT_BRANCH STREQUAL "") +elseif(NOT GIT_BRANCH) set(VERSION_STRING ${LIB_VERSION_STRING}) else() - if(GIT_BRANCH STREQUAL "master") + if(GIT_BRANCH STREQUAL "master" OR NOT GIT_BRANCH) set(VERSION_STRING ${GIT_REV}-${GIT_COMMIT_SHORT}) else() set(VERSION_STRING ${GIT_BRANCH}-${GIT_REV}-${GIT_COMMIT_SHORT})