all repos — mgba @ 817f1573d3b9fcdc8dc95acdd9ee2eaf86d70af0

mGBA Game Boy Advance Emulator

All: Move version generation to external CMake script
Jeffrey Pfau jeffrey@endrift.com
Sun, 12 Jul 2015 16:02:16 -0700
commit

817f1573d3b9fcdc8dc95acdd9ee2eaf86d70af0

parent

18ec3de2e2d12a1f81a5afa688bc14f28f6c2125

2 files changed, 34 insertions(+), 41 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -76,47 +76,11 @@ endforeach()

endfunction() # Version information -set(LIB_VERSION_MAJOR 0) -set(LIB_VERSION_MINOR 3) -set(LIB_VERSION_PATCH 0) -set(LIB_VERSION_ABI 0.3) -set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}) - -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) - -if(GIT_REV STREQUAL "") - set(GIT_REV -1) -endif() -if(NOT GIT_TAG STREQUAL "") - set(VERSION_STRING ${GIT_TAG}) -elseif(GIT_BRANCH STREQUAL "") - set(VERSION_STRING ${LIB_VERSION_STRING}) -else() - if(GIT_BRANCH STREQUAL "master") - set(VERSION_STRING ${GIT_REV}-${GIT_COMMIT_SHORT}) - else() - set(VERSION_STRING ${GIT_BRANCH}-${GIT_REV}-${GIT_COMMIT_SHORT}) - endif() - - if(NOT LIB_VERSION_ABI STREQUAL GIT_BRANCH) - set(VERSION_STRING ${LIB_VERSION_ABI}-${VERSION_STRING}) - endif() -endif() - add_custom_target(version-info ALL ${CMAKE_COMMAND} -E touch ${CMAKE_SOURCE_DIR}/src/util/version.c.in COMMAND ${CMAKE_COMMAND} - -DGIT_COMMIT=${GIT_COMMIT} - -DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT} - -DGIT_BRANCH=${GIT_BRANCH} - -DGIT_REV=${GIT_REV} -DBINARY_NAME=${BINARY_NAME} - -DPROJECT_NAME=${PROJECT_NAME} - -DVERSION_STRING=${VERSION_STRING} - -D${BINARY_NAME}_SOURCE_DIR=${CMAKE_SOURCE_DIR} + -DCONFIG_FILE=${CMAKE_SOURCE_DIR}/src/util/version.c.in + -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.c -P ${CMAKE_SOURCE_DIR}/version.cmake WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
M version.cmakeversion.cmake

@@ -1,5 +1,34 @@

-if(NOT ${BINARY_NAME}_SOURCE_DIR) - set(${BINARY_NAME}_SOURCE_DIR ${CMAKE_SOURCE_DIR}) +set(LIB_VERSION_MAJOR 0) +set(LIB_VERSION_MINOR 3) +set(LIB_VERSION_PATCH 0) +set(LIB_VERSION_ABI 0.3) +set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}) + +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) + +if(GIT_REV STREQUAL "") + set(GIT_REV -1) +endif() +if(NOT GIT_TAG STREQUAL "") + set(VERSION_STRING ${GIT_TAG}) +elseif(GIT_BRANCH STREQUAL "") + set(VERSION_STRING ${LIB_VERSION_STRING}) +else() + if(GIT_BRANCH STREQUAL "master") + set(VERSION_STRING ${GIT_REV}-${GIT_COMMIT_SHORT}) + else() + set(VERSION_STRING ${GIT_BRANCH}-${GIT_REV}-${GIT_COMMIT_SHORT}) + endif() + + if(NOT LIB_VERSION_ABI STREQUAL GIT_BRANCH) + set(VERSION_STRING ${LIB_VERSION_ABI}-${VERSION_STRING}) + endif() endif() -configure_file("${${BINARY_NAME}_SOURCE_DIR}/src/util/version.c.in" "${CMAKE_CURRENT_BINARY_DIR}/version.c") +if(CONFIG_FILE AND OUT_FILE) + configure_file("${CONFIG_FILE}" "${OUT_FILE}") +endif()