Skip to content

Commit

Permalink
Use git version if git available
Browse files Browse the repository at this point in the history
  • Loading branch information
IssMneur committed Sep 4, 2016
1 parent 8f27729 commit 26ece56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
37 changes: 10 additions & 27 deletions 3rdparty/GetVersionFromGitTag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Author: Nuno Fachada

# Check if git is found...
if (GIT_FOUND AND VERSION_UPDATE_FROM_GIT)
if (GIT_EXECUTABLE)

# Get last tag from git
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags
Expand Down Expand Up @@ -79,33 +79,16 @@ if (GIT_FOUND AND VERSION_UPDATE_FROM_GIT)
# Set full project version string
set(${PROJECT_NAME}_VERSION_STRING_FULL
${${PROJECT_NAME}_VERSION_STRING}+${${PROJECT_NAME}_VERSION_AHEAD}.${${PROJECT_NAME}_VERSION_GIT_SHA})

# Save version to file (which will be used when Git is not available
# or VERSION_UPDATE_FROM_GIT is disabled)
file(WRITE ${CMAKE_SOURCE_DIR}/VERSION ${${PROJECT_NAME}_VERSION_STRING_FULL}
"*" ${${PROJECT_NAME}_VERSION_STRING}
"*" ${${PROJECT_NAME}_VERSION_MAJOR}
"*" ${${PROJECT_NAME}_VERSION_MINOR}
"*" ${${PROJECT_NAME}_VERSION_PATCH}
"*" ${${PROJECT_NAME}_VERSION_TWEAK}
"*" ${${PROJECT_NAME}_VERSION_AHEAD}
"*" ${${PROJECT_NAME}_VERSION_GIT_SHA})

else()

# Git not available, get version from file
file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION ${PROJECT_NAME}_VERSION_LIST)
string(REPLACE "*" ";" ${PROJECT_NAME}_VERSION_LIST ${${PROJECT_NAME}_VERSION_LIST})
# Set partial versions
list(GET ${PROJECT_NAME}_VERSION_LIST 0 ${PROJECT_NAME}_VERSION_STRING_FULL)
list(GET ${PROJECT_NAME}_VERSION_LIST 1 ${PROJECT_NAME}_VERSION_STRING)
list(GET ${PROJECT_NAME}_VERSION_LIST 2 ${PROJECT_NAME}_VERSION_MAJOR)
list(GET ${PROJECT_NAME}_VERSION_LIST 3 ${PROJECT_NAME}_VERSION_MINOR)
list(GET ${PROJECT_NAME}_VERSION_LIST 4 ${PROJECT_NAME}_VERSION_PATCH)
list(GET ${PROJECT_NAME}_VERSION_LIST 5 ${PROJECT_NAME}_VERSION_TWEAK)
list(GET ${PROJECT_NAME}_VERSION_LIST 6 ${PROJECT_NAME}_VERSION_AHEAD)
list(GET ${PROJECT_NAME}_VERSION_LIST 7 ${PROJECT_NAME}_VERSION_GIT_SHA)

# Git not available, use fake version
set(${PROJECT_NAME}_VERSION_STRING_FULL "v0.0.0-unknown+1.1234567")
set(${PROJECT_NAME}_VERSION_STRING "v0.0.0-unknown")
set(${PROJECT_NAME}_VERSION_MAJOR "0")
set(${PROJECT_NAME}_VERSION_MINOR "0")
set(${PROJECT_NAME}_VERSION_PATCH "0")
set(${PROJECT_NAME}_VERSION_TWEAK "0")
set(${PROJECT_NAME}_VERSION_AHEAD "0")
set(${PROJECT_NAME}_VERSION_GIT_SHA "1234567")
endif()


Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ set(3RD_PARTY_SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty)

find_program(GIT_EXECUTABLE git)

set(VERSION_UPDATE_FROM_GIT ON)
include(${3RD_PARTY_SOURCE_DIR}/GetVersionFromGitTag.cmake)

message("--- Configuring wxLauncher ${wxlauncher_VERSION_STRING_FULL}")
Expand Down

0 comments on commit 26ece56

Please sign in to comment.