cmake: explicit GIT_TAG for releases

Tagged versions shouls use GIT_TAG instead of GIT_DESC+GIT_COMMIT
When using GIT_TAG, apk download will be done from WiVRn releases
In other cases, GIT_COMMIT will be used to download from WiVRn-APK
releases.

If none is set, git is used to compute the values
This commit is contained in:
Patrick Nicolas
2026-06-14 17:25:12 +02:00
parent 0f6da3498e
commit 29b1770ba0
8 changed files with 80 additions and 47 deletions
+44 -22
View File
@@ -1,32 +1,54 @@
if (NOT GIT_DESC)
if (GIT_TAG AND (GIT_DESC OR GIT_COMMIT))
message(FATAL_ERROR "cannot use GIT_DESC or GIT_COMMIT when using GIT_TAG")
endif()
if (NOT (GIT_TAG OR GIT_DESC OR GIT_COMMIT))
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
OUTPUT_VARIABLE GIT_DESC
COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(STRIP "${GIT_DESC}" GIT_DESC)
message(STATUS "Setting version to ${GIT_DESC} from git")
endif()
if (GIT_TAG)
set(GIT_DESC "${GIT_TAG}")
set(GIT_COMMIT "${GIT_TAG}")
set(GIT_TAG true)
message(STATUS "Building for git tag ${GIT_DESC}")
else()
message(STATUS "Setting version to ${GIT_DESC} from parameters")
endif()
if (NOT GIT_DESC)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
OUTPUT_VARIABLE GIT_DESC
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
message(STATUS "Setting version to ${GIT_DESC} from git")
else()
message(STATUS "Setting version to ${GIT_DESC} from parameters")
endif()
if (NOT GIT_COMMIT)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(STRIP "${GIT_COMMIT}" GIT_COMMIT)
endif()
if (NOT GIT_COMMIT)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(STRIP "${GIT_COMMIT}" GIT_COMMIT)
endif()
if (NOT GIT_DESC)
message(FATAL_ERROR "GIT_DESC cannot be inferred from .git and was not provided at build time")
endif()
if (NOT GIT_DESC)
message(FATAL_ERROR "GIT_DESC cannot be inferred from .git and was not provided at build time")
endif()
if (GIT_COMMIT)
message(STATUS "Setting commit to ${GIT_COMMIT}")
else()
message(FATAL_ERROR "GIT_COMMIT cannot be inferred from .git and was not provided at build time")
if (GIT_COMMIT)
message(STATUS "Setting commit to ${GIT_COMMIT}")
else()
message(FATAL_ERROR "GIT_COMMIT cannot be inferred from .git and was not provided at build time")
endif()
set(GIT_TAG false)
endif()
configure_file(${INPUT_FILE} ${OUTPUT_FILE})