forked from feelpp/feelpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feelpp.version.cmake
84 lines (77 loc) · 3.43 KB
/
feelpp.version.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
76
77
78
79
80
81
82
83
84
### feelpp.directive.cmake; coding: utf-8 ---
# Author(s): Christophe Prud'homme <[email protected]>
# Date: 2013-02-21
#
# Copyright (C) 2013-2020 Feel++ Consortium
#
# Distributed under the GPL(GNU Public License):
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
################################################################################
# set the version of feel++
################################################################################
if ( NOT FEELPP_VERSION_STRING )
OPTION(FEELPP_ENABLE_GIT "enable Feel++ looking up for git information" OFF)
SET(FEELPP_SCM "git")
FIND_PACKAGE(Git)
if(GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git )
message(STATUS "Git found" )
if ( NOT EXISTS ${PROJECT_SOURCE_DIR}/feelpp/contrib/nlopt/CMakeLists.txt )
message(STATUS "initializing submodules...")
execute_process(COMMAND git submodule init WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} )
message(STATUS "updating submodules...")
execute_process(COMMAND git submodule update WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} )
endif()
execute_process(
COMMAND git rev-parse --verify -q --short HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Project_WC_REVISION
ERROR_VARIABLE GIT_COMMIT_error
RESULT_VARIABLE GIT_COMMIT_result)
if ( NOT ${GIT_COMMIT_result} EQUAL 0 )
MESSAGE(SEND_ERROR "Command \"git rev-parse --verify -q --short git-svn\" failed with output:\n${GIT_COMMIT_error}")
else()
STRING(STRIP "${Project_WC_REVISION}" Project_WC_REVISION )
MESSAGE(STATUS "Git commit: ${Project_WC_REVISION}")
endif()
else()
if(EXISTS ${PROJECT_SOURCE_DIR}/GITREVISION)
file(READ ${PROJECT_SOURCE_DIR}/GITREVISION Project_WC_REVISION)
endif()
endif()
set(FEELPP_VERSION_MAJOR "0")
set(FEELPP_VERSION_MINOR "111")
set(FEELPP_VERSION_MICRO "0")
set(FEELPP_REVISION "0" )
set(FEELPP_BUILDID "0" )
set(FEELPP_VERSION_PRERELEASE "-alpha.3" )
if (FEELPP_ENABLE_GIT AND GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git )
set(FEELPP_VERSION_METADATA "+${FEELPP_SCM}${Project_WC_REVISION}")
set(FEELPP_REVISION "${Project_WC_REVISION}")
set(FEELPP_BUILDID "${Project_WC_REVISION}")
file(WRITE "${CMAKE_SOURCE_DIR}/GITREVISION" "${Project_WC_REVISION}")
else()
set(FEELPP_VERSION_METADATA "")
if ( EXISTS "${CMAKE_SOURCE_DIR}/GITREVISION" )
file(READ "${CMAKE_SOURCE_DIR}/GITREVISION" FEELPP_REVISION)
file(READ "${CMAKE_SOURCE_DIR}/GITREVISION" FEELPP_BUILDID)
endif()
endif()
set(FEELPP_VERSION "(((${FEELPP_VERSION_MAJOR}) << 16) | ((${FEELPP_VERSION_MINOR}) << 9) | (${FEELPP_VERSION_MICRO}))" )
set(FEELPP_VERSION_STRING "${FEELPP_VERSION_MAJOR}.${FEELPP_VERSION_MINOR}.${FEELPP_VERSION_MICRO}${FEELPP_VERSION_PRERELEASE}${FEELPP_VERSION_METADATA}")
set(FEELPP_SHARED_VERSION "1.0.0" )
set(FEELPP_SHARED_SOVERSION "1" )
endif(NOT FEELPP_VERSION_STRING )