@@ -23,7 +23,10 @@ function(_vcpkg_checkout vcpkg_root vcpkg_ref)
2323 message (STATUS "vcpkg checkout to ${vcpkg_ref} " )
2424
2525 if (EXISTS "${vcpkg_root} /.git/shallow" )
26- message (WARNING "vcpkg is shallow, unshallowing..." )
26+ message (
27+ WARNING
28+ "vcpkg is shallow now and unshallow to retrieve the Git tree object hash for a specific version port......"
29+ )
2730 execute_process (
2831 COMMAND ${GIT_EXECUTABLE} fetch --unshallow
2932 WORKING_DIRECTORY ${vcpkg_root}
@@ -78,7 +81,24 @@ function(_vcpkg_tool_bootstrap vcpkg_root)
7881 RESULT_VARIABLE result)
7982
8083 if (NOT result EQUAL "0" )
81- message (FATAL_ERROR "${bootstrap_cmd} failed with ${result} " )
84+ if (CMAKE_HOST_UNIX )
85+ message (STATUS "Retry to build vcpkg from source..." )
86+ set (bootstrap_impl "${vcpkg_root} /scripts/bootstrap.sh" )
87+ file (READ "${bootstrap_impl} " file_contents)
88+ string (REPLACE [[elif [ "$ARCH" = "x86_64" ]; then]]
89+ [[elif [ "$ARCH" = "" ]; then]] file_contents
90+ "${file_contents} " )
91+ file (WRITE "${bootstrap_impl} " "${file_contents} " )
92+
93+ execute_process (
94+ COMMAND ${bootstrap_cmd} -disableMetrics
95+ WORKING_DIRECTORY ${vcpkg_root}
96+ RESULT_VARIABLE result)
97+ endif ()
98+
99+ if (NOT result EQUAL "0" )
100+ message (FATAL_ERROR "${bootstrap_cmd} failed with ${result} " )
101+ endif ()
82102 endif ()
83103endfunction ()
84104
@@ -109,7 +129,7 @@ function(_vcpkg_upgrade vcpkg_root vcpkg_repo vcpkg_ref)
109129
110130 message (STATUS "Upgrade vcpkg" )
111131 message (STATUS "vcpkg current commit: ${current_git_hash} " )
112- message (STATUS "vcpkg release: ${vcpkg_ref} " )
132+ message (STATUS "vcpkg target commit: ${vcpkg_ref} " )
113133
114134 execute_process (
115135 COMMAND ${GIT_EXECUTABLE} remote set-url origin ${vcpkg_repo}
@@ -136,9 +156,7 @@ endfunction()
136156
137157# find root
138158function (_vcpkg_find_root cache_dir_name out_vcpkg_root)
139- if (DEFINED ENV{VCPKG_ROOT} AND NOT "$ENV{VCPKG_ROOT} " STREQUAL "" )
140- set (root "$ENV{VCPKG_ROOT} " )
141- elseif ("${__vcpkg_bootstrap_host} " STREQUAL "Windows" )
159+ if ("${__vcpkg_bootstrap_host} " STREQUAL "Windows" )
142160 set (root "$ENV{LOCALAPPDATA} /vcpkg/projects/${cache_dir_name} /cache" )
143161 else ()
144162 set (root "$ENV{HOME} /.cache/vcpkg/projects/${cache_dir_name} " )
0 commit comments