More CMake version number tweaking

This commit is contained in:
Andrew Nelless 2017-05-22 15:48:39 +01:00
parent ca830f267a
commit 8d92b7ad45
2 changed files with 29 additions and 22 deletions

View File

@ -39,8 +39,8 @@ if (NOT DEFINED SYNERGY_VERSION_MAJOR)
set (SYNERGY_VERSION_MAJOR $ENV{SYNERGY_VERSION_MAJOR})
else()
set (SYNERGY_VERSION_MAJOR 1)
message (WARNING
"SYNERGY_VERSION_MAJOR not set. Defaulted to ${SYNERGY_VERSION_MAJOR}")
set (SYNERGY_VERSION_WARNED 1)
message (WARNING "SYNERGY_VERSION_MAJOR not set. Defaulted to ${SYNERGY_VERSION_MAJOR}")
endif()
endif()
@ -49,8 +49,10 @@ if (NOT DEFINED SYNERGY_VERSION_MINOR)
set (SYNERGY_VERSION_MINOR $ENV{SYNERGY_VERSION_MINOR})
else()
set (SYNERGY_VERSION_MINOR 9)
message (WARNING
"(SYNERGY_VERSION_MINOR not set. Defaulted to ${SYNERGY_VERSION_MINOR}")
if (NOT ${SYNERGY_VERSION_WARNED})
set (SYNERGY_VERSION_WARNED 1)
message (WARNING "(SYNERGY_VERSION_MINOR not set. Defaulted to ${SYNERGY_VERSION_MINOR}")
endif()
endif()
endif()
@ -59,8 +61,10 @@ if (NOT DEFINED SYNERGY_VERSION_PATCH)
set (SYNERGY_VERSION_PATCH $ENV{SYNERGY_VERSION_PATCH})
else()
set (SYNERGY_VERSION_PATCH 0)
message (WARNING
"SYNERGY_VERSION_PATCH not set. Defaulted to ${SYNERGY_VERSION_PATCH}")
if (NOT ${SYNERGY_VERSION_WARNED})
set (SYNERGY_VERSION_WARNED 1)
message (WARNING "SYNERGY_VERSION_PATCH not set. Defaulted to ${SYNERGY_VERSION_PATCH}")
endif()
endif()
endif()
@ -69,8 +73,11 @@ if (NOT DEFINED SYNERGY_VERSION_STAGE)
set (SYNERGY_VERSION_STAGE $ENV{SYNERGY_VERSION_STAGE})
else()
set (SYNERGY_VERSION_STAGE "git")
if (NOT ${SYNERGY_VERSION_WARNED})
set (SYNERGY_VERSION_WARNED 1)
message (WARNING "SYNERGY_VERSION_STAGE not set. Defaulted to '${SYNERGY_VERSION_STAGE}'")
endif()
endif()
endif()
if (NOT DEFINED SYNERGY_REVISION)
@ -78,7 +85,7 @@ if (NOT DEFINED SYNERGY_REVISION)
string (SUBSTRING $ENV{GIT_COMMIT} 0 8 SYNERGY_REVISION)
elseif (SYNERGY_VERSION_STAGE STREQUAL "git")
execute_process (
COMMAND git rev-parse --short HEAD
COMMAND git rev-parse --short=8 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SYNERGY_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
@ -86,32 +93,32 @@ if (NOT DEFINED SYNERGY_REVISION)
endif()
endif()
if (NOT SYNERGY_REVISION MATCHES "[a-f0-9]{8}")
message (FATAL_ERROR "SYNERGY_VERSION='${SYNERGY_REVISION}' is invalid")
endif()
string (TIMESTAMP SYNERGY_BUILD_DATE "%Y%m%d" UTC)
if (DEFINED ENV{BUILDS_TODAY})
set (SYNERGY_BUILDS_TODAY $ENV{BUILDS_TODAY})
if (DEFINED SYNERGY_REVISION)
string(LENGTH ${SYNERGY_REVISION} SYNERGY_REVISION_LENGTH)
if (NOT ((SYNERGY_REVISION MATCHES "^[a-f0-9]+") AND (SYNERGY_REVISION_LENGTH EQUAL "8")))
message (FATAL_ERROR "SYNERGY_REVISION='${SYNERGY_REVISION}' should be a short git commit hash")
endif()
unset (SYNERGY_REVISION_LENGTH)
else()
set (SYNERGY_BUILDS_TODAY 1)
endif()
endif()
if (DEFINED ENV{BUILD_NUMBER})
set (SYNERGY_BUILD_NUMBER $ENV{BUILD_NUMBER})
else()
set (SYNERGY_BUILD_NUMBER 1)
endif()
set (SYNERGY_VERSION "${SYNERGY_VERSION_MAJOR}.${SYNERGY_VERSION_MINOR}.${SYNERGY_VERSION_PATCH}")
set (SYNERGY_SNAPSHOT_INFO "${SYNERGY_BUILD_DATE}.${SYNERGY_REVISION}")
string (TIMESTAMP SYNERGY_BUILD_DATE "%Y%m%d" UTC)
if (SYNERGY_VERSION_STAGE STREQUAL "git")
set (SYNERGY_VERSION_TAG "${SYNERGY_SNAPSHOT_INFO}")
set (SYNERGY_SNAPSHOT_INFO "${SYNERGY_BUILD_DATE}.${SYNERGY_REVISION}")
set (SYNERGY_VERSION_TAG "b${SYNERGY_BUILD_DATE}-${SYNERGY_REVISION}")
else()
set (SYNERGY_SNAPSHOT_INFO "")
set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}")
endif()
set (SYNERGY_VERSION "${SYNERGY_VERSION_MAJOR}.${SYNERGY_VERSION_MINOR}.${SYNERGY_VERSION_PATCH}")
set (SYNERGY_VERSION_STRING "${SYNERGY_VERSION}-${SYNERGY_VERSION_TAG}")
message (STATUS "Full Synergy version string is " ${SYNERGY_VERSION_STRING})

View File

@ -7,7 +7,7 @@ Source: https://symless.com/synergy/downloads
Vendor: Symless
Packager: Symless <engineering@symless.com>
License: GPLv2
Release: @SYNERGY_BUILDS_TODAY@.@SYNERGY_SNAPSHOT_INFO@%{?dist}
Release: @SYNERGY_BUILD_NUMBER@.@SYNERGY_SNAPSHOT_INFO@%{?dist}
%description
Synergy allows you to share one mouse and keyboard between multiple computers.