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 <alexandru.croitor@qt.io>
This commit is contained in:
Simon Hausmann 2019-05-29 10:09:52 +02:00
parent d908e0a47d
commit bcca649440

View File

@ -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()