This repository was archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathGetVersion.cmake
More file actions
44 lines (40 loc) · 1.52 KB
/
GetVersion.cmake
File metadata and controls
44 lines (40 loc) · 1.52 KB
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
#
# Copyright (C) 2012 Modelon AB <http://www.modelon.com>
#
# You should have received a copy of the LICENSE-FMUChecker.txt
# along with this program. If not, contact Modelon AB.
#
# File: GetVesion.cmake
# CMake module for getting the version information from SVN.
include(FindSubversion)
# Uses svn info to find out the version of the code and sets the "variable" to it.
# Version becomes "Test" if svn commands fail.
function(getVersionSVN dir variable)
TestSVNOK(${dir} test_svn_result)
if(${test_svn_result} EQUAL 0)
Subversion_WC_INFO(${dir} SVNVER)
string(REGEX MATCH "URL[^\n]*tags/" SVNTAGS "${SVNVER_WC_INFO}")
if(SVNTAGS)
string(REGEX MATCH "${SVNTAGS}[^\n]*" SVNTAGTMP "${SVNVER_WC_INFO}")
string(REPLACE "${SVNTAGS}" "" SVNTAG "${SVNTAGTMP}")
set(${variable} "${SVNTAG}" PARENT_SCOPE)
else()
set(${variable} "rev${SVNVER_WC_REVISION}" PARENT_SCOPE)
endif()
else()
message(STATUS "Setting version to 'Test' since no Subversion info is found")
set(${variable} "Test" PARENT_SCOPE)
endif()
endfunction(getVersionSVN)
function(TestSVNOK dir svnok)
if(COMMAND Subversion_WC_INFO)
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
OUTPUT_VARIABLE TEST_WC_INFO
ERROR_VARIABLE test_svn_error
RESULT_VARIABLE test_svn_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(test_svn_result 1)
endif()
set(${svnok} ${test_svn_result} PARENT_SCOPE)
endfunction(TestSVNOK)