From dd389d018b0d2aa5ec089001b18c7fac6d8775d7 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 6 Oct 2022 10:49:36 +0200 Subject: [PATCH] Add padded size for individual languages --- cmake/Check_lang_size.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/Check_lang_size.cmake b/cmake/Check_lang_size.cmake index 58efab7bf9..5aba2fb1ec 100644 --- a/cmake/Check_lang_size.cmake +++ b/cmake/Check_lang_size.cmake @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.18) FILE(SIZE ${LANG_FILE} FILE_SIZE) get_filename_component(FILE_BASE ${LANG_FILE} NAME) -if(${FILE_SIZE} GREATER ${LANG_MAX_SIZE}) - message(FATAL_ERROR "Language file ${FILE_BASE} (${FILE_SIZE}b) exceeds maximum allowed size of ${LANG_MAX_SIZE} bytes - Aborting!") +MATH(EXPR PADDED_SIZE "((${FILE_SIZE}+256-1) / 256 * 256 )") +MATH(EXPR FREE_SPACE "(${LANG_MAX_SIZE}-${FILE_SIZE})") +if(${PADDED_SIZE} GREATER ${LANG_MAX_SIZE}) + message(FATAL_ERROR "Language file ${FILE_BASE} (${PADDED_SIZE}b) exceeds maximum allowed size of ${LANG_MAX_SIZE} bytes - Aborting!") else() - MATH(EXPR SIZE_PCT "( ${FILE_SIZE} * 100) / ${LANG_MAX_SIZE} " ) - message(STATUS "Language file ${FILE_BASE} is ${FILE_SIZE} bytes, ${SIZE_PCT}% of allowed space - OK") + MATH(EXPR SIZE_PCT "( ${PADDED_SIZE} * 100) / ${LANG_MAX_SIZE} " ) + message(STATUS "Language file ${FILE_BASE} is ${PADDED_SIZE} (${FILE_SIZE}) bytes, ${SIZE_PCT}% of allowed space. Free bytes ${FREE_SPACE} - OK") endif()