Check_lang_size.cmake 660 B

1234567891011
  1. cmake_minimum_required(VERSION 3.18)
  2. FILE(SIZE ${LANG_FILE} FILE_SIZE)
  3. get_filename_component(FILE_BASE ${LANG_FILE} NAME)
  4. MATH(EXPR PADDED_SIZE "((${FILE_SIZE}+256-1) / 256 * 256 )")
  5. MATH(EXPR FREE_SPACE "(${LANG_MAX_SIZE}-${FILE_SIZE})")
  6. if(${PADDED_SIZE} GREATER ${LANG_MAX_SIZE})
  7. message(FATAL_ERROR "Language file ${FILE_BASE} (${PADDED_SIZE}b) exceeds maximum allowed size of ${LANG_MAX_SIZE} bytes - Aborting!")
  8. else()
  9. MATH(EXPR SIZE_PCT "( ${PADDED_SIZE} * 100) / ${LANG_MAX_SIZE} " )
  10. message(STATUS "Language file ${FILE_BASE} is ${PADDED_SIZE} (${FILE_SIZE}) bytes, ${SIZE_PCT}% of allowed space. Free bytes ${FREE_SPACE} - OK")
  11. endif()