From 4ade5e9c32896fdff96edee5a1dea17753594269 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Fri, 23 Aug 2019 12:02:27 +0200 Subject: [PATCH] cmake: check sdk_version format Encountered situation when sdk_version string was empty (as the result of corrupted installation). The version should had 0.0.0 format. Patch add check for this and descriptive failure message. Objective is to help the user to recognize the installation failure. Signed-off-by: Andrzej Puzdrowski --- cmake/toolchain/zephyr/host-tools.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/toolchain/zephyr/host-tools.cmake b/cmake/toolchain/zephyr/host-tools.cmake index 96c7e21faf0..347c700fe91 100644 --- a/cmake/toolchain/zephyr/host-tools.cmake +++ b/cmake/toolchain/zephyr/host-tools.cmake @@ -35,7 +35,17 @@ string(REGEX REPLACE "-.*" "" SDK_VERSION_PRE2 ${SDK_VERSION_PRE1}) # Strip any trailing spaces/newlines from the version string string(STRIP ${SDK_VERSION_PRE2} SDK_VERSION) string(REGEX MATCH "([0-9]*).([0-9]*)" SDK_MAJOR_MINOR ${SDK_VERSION}) -if(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION}) + +string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" SDK_MAJOR_MINOR_MICRO ${SDK_VERSION}) + +#at least 0.0.0 +if(NOT SDK_MAJOR_MINOR_MICRO) + message(FATAL_ERROR "sdk version: ${SDK_MAJOR_MINOR_MICRO} improper format. + Expected format: x.y.z + Check whether the Zephyr SDK was installed correctly. +") + +elseif(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION}) message(FATAL_ERROR "The SDK version you are using is too old, please update your SDK. You need at least SDK version ${REQUIRED_SDK_VER}. You have version ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR}).