From e9162a0d28b1e3cace65e3b18166cbf6e6a4b7e7 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Thu, 2 Nov 2023 18:01:18 +0000 Subject: [PATCH] build: handle revisions for vcpkg binary packages Read the revision from the vcpkg binary package zip file names and from `vcpkg list` and use them in version comparisons. Also fix up the indentation a bit. Signed-off-by: Rafael Kitover --- cmake/Set-Toolchain-vcpkg.cmake | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/cmake/Set-Toolchain-vcpkg.cmake b/cmake/Set-Toolchain-vcpkg.cmake index 3f259405..8dacc0cb 100644 --- a/cmake/Set-Toolchain-vcpkg.cmake +++ b/cmake/Set-Toolchain-vcpkg.cmake @@ -135,6 +135,8 @@ endfunction() function(vcpkg_is_installed vcpkg_exe pkg_name pkg_version outvar) set(${outvar} FALSE PARENT_SCOPE) + string(REGEX REPLACE "-r([0-9]+)\$" ".\\1" pkg_version ${pkg_version}) + if(NOT DEFINED VCPKG_INSTALLED) execute_process( COMMAND ${vcpkg_exe} list @@ -150,14 +152,16 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_version outvar) endif() set(inst_pkg_name ${CMAKE_MATCH_1}) set(inst_pkg_version ${CMAKE_MATCH_2}) - + + string(REGEX REPLACE "#([0-9]+)\$" ".\\1" inst_pkg_version ${inst_pkg_version}) + list(APPEND VCPKG_INSTALLED ${inst_pkg_name} ${inst_pkg_version}) math(EXPR VCPKG_INSTALLED_COUNT "${VCPKG_INSTALLED_COUNT} + 1") endforeach() set(VCPKG_INSTALLED ${VCPKG_INSTALLED} PARENT_SCOPE) set(VCPKG_INSTALLED_COUNT ${VCPKG_INSTALLED_COUNT} PARENT_SCOPE) endif() - + if(NOT VCPKG_INSTALLED_COUNT GREATER 0) return() endif() @@ -168,7 +172,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_version outvar) math(EXPR idx_ver "${idx} + 1") list(GET VCPKG_INSTALLED ${idx} inst_pkg_name) list(GET VCPKG_INSTALLED ${idx_ver} inst_pkg_ver) - + if(inst_pkg_name STREQUAL pkg_name AND (NOT inst_pkg_ver VERSION_LESS pkg_version)) set(${outvar} TRUE PARENT_SCOPE) return() @@ -178,7 +182,7 @@ endfunction() function(get_binary_packages vcpkg_exe) set(binary_packages_installed FALSE PARENT_SCOPE) - + file( DOWNLOAD "https://nightly.vba-m.com/vcpkg/${VCPKG_TARGET_TRIPLET}/" ${CMAKE_BINARY_DIR}/binary_package_list.html STATUS pkg_list_status @@ -190,7 +194,7 @@ function(get_binary_packages vcpkg_exe) message(STATUS "Failed to download vcpkg binary package list: ${pkg_list_status} - ${pkg_list_error}") return() endif() - + file( STRINGS ${CMAKE_BINARY_DIR}/binary_package_list.html binary_packages_html REGEX "