cmake: detect cpu architecture in SDL_DetectCPUArchitecture

Stop looking for arch, when one is found
This commit is contained in:
Anonymous Maarten
2023-01-09 15:06:45 +01:00
committed by Anonymous Maarten
parent 9cf34908a1
commit 19d162281c
2 changed files with 22 additions and 5 deletions

View File

@@ -53,3 +53,24 @@ macro(SDL_DetectCMakePlatform)
set(${SDL_CMAKE_PLATFORM} TRUE)
endif()
endmacro()
function(SDL_DetectCPUArchitecture)
set(archs x86 x64 arm32 arm64 loongarch64)
set(found FALSE)
foreach(arch ${archs})
string(TOUPPER "${arch}" arch_upper)
set(var_name "SDL_CPU_${arch_upper}")
if(found)
set(${var_name} 0 PARENT_SCOPE)
else()
check_cpu_architecture(${arch} ${var_name})
set(found ${${var_name}})
set(${var_name} ${${var_name}} PARENT_SCOPE)
set(SDL_CPU_NAME ${arch})
endif()
endforeach()
if(NOT found)
message(AUTHOR_WARNING "Unknown architecture (failed archs=${archs})")
set(SDL_CPU_NAME "(unknown)")
endif()
endfunction()