mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-14 02:27:09 -07:00
cmake: read version numbers from the version.pri file. Closes #6350.
This commit is contained in:
parent
3b3de81cb7
commit
e96e14ca76
2 changed files with 34 additions and 8 deletions
28
cmake/Modules/FunctionReadVersion.cmake
Normal file
28
cmake/Modules/FunctionReadVersion.cmake
Normal file
|
@ -0,0 +1,28 @@
|
|||
# function for parsing version variables that are set in version.pri file
|
||||
# the version identifiers there are defined as follows:
|
||||
# VER_MAJOR = 3
|
||||
# VER_MINOR = 4
|
||||
# VER_BUGFIX = 0
|
||||
# VER_BUILD = 0
|
||||
# VER_STATUS = alpha
|
||||
|
||||
function(read_version priFile outMajor outMinor outBugfix outBuild outStatus)
|
||||
file(STRINGS ${priFile} _priFileContents REGEX "^VER_.+")
|
||||
# message(STATUS "version.pri version contents: ${_priFileContents}")
|
||||
# the _priFileContents variable contains something like the following:
|
||||
# VER_MAJOR = 3;VER_MINOR = 4;VER_BUGFIX = 0;VER_BUILD = 0;VER_STATUS = alpha # Should be empty for stable releases!
|
||||
set(_regex "VER_MAJOR += +([0-9]+);VER_MINOR += +([0-9]+);VER_BUGFIX += +([0-9]+);VER_BUILD += +([0-9]+);VER_STATUS += +([0-9A-Za-z]+)?")
|
||||
# note quotes around _regex, they are needed because the variable contains semicolons
|
||||
string(REGEX MATCH "${_regex}" _tmp "${_priFileContents}")
|
||||
if (NOT _tmp)
|
||||
message(FATAL_ERROR "Could not detect project version number from ${priFile}")
|
||||
endif()
|
||||
|
||||
# message(STATUS "Matched version string: ${_tmp}")
|
||||
|
||||
set(${outMajor} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
set(${outMinor} ${CMAKE_MATCH_2} PARENT_SCOPE)
|
||||
set(${outBugfix} ${CMAKE_MATCH_3} PARENT_SCOPE)
|
||||
set(${outBuild} ${CMAKE_MATCH_4} PARENT_SCOPE)
|
||||
set(${outStatus} ${CMAKE_MATCH_5} PARENT_SCOPE)
|
||||
endfunction()
|
Loading…
Add table
Add a link
Reference in a new issue