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}) set (SYNERGY_VERSION_MAJOR $ENV{SYNERGY_VERSION_MAJOR})
else() else()
set (SYNERGY_VERSION_MAJOR 1) set (SYNERGY_VERSION_MAJOR 1)
message (WARNING set (SYNERGY_VERSION_WARNED 1)
"SYNERGY_VERSION_MAJOR not set. Defaulted to ${SYNERGY_VERSION_MAJOR}") message (WARNING "SYNERGY_VERSION_MAJOR not set. Defaulted to ${SYNERGY_VERSION_MAJOR}")
endif() endif()
endif() endif()
@ -49,8 +49,10 @@ if (NOT DEFINED SYNERGY_VERSION_MINOR)
set (SYNERGY_VERSION_MINOR $ENV{SYNERGY_VERSION_MINOR}) set (SYNERGY_VERSION_MINOR $ENV{SYNERGY_VERSION_MINOR})
else() else()
set (SYNERGY_VERSION_MINOR 9) set (SYNERGY_VERSION_MINOR 9)
message (WARNING if (NOT ${SYNERGY_VERSION_WARNED})
"(SYNERGY_VERSION_MINOR not set. Defaulted to ${SYNERGY_VERSION_MINOR}") set (SYNERGY_VERSION_WARNED 1)
message (WARNING "(SYNERGY_VERSION_MINOR not set. Defaulted to ${SYNERGY_VERSION_MINOR}")
endif()
endif() endif()
endif() endif()
@ -59,8 +61,10 @@ if (NOT DEFINED SYNERGY_VERSION_PATCH)
set (SYNERGY_VERSION_PATCH $ENV{SYNERGY_VERSION_PATCH}) set (SYNERGY_VERSION_PATCH $ENV{SYNERGY_VERSION_PATCH})
else() else()
set (SYNERGY_VERSION_PATCH 0) set (SYNERGY_VERSION_PATCH 0)
message (WARNING if (NOT ${SYNERGY_VERSION_WARNED})
"SYNERGY_VERSION_PATCH not set. Defaulted to ${SYNERGY_VERSION_PATCH}") set (SYNERGY_VERSION_WARNED 1)
message (WARNING "SYNERGY_VERSION_PATCH not set. Defaulted to ${SYNERGY_VERSION_PATCH}")
endif()
endif() endif()
endif() endif()
@ -69,7 +73,10 @@ if (NOT DEFINED SYNERGY_VERSION_STAGE)
set (SYNERGY_VERSION_STAGE $ENV{SYNERGY_VERSION_STAGE}) set (SYNERGY_VERSION_STAGE $ENV{SYNERGY_VERSION_STAGE})
else() else()
set (SYNERGY_VERSION_STAGE "git") set (SYNERGY_VERSION_STAGE "git")
message (WARNING "SYNERGY_VERSION_STAGE not set. Defaulted to '${SYNERGY_VERSION_STAGE}'") 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()
endif() endif()
@ -78,7 +85,7 @@ if (NOT DEFINED SYNERGY_REVISION)
string (SUBSTRING $ENV{GIT_COMMIT} 0 8 SYNERGY_REVISION) string (SUBSTRING $ENV{GIT_COMMIT} 0 8 SYNERGY_REVISION)
elseif (SYNERGY_VERSION_STAGE STREQUAL "git") elseif (SYNERGY_VERSION_STAGE STREQUAL "git")
execute_process ( execute_process (
COMMAND git rev-parse --short HEAD COMMAND git rev-parse --short=8 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SYNERGY_REVISION OUTPUT_VARIABLE SYNERGY_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
@ -86,32 +93,32 @@ if (NOT DEFINED SYNERGY_REVISION)
endif() endif()
endif() endif()
if (NOT SYNERGY_REVISION MATCHES "[a-f0-9]{8}") if (DEFINED SYNERGY_REVISION)
message (FATAL_ERROR "SYNERGY_VERSION='${SYNERGY_REVISION}' is invalid") string(LENGTH ${SYNERGY_REVISION} SYNERGY_REVISION_LENGTH)
endif() 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")
string (TIMESTAMP SYNERGY_BUILD_DATE "%Y%m%d" UTC) endif()
if (DEFINED ENV{BUILDS_TODAY}) unset (SYNERGY_REVISION_LENGTH)
set (SYNERGY_BUILDS_TODAY $ENV{BUILDS_TODAY})
else() else()
set (SYNERGY_BUILDS_TODAY 1)
endif()
endif()
if (DEFINED ENV{BUILD_NUMBER}) if (DEFINED ENV{BUILD_NUMBER})
set (SYNERGY_BUILD_NUMBER $ENV{BUILD_NUMBER}) set (SYNERGY_BUILD_NUMBER $ENV{BUILD_NUMBER})
else() else()
set (SYNERGY_BUILD_NUMBER 1) set (SYNERGY_BUILD_NUMBER 1)
endif() endif()
set (SYNERGY_VERSION "${SYNERGY_VERSION_MAJOR}.${SYNERGY_VERSION_MINOR}.${SYNERGY_VERSION_PATCH}") string (TIMESTAMP SYNERGY_BUILD_DATE "%Y%m%d" UTC)
set (SYNERGY_SNAPSHOT_INFO "${SYNERGY_BUILD_DATE}.${SYNERGY_REVISION}")
if (SYNERGY_VERSION_STAGE STREQUAL "git") 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() else()
set (SYNERGY_SNAPSHOT_INFO "")
set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}") set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}")
endif() endif()
set (SYNERGY_VERSION "${SYNERGY_VERSION_MAJOR}.${SYNERGY_VERSION_MINOR}.${SYNERGY_VERSION_PATCH}")
set (SYNERGY_VERSION_STRING "${SYNERGY_VERSION}-${SYNERGY_VERSION_TAG}") set (SYNERGY_VERSION_STRING "${SYNERGY_VERSION}-${SYNERGY_VERSION_TAG}")
message (STATUS "Full Synergy version string is " ${SYNERGY_VERSION_STRING}) message (STATUS "Full Synergy version string is " ${SYNERGY_VERSION_STRING})
@ -452,6 +459,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif() endif()
else() else()
message (STATUS "NOT configuring the v1 installer") message (STATUS "NOT configuring the v1 installer")
endif() endif()
add_subdirectory (src) add_subdirectory (src)

View File

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