cmake: Get CPACK_PACKAGE_VERSION from git tag.
Change-Id: Iaa4ef8e346f926df52d43277d4d9c967425af54f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/apitrace/+/2224538
Reviewed-by: Po-Hsien Wang <pwang@chromium.org>
Commit-Queue: Robert Tarasov <tutankhamen@chromium.org>
Tested-by: Robert Tarasov <tutankhamen@chromium.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19316e6..5db3128 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -639,14 +639,15 @@
RENAME LICENSE.txt
)
-set (CPACK_PACKAGE_VERSION_MAJOR "9")
-set (CPACK_PACKAGE_VERSION_MINOR "0")
-
-# Use current date in YYYYMMDD format as patch number
-execute_process (
- COMMAND ${Python3_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))"
- OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH
-)
+set (CPACK_PACKAGE_VERSION "latest")
+# https://www.appveyor.com/docs/environment-variables/
+if (($ENV{APPVEYOR}) AND ($ENV{APPVEYOR_REPO_TAG}))
+ set (CPACK_PACKAGE_VERSION "$ENV{APPVEYOR_REPO_TAG_NAME}")
+endif ()
+# https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
+if (($ENV{TRAVIS}) AND NOT "$ENV{TRAVIS_TAG}" STREQUAL "")
+ set (CPACK_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
+endif ()
# cpack mistakenly detects Mingw-w64 as win32
if (MINGW)