Fix versioning system

This commit is contained in:
pixl 2020-07-15 13:16:43 -04:00
parent c83739beb9
commit b75b9794d1
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E

View File

@ -14,37 +14,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Git) find_package(Git)
# Set version number # Set version number
if(EXISTS ${CMAKE_SOURCE_DIR}/version.txt) if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} describe
OUTPUT_VARIABLE LOGIOPS_VERSION
RESULT_VARIABLE LOGIOPS_VERSION_RET
ERROR_QUIET)
if(NOT LOGIOPS_VERSION_RET EQUAL "0")
execute_process(COMMAND ${GIT_EXECUTABLE}
rev-parse --short HEAD
OUTPUT_VARIABLE LOGIOPS_COMMIT_HASH)
set(LOGIOPS_VERSION git-${LOGIOPS_COMMIT_HASH})
endif()
string(REGEX REPLACE "\n$" "" LOGIOPS_VERSION ${LOGIOPS_VERSION})
elseif(EXISTS ${CMAKE_SOURCE_DIR}/version.txt)
file(READ version.txt LOGIOPS_VERSION) file(READ version.txt LOGIOPS_VERSION)
string(REGEX REPLACE "\n$" "" LOGIOPS_VERSION ${LOGIOPS_VERSION}) string(REGEX REPLACE "\n$" "" LOGIOPS_VERSION ${LOGIOPS_VERSION})
endif() endif()
if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) if(NOT LOGIOPS_VERSION)
execute_process(COMMAND ${GIT_EXECUTABLE}
rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE LOGIOPS_GIT_BRANCH)
string(REGEX REPLACE "\n$" "" LOGIOPS_GIT_BRANCH ${LOGIOPS_GIT_BRANCH})
if(LOGIOPS_GIT_BRANCH MATCHES "^tags/?")
STRING(REGEX REPLACE "^tags/" ""
LOGIOPS_VERSION ${LOGIOPS_GIT_BRANCH})
else()
execute_process(COMMAND ${GIT_EXECUTABLE}
rev-parse --short HEAD
OUTPUT_VARIABLE LOGIOPS_COMMIT_HASH)
string(REGEX REPLACE "\n$" "" LOGIOPS_COMMIT_HASH ${LOGIOPS_COMMIT_HASH})
if(LOGIOPS_VERSION)
string(APPEND LOGIOPS_VERSION -${LOGIOPS_COMMIT_HASH})
else()
set(LOGIOPS_VERSION git-${LOGIOPS_COMMIT_HASH})
endif()
endif()
endif()
if(LOGIOPS_VERSION)
message("LogiOps Version Number: ${LOGIOPS_VERSION}")
else()
set(LOGIOPS_VERSION "null") set(LOGIOPS_VERSION "null")
endif() endif()
message("LogiOps Version Number: ${LOGIOPS_VERSION}")
add_definitions( -DLOGIOPS_VERSION="${LOGIOPS_VERSION}") add_definitions( -DLOGIOPS_VERSION="${LOGIOPS_VERSION}")