Require commit ID and tag name via CMake vars if git is not found
On OBS for instance, cmake can be invoked like cmake -DGIT_COMMIT=xxx -DGIT_TAG_NAME=xxx to collect the required information. Fixes #308
This commit is contained in:
+12
-4
@@ -7,15 +7,22 @@ project(linuxdeployqt)
|
|||||||
|
|
||||||
find_program(GIT git)
|
find_program(GIT git)
|
||||||
|
|
||||||
|
if("${GIT}" STREQUAL "GIT-NOTFOUND")
|
||||||
|
message(WARNING "Could not find git, commit and tag info cannot be updated")
|
||||||
|
|
||||||
|
if(NOT GIT_COMMIT)
|
||||||
|
message(FATAL_ERROR "Commit ID not set, please call with -DGIT_COMMIT=...")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT GIT_TAG_NAME)
|
||||||
|
message(FATAL_ERROR "Tag name not set, please call with -DGIT_TAG_NAME=...")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
# make sure Git revision ID and latest tag is not stored in the CMake cache
|
# make sure Git revision ID and latest tag is not stored in the CMake cache
|
||||||
# otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date
|
# otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date
|
||||||
unset(GIT_COMMIT CACHE)
|
unset(GIT_COMMIT CACHE)
|
||||||
unset(GIT_LATEST_TAG CACHE)
|
unset(GIT_LATEST_TAG CACHE)
|
||||||
|
|
||||||
if("${GIT}" STREQUAL "GIT-NOTFOUND")
|
|
||||||
message(FATAL_ERROR "Could not find git")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# read Git revision ID and latest tag number
|
# read Git revision ID and latest tag number
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${GIT}" rev-parse --short HEAD
|
COMMAND "${GIT}" rev-parse --short HEAD
|
||||||
@@ -52,6 +59,7 @@ if(NOT GIT_TAG_NAME_RESULT EQUAL 0)
|
|||||||
message(FATAL_ERROR "Failed to determine git tag name")
|
message(FATAL_ERROR "Failed to determine git tag name")
|
||||||
endif()
|
endif()
|
||||||
mark_as_advanced(GIT_TAG_NAME GIT_TAG_NAME_RESULT)
|
mark_as_advanced(GIT_TAG_NAME GIT_TAG_NAME_RESULT)
|
||||||
|
endif()
|
||||||
|
|
||||||
# set version and build number
|
# set version and build number
|
||||||
set(VERSION 1-alpha)
|
set(VERSION 1-alpha)
|
||||||
|
|||||||
Reference in New Issue
Block a user