Skip to content
Snippets Groups Projects
Verified Commit e1e5c8e7 authored by Martin Stump's avatar Martin Stump
Browse files

build: read the project version from Git


Signed-off-by: default avatarMartin Stump <martin.stump@mercedes-benz.com>
parent 04e7d773
No related branches found
No related tags found
No related merge requests found
......@@ -17,10 +17,15 @@
#
################################################################################
find_package(Git REQUIRED)
find_package(Git)
if(NOT GIT_FOUND)
message(AUTHOR_WARNING "Git not found. Version information will not be available.")
return()
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always
COMMAND ${GIT_EXECUTABLE} describe --tags --always
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE PROJECT_VERSION_RESULT
OUTPUT_VARIABLE PROJECT_VERSION_STRING
......@@ -31,7 +36,7 @@ if(PROJECT_VERSION_RESULT EQUAL 0)
message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION_STRING}")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" PROJECT_VERSION "${PROJECT_VERSION_STRING}")
else()
message(AUTHOR_WARNING "Could not parse project version from Git.")
message(AUTHOR_WARNING "Could not read version information from Git.")
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/VERSION.in")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment