-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathversion.cmake
More file actions
32 lines (27 loc) · 1018 Bytes
/
version.cmake
File metadata and controls
32 lines (27 loc) · 1018 Bytes
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
function(read_from_file_and_set FILEPATH)
file(STRINGS ${FILEPATH} FileContents)
foreach(NameAndValue ${FileContents})
# Strip leading spaces
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
# ignore comments
if(${NameAndValue} MATCHES "^#")
continue()
endif()
# Find variable name
string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
# Find the value
string(REPLACE "${Name}=" "" Value ${NameAndValue})
# Set the variable
set(${Name} "${Value}" PARENT_SCOPE)
endforeach()
endfunction()
read_from_file_and_set(${CMAKE_SOURCE_DIR}/version)
string(CONCAT VERSION_STR
"${GAMSCPP_MAJOR_VERSION}."
"${GAMSCPP_MINOR_VERSION}."
"${GAMSCPP_PATCH_LEVEL}")
set(VERSION ${VERSION_STR})
set(CMAKE_PROJECT_VERSION ${VERSION})
set(CMAKE_PROJECT_VERSION_MAJOR ${GAMSCPP_MAJOR_VERSION})
set(CMAKE_PROJECT_VERSION_MINOR ${GAMSCPP_MINOR_VERSION})
set(CMAKE_PROJECT_VERSION_PATCH ${GAMSCPP_PATCH_LEVEL})