|
| 1 | +# CMake tools for version management |
| 2 | + |
| 3 | +function(bx_version_build_version_number prefix_) |
| 4 | + set(${prefix_}_VERSION |
| 5 | + "${${prefix_}_VERSION_MAJOR}.${${prefix_}_VERSION_MINOR}.${${prefix_}_VERSION_PATCH}" |
| 6 | + PARENT_SCOPE) |
| 7 | +endfunction() |
| 8 | + |
| 9 | +function(bx_version_extract_patch_from_db major_ minor_ patch_) |
| 10 | + # message(STATUS "[info] bx_version_extract_patch_from_db: Entering...") |
| 11 | + # message(STATUS "[info] - Major = ${major_}") |
| 12 | + # message(STATUS "[info] - Minor = ${minor_}") |
| 13 | + file(STRINGS |
| 14 | + ${PROJECT_SOURCE_DIR}/cmake/BxPackageVersions.db |
| 15 | + _bx_package_versions_lines |
| 16 | + REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9+])" |
| 17 | + ) |
| 18 | + # message(STATUS "[info] Lines = ${_bx_package_versions_lines}") |
| 19 | + foreach(line ${_bx_package_versions_lines}) |
| 20 | + string(REPLACE "." ";" _version_list ${line}) |
| 21 | + # message(STATUS "[info] Version list = ${_version_list}") |
| 22 | + list(GET _version_list 0 _version_major) |
| 23 | + list(GET _version_list 1 _version_minor) |
| 24 | + list(GET _version_list 2 _version_patch) |
| 25 | + if(${_version_major} EQUAL ${major_}) |
| 26 | + if(${_version_minor} EQUAL ${minor_}) |
| 27 | + set(${patch_} ${_version_patch} PARENT_SCOPE) |
| 28 | + # message(STATUS "[info] Resolved patch = ${_version_patch}") |
| 29 | + endif() |
| 30 | + endif() |
| 31 | + endforeach() |
| 32 | + # message(STATUS "[info] - New patch is set to : $ {${patch_}}") |
| 33 | + # message(STATUS "[info] bx_version_extract_patch_from_db: Exiting.") |
| 34 | +endfunction() |
| 35 | + |
| 36 | +macro(bx_version_set prefix_ major_ minor_) |
| 37 | + #message(STATUS "[info] bx_version_set: prefix_ = ${prefix_}") |
| 38 | + #message(STATUS "[info] bx_version_set: major_ = ${major_}") |
| 39 | + #message(STATUS "[info] bx_version_set: minor_ = ${minor_}") |
| 40 | + #message(STATUS "[info] bx_version_set: key = ${prefix_}_VERSION_MAJOR") |
| 41 | + set(_version_major ${major_}) |
| 42 | + set(_version_minor ${minor_}) |
| 43 | + set(_version_patch 0) |
| 44 | + set(${prefix_}_VERSION_MAJOR ${_version_major}) |
| 45 | + set(${prefix_}_VERSION_MINOR ${_version_minor}) |
| 46 | + set(${prefix_}_VERSION_PATCH ${_version_patch}) |
| 47 | + # message(STATUS "[info] bx_version_set: Major = ${${prefix_}_VERSION_MAJOR}") |
| 48 | + # message(STATUS "[info] bx_version_set: Minor = ${${prefix_}_VERSION_MINOR}") |
| 49 | + # message(STATUS "[info] bx_version_set: Patch = ${${prefix_}_VERSION_PATCH}") |
| 50 | + bx_version_extract_patch_from_db( |
| 51 | + ${${prefix_}_VERSION_MAJOR} |
| 52 | + ${${prefix_}_VERSION_MINOR} |
| 53 | + ${prefix_}_VERSION_PATCH |
| 54 | + ) |
| 55 | + bx_version_build_version_number(${prefix_}) |
| 56 | + message(STATUS "[info] bx_version_set: Major = ${${prefix_}_VERSION_MAJOR}") |
| 57 | + message(STATUS "[info] bx_version_set: Minor = ${${prefix_}_VERSION_MINOR}") |
| 58 | + message(STATUS "[info] bx_version_set: Patch = ${${prefix_}_VERSION_PATCH}") |
| 59 | + message(STATUS "[info] bx_version_set: Version = ${${prefix_}_VERSION}") |
| 60 | +endmacro() |
0 commit comments