62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
# -----------------------------------------------------------------------------
|
|
#
|
|
# CMake module for paths generation in DEBUG and RELEASE modes
|
|
#
|
|
# (c) Copyright Löwenware Ltd. (https://lowenware.com/)
|
|
#
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
## Constants
|
|
set (VERSION_FILE "version")
|
|
set (
|
|
VERSION_REGEX
|
|
"^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-(pre|alpha|beta|rc|release))?"
|
|
)
|
|
|
|
# Read file
|
|
file (READ ${VERSION_FILE} VERSION_STRING)
|
|
|
|
# Match file content
|
|
string(REGEX MATCH ${VERSION_REGEX} VERSION_STRING ${VERSION_STRING} )
|
|
|
|
# Set Version constants
|
|
set (VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
set (VERSION_MINOR ${CMAKE_MATCH_2})
|
|
set (VERSION_TWEAK ${CMAKE_MATCH_3})
|
|
|
|
if (CMAKE_MATCH_5 STREQUAL "pre")
|
|
set(VERSION_CYCLE 1)
|
|
elseif (CMAKE_MATCH_5 STREQUAL "alpha")
|
|
set (VERSION_CYCLE 2)
|
|
elseif (CMAKE_MATCH_5 STREQUAL "beta")
|
|
set (VERSION_CYCLE 3)
|
|
elseif (CMAKE_MATCH_5 STREQUAL "rc")
|
|
set (VERSION_CYCLE 4)
|
|
else()
|
|
set (VERSION_CYCLE 0)
|
|
endif()
|
|
|
|
set (VERSION_LABEL ${CMAKE_MATCH_4})
|
|
|
|
# Add compiler macros
|
|
|
|
add_definitions(
|
|
-DVERSION_MAJOR=${VERSION_MAJOR}
|
|
-DVERSION_MINOR=${VERSION_MINOR}
|
|
-DVERSION_TWEAK=${VERSION_TWEAK}
|
|
-DVERSION_CYCLE=${VERSION_CYCLE}
|
|
-DVERSION_LABEL="${VERSION_LABEL}"
|
|
)
|
|
|
|
#Print output
|
|
|
|
MESSAGE(
|
|
STATUS "${PROJECT_TITLE} version: " ${VERSION_MAJOR} "."
|
|
${VERSION_MINOR} "."
|
|
${VERSION_TWEAK} "-"
|
|
${VERSION_CYCLE_TEXT} " "
|
|
${VERSION_LABEL}
|
|
)
|
|
|