summaryrefslogtreecommitdiffstats
path: root/cmake/version.cmake
blob: 9023aef1d848ce84418d809f1351565ccc3b64e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+")

MACRO(VERSION_TO_VARS version major minor patch)
  IF(${version} MATCHES ${VERSION_REGEX})
    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ${major} "${version}")
    STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ${minor} "${version}")
    STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ${patch} "${version}")
  ELSE(${version} MATCHES ${VERSION_REGEX})
    MESSAGE("MACRO(VERSION_TO_VARS ${version} ${major} ${minor} ${patch}")
    MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.")
  ENDIF(${version} MATCHES ${VERSION_REGEX})
ENDMACRO(VERSION_TO_VARS)