all repos — mgba @ 3f05b12bc11d152c51516470b763939e05a842cb

mGBA Game Boy Advance Emulator

version.cmake (view raw)

 1if(NOT PROJECT_NAME)
 2	set(PROJECT_NAME "mGBA")
 3endif()
 4set(LIB_VERSION_MAJOR 0)
 5set(LIB_VERSION_MINOR 7)
 6set(LIB_VERSION_PATCH 0)
 7set(LIB_VERSION_ABI 0.7)
 8set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
 9set(SUMMARY "${PROJECT_NAME} Game Boy Advance Emulator")
10
11find_program(GIT git)
12if(GIT AND NOT SKIP_GIT)
13	execute_process(COMMAND ${GIT} describe --always --abbrev=40 --dirty WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
14	execute_process(COMMAND ${GIT} describe --always --dirty WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_COMMIT_SHORT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
15	execute_process(COMMAND ${GIT} symbolic-ref --short HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
16	execute_process(COMMAND ${GIT} rev-list HEAD --count WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_REV ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
17	execute_process(COMMAND ${GIT} describe --tag --exact-match WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
18endif()
19
20if(NOT GIT_REV)
21	set(GIT_REV -1)
22endif()
23if(GIT_TAG)
24	set(VERSION_STRING ${GIT_TAG})
25elseif(NOT GIT_BRANCH)
26	set(VERSION_STRING ${LIB_VERSION_STRING})
27else()
28	if(GIT_BRANCH STREQUAL "master" OR NOT GIT_BRANCH)
29		set(VERSION_STRING ${GIT_REV}-${GIT_COMMIT_SHORT})
30	else()
31		set(VERSION_STRING ${GIT_BRANCH}-${GIT_REV}-${GIT_COMMIT_SHORT})
32	endif()
33
34	if(NOT LIB_VERSION_ABI STREQUAL GIT_BRANCH)
35		set(VERSION_STRING ${LIB_VERSION_ABI}-${VERSION_STRING})
36	endif()
37endif()
38
39if(NOT GIT_COMMIT)
40	set(GIT_COMMIT "(unknown)")
41endif()
42if(NOT GIT_COMMIT_SHORT)
43	set(GIT_COMMIT_SHORT "(unknown)")
44endif()
45if(NOT GIT_BRANCH)
46	set(GIT_BRANCH "(unknown)")
47endif()
48
49if(DEFINED PRINT_STRING)
50	message("${${PRINT_STRING}}")
51elseif(NOT VERSION_STRING_CACHE OR NOT VERSION_STRING STREQUAL VERSION_STRING_CACHE)
52	set(VERSION_STRING_CACHE ${VERSION_STRING} CACHE STRING "" FORCE)
53
54	if(CONFIG_FILE AND OUT_FILE)
55		configure_file("${CONFIG_FILE}" "${OUT_FILE}")
56	endif()
57endif()