From bcca64944052618b8aa8e3f9be82eb5ccad5807e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 29 May 2019 10:09:52 +0200 Subject: [PATCH] Fix architecture detection when targeting plain arm We record extra CPU features such as neon, etc. in the sub-architecture field, which may very well be empty. Allow for that and avoid cmake warnings about indexed string access beyond the string boundaries. Change-Id: I63e61c6427d156180039b8ac6f5b0f5f55c36ee8 Reviewed-by: Alexandru Croitor --- cmake/QtBaseConfigureTests.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index 7a5502bc651..d8024787f89 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -13,13 +13,14 @@ function(run_config_test_architecture) file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8) foreach (_line ${_arch_lines}) + string(LENGTH "${line}" lineLength) string(FIND "${_line}" "==Qt=magic=Qt== Architecture:" _pos) if (_pos GREATER -1) math(EXPR _pos "${_pos}+29") string(SUBSTRING "${_line}" ${_pos} -1 _architecture) endif() string(FIND "${_line}" "==Qt=magic=Qt== Sub-architecture:" _pos) - if (_pos GREATER -1) + if (_pos GREATER -1 AND ${lineLength} GREATER 33) math(EXPR _pos "${_pos}+34") string(SUBSTRING "${_line}" ${_pos} -1 _sub_architecture) string(REPLACE " " ";" _sub_architecture "${_sub_architecture}") @@ -31,7 +32,7 @@ function(run_config_test_architecture) endif() endforeach() - if (NOT _architecture OR NOT _sub_architecture OR NOT _build_abi) + if (NOT _architecture OR NOT _build_abi) message(FATAL_ERROR "Failed to extract architecture data from file.") endif()