build: detect vcpkg host triplet for build deps

On Windows, detect the host triplet for vcpkg and prepend it to the
triplet list to get the binary packages for vcpkg build dependencies
correctly.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2023-12-31 16:06:41 +00:00
parent 7dc95076e5
commit d1aa4eb23d
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 14 additions and 3 deletions

View File

@ -224,10 +224,21 @@ function(get_binary_packages vcpkg_exe)
set(binary_packages_installed FALSE PARENT_SCOPE)
unset(triplets)
if(VCPKG_TARGET_TRIPLET MATCHES "^(.*)-static\$")
list(APPEND triplets "${CMAKE_MATCH_1}")
unset(host_triplet)
# Determine host triplet for vcpkg build dependencies
if(WIN32)
if($ENV{PROCESSOR_ARCHITECTURE} MATCHES "[Aa][Rr][Mm]64")
set(host_triplet "arm64-windows")
elseif($ENV{PROCESSOR_ARCHITECTURE} MATCHES "[Aa][Mm][Dd]64|[Xx]64")
set(host_triplet "x64-windows")
else()
set(host_triplet "x86-windows")
endif()
endif()
list(APPEND triplets "${VCPKG_TARGET_TRIPLET}")
if(DEFINED host_triplet)
list(APPEND triplets ${host_triplet})
endif()
list(APPEND triplets ${VCPKG_TARGET_TRIPLET})
foreach(triplet ${triplets})
file(