diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cc775a7..3d1aa8bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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,7 +73,10 @@ if (NOT DEFINED SYNERGY_VERSION_STAGE) set (SYNERGY_VERSION_STAGE $ENV{SYNERGY_VERSION_STAGE}) else() 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() @@ -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}) @@ -452,6 +459,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif() else() - message (STATUS "NOT configuring the v1 installer") + message (STATUS "NOT configuring the v1 installer") endif() add_subdirectory (src) diff --git a/dist/rpm/synergy.spec.in b/dist/rpm/synergy.spec.in index e876c001..254475c8 100644 --- a/dist/rpm/synergy.spec.in +++ b/dist/rpm/synergy.spec.in @@ -7,7 +7,7 @@ Source: https://symless.com/synergy/downloads Vendor: Symless Packager: Symless 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.