-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathVersionInfo.cmake
75 lines (64 loc) · 2.67 KB
/
VersionInfo.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# NestVersionInfo.cmake
#
# This file is part of NEST GPU.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST GPU is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST GPU is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST GPU. If not, see <http://www.gnu.org/licenses/>.
# Determine NEST GPU version based on git branch
#
# This module defines
# NEST_GPU_VERSION_BRANCH, the current git branch (nest-3.0)
# NEST_GPU_VERSION_SUFFIX, set using -Dwith-version-suffix=<suffix>. ("-pre")
# NEST_GPU_VERSION, the numeric version number plus the suffix ("3.0-pre")
# NEST_GPU_VERSION_GITHASH, the current git revision hash (empty for tarballs) ("dd47c39ce")
# NEST_GPU_VERSION_STRING, the full NEST version string ("nest-3.0-pre@dd47c39ce")
#
# In release branches, the string "UNKNOWN" below has to be replaced
# with the proper version (e.g. "nest-2.20") in order to get the
# correct version number if building from tarballs.
macro(get_version_info)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
COMMAND "git" "rev-parse" "--short" "HEAD"
OUTPUT_VARIABLE NEST_GPU_VERSION_GITHASH
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
execute_process(
COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD"
OUTPUT_VARIABLE NEST_GPU_VERSION_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
if (NEST_GPU_VERSION_SUFFIX)
set(versionsuffix "-${NEST_GPU_VERSION_SUFFIX}")
endif()
if (NEST_GPU_VERSION_GITHASH)
set(githash "@${NEST_GPU_VERSION_GITHASH}")
endif()
endif()
if (NOT NEST_GPU_VERSION_BRANCH)
set(NEST_GPU_VERSION_BRANCH "UNKNOWN")
endif()
string(SUBSTRING "${NEST_GPU_VERSION_BRANCH}" 0 5 isRelease)
if (isRelease STREQUAL "nestgpu-")
string(SUBSTRING "${NEST_GPU_VERSION_BRANCH}${versionsuffix}" 5 99999 NEST_GPU_VERSION)
else()
set(NEST_GPU_VERSION "${NEST_GPU_VERSION_BRANCH}${versionsuffix}")
endif()
set(NEST_GPU_VERSION_STRING "${NEST_GPU_VERSION_BRANCH}${versionsuffix}${githash}")
unset(branchname)
unset(versionsuffix)
endmacro()