Improve detection of the target architecture on Apple platforms. (#34054)

This commit is contained in:
Theodore Tsirpanis 2023-10-07 02:47:54 +03:00 committed by GitHub
parent 681e510ff1
commit cc97b4536a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -268,17 +268,7 @@ else()
set(Z_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022")
set(Z_VCPKG_TARGET_TRIPLET_ARCH x64)
else()
find_program(Z_VCPKG_CL cl)
if(Z_VCPKG_CL MATCHES "amd64/cl.exe$" OR Z_VCPKG_CL MATCHES "x64/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(Z_VCPKG_CL MATCHES "arm/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(Z_VCPKG_CL MATCHES "arm64/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(Z_VCPKG_CL MATCHES "bin/cl.exe$" OR Z_VCPKG_CL MATCHES "x86/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES Z_VCPKG_OSX_ARCH_COUNT)
if(Z_VCPKG_OSX_ARCH_COUNT EQUAL "0")
message(WARNING "Unable to determine target architecture. "
@ -311,6 +301,16 @@ else()
cmake_policy(POP)
return()
endif()
else()
find_program(Z_VCPKG_CL cl)
if(Z_VCPKG_CL MATCHES "amd64/cl.exe$" OR Z_VCPKG_CL MATCHES "x64/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(Z_VCPKG_CL MATCHES "arm/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(Z_VCPKG_CL MATCHES "arm64/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(Z_VCPKG_CL MATCHES "bin/cl.exe$" OR Z_VCPKG_CL MATCHES "x86/cl.exe$")
set(Z_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64" OR
CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64")