version.cmake (view raw)
1if(NOT PROJECT_NAME)
2 set(PROJECT_NAME "mGBA")
3endif()
4set(LIB_VERSION_MAJOR 0)
5set(LIB_VERSION_MINOR 5)
6set(LIB_VERSION_PATCH 0)
7set(LIB_VERSION_ABI 0.5)
8set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
9set(SUMMARY "${PROJECT_NAME} Game Boy Advance Emulator")
10
11execute_process(COMMAND git describe --always --abbrev=40 --dirty OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
12execute_process(COMMAND git describe --always --dirty OUTPUT_VARIABLE GIT_COMMIT_SHORT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
13execute_process(COMMAND git symbolic-ref --short HEAD OUTPUT_VARIABLE GIT_BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
14execute_process(COMMAND git rev-list HEAD --count OUTPUT_VARIABLE GIT_REV ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
15execute_process(COMMAND git describe --tag --exact-match OUTPUT_VARIABLE GIT_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
16
17if(GIT_REV STREQUAL "")
18 set(GIT_REV -1)
19endif()
20if(NOT GIT_TAG STREQUAL "")
21 set(VERSION_STRING ${GIT_TAG})
22elseif(GIT_BRANCH STREQUAL "")
23 set(VERSION_STRING ${LIB_VERSION_STRING})
24else()
25 if(GIT_BRANCH STREQUAL "master")
26 set(VERSION_STRING ${GIT_REV}-${GIT_COMMIT_SHORT})
27 else()
28 set(VERSION_STRING ${GIT_BRANCH}-${GIT_REV}-${GIT_COMMIT_SHORT})
29 endif()
30
31 if(NOT LIB_VERSION_ABI STREQUAL GIT_BRANCH)
32 set(VERSION_STRING ${LIB_VERSION_ABI}-${VERSION_STRING})
33 endif()
34endif()
35
36if(NOT GIT_COMMIT)
37 set(GIT_COMMIT "(unknown)")
38endif()
39if(NOT GIT_COMMIT_SHORT)
40 set(GIT_COMMIT_SHORT "(unknown)")
41endif()
42if(NOT GIT_BRANCH)
43 set(GIT_BRANCH "(unknown)")
44endif()
45
46if(CONFIG_FILE AND OUT_FILE)
47 configure_file("${CONFIG_FILE}" "${OUT_FILE}")
48endif()