From 557f897eade1856a9bf48ab45b180eab0b841847 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sun, 15 Sep 2024 15:47:28 +0000 Subject: [PATCH] build: fix using host pkgconf for ARM64 cross bld Set `VCPKG_HOST_TRIPLET` and `VCPKG_USE_HOST_TOOLS` when using an X64 host for an ARM64 cross build in order to use the host `pkgconf` and possibly other tools. Signed-off-by: Rafael Kitover --- cmake/Set-Toolchain-vcpkg.cmake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/Set-Toolchain-vcpkg.cmake b/cmake/Set-Toolchain-vcpkg.cmake index cff10275..1152154f 100644 --- a/cmake/Set-Toolchain-vcpkg.cmake +++ b/cmake/Set-Toolchain-vcpkg.cmake @@ -10,19 +10,28 @@ if(NOT DEFINED VCPKG_TARGET_TRIPLET) # Check if we are in an MSVC environment. find_program(cl_exe_path NAME cl.exe HINTS ENV PATH) - if($ENV{CXX} MATCHES "cl.exe$" OR cl_exe_path) + if(ENV{CXX} MATCHES "cl.exe$" OR cl_exe_path) # Infer the architecture from the LIB folders. - foreach(LIB $ENV{LIB}) - if(${LIB} MATCHES "x64$") + foreach(lib $ENV{LIB}) + if(lib MATCHES "x64$") set(VBAM_VCPKG_PLATFORM "x64-windows-static") break() endif() - if(${LIB} MATCHES "x86$") + if(lib MATCHES "x86$") set(VBAM_VCPKG_PLATFORM "x86-windows-static") break() endif() - if(${LIB} MATCHES "ARM64$") + if(lib MATCHES "ARM64$") set(VBAM_VCPKG_PLATFORM "arm64-windows-static") + + foreach(path $ENV{PATH}) + if(path MATCHES "[Hh]ost[Xx]64") + set(VCPKG_HOST_TRIPLET "x64-windows-static" CACHE STRING "Vcpkg host triplet" FORCE) + set(VCPKG_USE_HOST_TOOLS ON CACHE BOOL "Use vcpkg host tools" FORCE) + break() + endif() + endforeach() + break() endif() endforeach()