From 59d67fe70373976e602c4fccbca3d16b655f81d9 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 1 Dec 2023 10:38:20 +0000 Subject: [PATCH] build: fix check for vcpkg ports in vcpkg clones Fix checking for already installed vcpkg ports in user vcpkg clones, broken in 491f104b (build: better binpkg support for default VS vcpkg, 2023-11-30). Checking for installed ports in the VS default vcpkg is still broken, because it does not implement the list command. Signed-off-by: Rafael Kitover --- cmake/Set-Toolchain-vcpkg.cmake | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cmake/Set-Toolchain-vcpkg.cmake b/cmake/Set-Toolchain-vcpkg.cmake index 791593da..ce1b187a 100644 --- a/cmake/Set-Toolchain-vcpkg.cmake +++ b/cmake/Set-Toolchain-vcpkg.cmake @@ -151,11 +151,12 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet outvar) set(VCPKG_INSTALLED_COUNT 0 PARENT_SCOPE) foreach(pkg ${vcpkg_list_raw}) - if(NOT pkg MATCHES "^([^:[]+)[^:]*:${pkg_triplet} +([0-9][^ ]*) +.*\$") + if(NOT pkg MATCHES "^([^:[]+)[^:]*:([^ ]+) +([0-9][^ ]*) +.*\$") continue() endif() - set(inst_pkg_name ${CMAKE_MATCH_1}) - set(inst_pkg_ver ${CMAKE_MATCH_2}) + set(inst_pkg_name ${CMAKE_MATCH_1}) + set(inst_pkg_ver ${CMAKE_MATCH_3}) + set(inst_pkg_triplet ${CMAKE_MATCH_2}) unset(CMAKE_MATCH_1) string(REGEX REPLACE "#([0-9]+)\$" "" inst_pkg_ver ${inst_pkg_ver}) @@ -167,7 +168,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet outvar) string(REPLACE "-" "." inst_pkg_ver ${inst_pkg_ver}) - list(APPEND VCPKG_INSTALLED ${inst_pkg_name} ${inst_pkg_ver} ${inst_pkg_rev}) + list(APPEND VCPKG_INSTALLED ${inst_pkg_name} ${inst_pkg_ver} ${inst_pkg_rev} ${inst_pkg_triplet}) math(EXPR VCPKG_INSTALLED_COUNT "${VCPKG_INSTALLED_COUNT} + 1") endforeach() set(VCPKG_INSTALLED ${VCPKG_INSTALLED} PARENT_SCOPE) @@ -178,14 +179,20 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet outvar) return() endif() - math(EXPR idx_max "(${VCPKG_INSTALLED_COUNT} - 1) * 3") + math(EXPR idx_max "(${VCPKG_INSTALLED_COUNT} - 1) * 4") - foreach(idx RANGE 0 ${idx_max} 3) - math(EXPR idx_ver "${idx} + 1") - math(EXPR idx_rev "${idx} + 2") - list(GET VCPKG_INSTALLED ${idx} inst_pkg_name) - list(GET VCPKG_INSTALLED ${idx_ver} inst_pkg_ver) - list(GET VCPKG_INSTALLED ${idx_rev} inst_pkg_rev) + foreach(idx RANGE 0 ${idx_max} 4) + math(EXPR idx_ver "${idx} + 1") + math(EXPR idx_rev "${idx} + 2") + math(EXPR idx_triplet "${idx} + 3") + list(GET VCPKG_INSTALLED ${idx} inst_pkg_name) + list(GET VCPKG_INSTALLED ${idx_ver} inst_pkg_ver) + list(GET VCPKG_INSTALLED ${idx_rev} inst_pkg_rev) + list(GET VCPKG_INSTALLED ${idx_triplet} inst_pkg_triplet) + + if(NOT inst_pkg_triplet STREQUAL pkg_triplet) + continue() + endif() if(inst_pkg_name STREQUAL pkg_name AND pkg_ver VERSION_LESS inst_pkg_ver