2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-19 04:02:17 +00:00

CMake: fix detection of arm/aarch64 (#182)

Use CMAKE_SYSTEM_PROCESSOR at first step and if it matches to any
Boost.Context arch option, then we will use it as default arch.
Otherwise we try to detect the known arm names depending on current
bitness.

Fixes #182.
This commit is contained in:
leha-bot
2021-08-10 15:09:41 +03:00
parent 561a31508f
commit 5c8163d68c

View File

@@ -40,15 +40,30 @@ unset(_default_abi)
math(EXPR _bits "${CMAKE_SIZEOF_VOID_P}*8")
if(_bits EQUAL 32)
set(_default_arch i386)
set(_all_archs arm arm64 mips32 mips64 ppc32 ppc64 riscv64 s390x i386 x86_64 combined)
# Try at start to auto determine arch from CMake.
if(CMAKE_SYSTEM_PROCESSOR IN_LIST _all_archs)
set(_default_arch ${CMAKE_SYSTEM_PROCESSOR})
elseif(_bits EQUAL 32)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(_default_arch arm)
else()
set(_default_arch i386)
endif()
else()
set(_default_arch x86_64)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") # armv8
set(_default_arch arm64)
else()
set(_default_arch x86_64)
endif()
endif()
set(BOOST_CONTEXT_ARCHITECTURE "${_default_arch}" CACHE STRING "Boost.Context architecture (arm, arm64, mips32, mips64, ppc32, ppc64, riscv64, s390x, i386, x86_64, combined)")
set_property(CACHE BOOST_CONTEXT_ARCHITECTURE PROPERTY STRINGS arm arm64 mips32 mips64 ppc32 ppc64 riscv64 s390x i386 x86_64 combined)
set_property(CACHE BOOST_CONTEXT_ARCHITECTURE PROPERTY STRINGS ${_all_archs})
unset(_all_archs)
unset(_bits)
unset(_default_arch)