From b08c57c8d0de79f7d569c4261a72c1dbeb28d602 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 17:38:39 +0300 Subject: [PATCH] Fix version parsing for stable version. --- version.cmake | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/version.cmake b/version.cmake index 3d4cde3..bea8506 100644 --- a/version.cmake +++ b/version.cmake @@ -17,25 +17,30 @@ function(desktop_app_parse_version file) endif() endforeach() - if (NOT ${version} MATCHES "[0-9]+\.[0-9]+(\.[0-9]+(\.([0-9]+|beta)))") + if (NOT ${version} MATCHES "[0-9]+\.[0-9]+(\.[0-9]+(\.([0-9]+|beta))?)?") message(FATAL_ERROR "Bad version: ${version}, check ${file}") endif() message("Version: ${version}") + set(beta 0) + set(beta_bool "false") + set(alpha 0) + string(REPLACE "." ";" components ${version}) + list(LENGTH components components_count) list(GET components 0 major) list(GET components 1 minor) - list(GET components 2 patch) - list(GET components 3 alpha) - - if (${alpha} STREQUAL beta) - set(beta 1) - set(beta_bool "true") - set(alpha 0) - else() - set(beta 0) - set(beta_bool "false") + if (${components_count} GREATER 2) + list(GET components 2 patch) + if (${components_count} GREATER 3) + list(GET components 3 alpha) + if (${alpha} STREQUAL beta) + set(beta 1) + set(beta_bool "true") + set(alpha 0) + endif() + endif() endif() if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "")