2017-05-27 16:01:49 +03:00
|
|
|
cmake_minimum_required (VERSION 3.4)
|
|
|
|
|
|
|
|
#
|
2018-01-28 00:48:17 +03:00
|
|
|
# Barrier Version
|
2017-05-27 16:01:49 +03:00
|
|
|
#
|
2018-01-28 00:48:17 +03:00
|
|
|
if (NOT DEFINED BARRIER_VERSION_MAJOR)
|
|
|
|
if (DEFINED ENV{BARRIER_VERSION_MAJOR})
|
|
|
|
set (BARRIER_VERSION_MAJOR $ENV{BARRIER_VERSION_MAJOR})
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION_MAJOR 1)
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (NOT DEFINED BARRIER_VERSION_MINOR)
|
|
|
|
if (DEFINED ENV{BARRIER_VERSION_MINOR})
|
|
|
|
set (BARRIER_VERSION_MINOR $ENV{BARRIER_VERSION_MINOR})
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION_MINOR 9)
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (NOT DEFINED BARRIER_VERSION_PATCH)
|
|
|
|
if (DEFINED ENV{BARRIER_VERSION_PATCH})
|
|
|
|
set (BARRIER_VERSION_PATCH $ENV{BARRIER_VERSION_PATCH})
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION_PATCH 0)
|
|
|
|
message (WARNING "Barrier version wasn't set. Set to ${BARRIER_VERSION_MAJOR}.${BARRIER_VERSION_MINOR}.${BARRIER_VERSION_PATCH}")
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (NOT DEFINED BARRIER_VERSION_STAGE)
|
|
|
|
if (DEFINED ENV{BARRIER_VERSION_STAGE})
|
|
|
|
set (BARRIER_VERSION_STAGE $ENV{BARRIER_VERSION_STAGE})
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION_STAGE "snapshot")
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (NOT DEFINED BARRIER_REVISION)
|
2017-05-27 16:01:49 +03:00
|
|
|
if (DEFINED ENV{GIT_COMMIT})
|
2018-01-28 00:48:17 +03:00
|
|
|
string (SUBSTRING $ENV{GIT_COMMIT} 0 8 BARRIER_REVISION)
|
|
|
|
elseif (BARRIER_VERSION_STAGE STREQUAL "snapshot")
|
2017-05-27 16:01:49 +03:00
|
|
|
execute_process (
|
|
|
|
COMMAND git rev-parse --short=8 HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2018-01-28 00:48:17 +03:00
|
|
|
OUTPUT_VARIABLE BARRIER_REVISION
|
2017-05-27 16:01:49 +03:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (DEFINED BARRIER_REVISION)
|
|
|
|
string(LENGTH ${BARRIER_REVISION} BARRIER_REVISION_LENGTH)
|
|
|
|
if (NOT ((BARRIER_REVISION MATCHES "^[a-f0-9]+") AND (BARRIER_REVISION_LENGTH EQUAL "8")))
|
|
|
|
message (FATAL_ERROR "BARRIER_REVISION ('${BARRIER_REVISION}') should be a short commit hash")
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
2018-01-28 00:48:17 +03:00
|
|
|
unset (BARRIER_REVISION_LENGTH)
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_REVISION "0badc0de")
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (DEFINED ENV{BUILD_NUMBER})
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_BUILD_NUMBER $ENV{BUILD_NUMBER})
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_BUILD_NUMBER 1)
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
string (TIMESTAMP BARRIER_BUILD_DATE "%Y%m%d" UTC)
|
|
|
|
set (BARRIER_SNAPSHOT_INFO ".${BARRIER_VERSION_STAGE}.${BARRIER_REVISION}")
|
2017-05-27 16:01:49 +03:00
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (BARRIER_VERSION_STAGE STREQUAL "snapshot")
|
|
|
|
set (BARRIER_VERSION_TAG "${BARRIER_VERSION_STAGE}.b${BARRIER_BUILD_NUMBER}-${BARRIER_REVISION}")
|
2017-05-27 16:01:49 +03:00
|
|
|
else()
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION_TAG "${BARRIER_VERSION_STAGE}")
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
set (BARRIER_VERSION "${BARRIER_VERSION_MAJOR}.${BARRIER_VERSION_MINOR}.${BARRIER_VERSION_PATCH}")
|
|
|
|
set (BARRIER_VERSION_STRING "${BARRIER_VERSION}-${BARRIER_VERSION_TAG}")
|
|
|
|
message (STATUS "Full Barrier version string is '" ${BARRIER_VERSION_STRING} "'")
|
2017-05-27 16:01:49 +03:00
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
add_definitions (-DBARRIER_VERSION="${BARRIER_VERSION}")
|
|
|
|
add_definitions (-DBARRIER_VERSION_STRING="${BARRIER_VERSION_STRING}")
|
|
|
|
add_definitions (-DBARRIER_REVISION="${BARRIER_REVISION}")
|
|
|
|
add_definitions (-DBARRIER_BUILD_DATE="${BARRIER_BUILD_DATE}")
|
|
|
|
add_definitions (-DBARRIER_BUILD_NUMBER=${BARRIER_BUILD_NUMBER})
|
2017-05-27 16:01:49 +03:00
|
|
|
|
2018-01-28 00:48:17 +03:00
|
|
|
if (BARRIER_DEVELOPER_MODE)
|
|
|
|
add_definitions (-DBARRIER_DEVELOPER_MODE=1)
|
2017-05-27 16:01:49 +03:00
|
|
|
endif()
|
|
|
|
|