diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2024-04-03 16:41:45 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2024-04-11 08:23:49 +0000 |
commit | cc56353c33f7be1c194ccea982285197f0056c00 (patch) | |
tree | 8238ce28395a4f3d9dfc2ef719a8ed588e407a69 | |
parent | 6f946168d656f096a65d7ba09b1b1dd15fdbac0e (diff) |
Read commit sha from .tag file as a fallback
The source artifacts in coin are not in a git repository, so the
revision information was missing from the official binaries.
Add .gitattributes with export-subst attribute for the .tag file
to expand the placeholder when adding the file to archive.
Task-number: QLS-856
Pick-to: 3.0
Change-Id: I6f584961e548a4b44d5a5fb52f49e7ca67ce4e9f
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r-- | .gitattributes | 3 | ||||
-rw-r--r-- | .tag | 1 | ||||
-rw-r--r-- | src/include/CMakeLists.txt | 8 |
3 files changed, 12 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..018cf2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.tag export-subst +.gitignore export-ignore +.gitattributes export-ignore @@ -0,0 +1 @@ +$Format:%H$ diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index d7abbe2..f96931b 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -12,5 +12,13 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) +# If git command failed or resulting variable is empty, try to read from .tag file +if (NOT GIT_COMMIT_SHA) + file(READ "${CMAKE_SOURCE_DIR}/.tag" TAG_CONTENT) + string(STRIP ${TAG_CONTENT} GIT_COMMIT_SHA) +endif() + +message("Commit SHA: ${GIT_COMMIT_SHA}") + configure_file(commonsetup.h.in ${CMAKE_BINARY_DIR}/include/commonsetup.h) configure_file(version.h.in ${CMAKE_BINARY_DIR}/include/version.h) |