Commit 8907fead authored by Simon Spannagel's avatar Simon Spannagel
Browse files

CMake: check if we are on a tag

parent 430542f1
Pipeline #592716 failed with stages
in 13 minutes and 40 seconds
...@@ -7,6 +7,8 @@ FUNCTION(get_version PROJECT_VERSION) ...@@ -7,6 +7,8 @@ FUNCTION(get_version PROJECT_VERSION)
# Set package version # Set package version
IF(NOT SOURCE_PACKAGE) IF(NOT SOURCE_PACKAGE)
SET(TAG_FOUND FALSE)
# Get the version from last git tag plus number of additional commits: # Get the version from last git tag plus number of additional commits:
FIND_PACKAGE(Git QUIET) FIND_PACKAGE(Git QUIET)
IF(GIT_FOUND) IF(GIT_FOUND)
...@@ -19,14 +21,23 @@ FUNCTION(get_version PROJECT_VERSION) ...@@ -19,14 +21,23 @@ FUNCTION(get_version PROJECT_VERSION)
ELSE(PROJECT_STATUS STREQUAL "") ELSE(PROJECT_STATUS STREQUAL "")
MESSAGE(STATUS "Git project directory is dirty:\n ${PROJECT_STATUS}.") MESSAGE(STATUS "Git project directory is dirty:\n ${PROJECT_STATUS}.")
ENDIF(PROJECT_STATUS STREQUAL "") ENDIF(PROJECT_STATUS STREQUAL "")
EXEC_PROGRAM(git ${CMAKE_CURRENT_SOURCE_DIR} ARGS describe --exact-match --tags HEAD OUTPUT_VARIABLE GIT_TAG RETURN_VALUE GIT_RETURN)
IF(GIT_RETURN EQUAL 0)
SET(TAG_FOUND TRUE)
ENDIF()
ELSE(GIT_FOUND) ELSE(GIT_FOUND)
MESSAGE(STATUS "Git repository present, but could not find git executable.") MESSAGE(STATUS "Git repository present, but could not find git executable.")
ENDIF(GIT_FOUND) ENDIF(GIT_FOUND)
ELSE(NOT SOURCE_PACKAGE) ELSE(NOT SOURCE_PACKAGE)
# If we don't have git we can not really do anything # If we don't have git we can not really do anything
MESSAGE(STATUS "Source tarball build - no repository present.") MESSAGE(STATUS "Source tarball build - no repository present.")
SET(TAG_FOUND TRUE)
ENDIF(NOT SOURCE_PACKAGE) ENDIF(NOT SOURCE_PACKAGE)
# Set the project version in the parent scope
SET(TAG_FOUND ${TAG_FOUND} PARENT_SCOPE)
# Set the project version in the parent scope # Set the project version in the parent scope
SET(${PROJECT_VERSION} ${${PROJECT_VERSION}} PARENT_SCOPE) SET(${PROJECT_VERSION} ${${PROJECT_VERSION}} PARENT_SCOPE)
ENDFUNCTION() ENDFUNCTION()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment