aboutsummaryrefslogtreecommitdiff
path: root/scripts/cmake/vcpkg_from_sourceforge.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cmake/vcpkg_from_sourceforge.cmake')
-rw-r--r--scripts/cmake/vcpkg_from_sourceforge.cmake85
1 files changed, 10 insertions, 75 deletions
diff --git a/scripts/cmake/vcpkg_from_sourceforge.cmake b/scripts/cmake/vcpkg_from_sourceforge.cmake
index 82286b346..de0e6c509 100644
--- a/scripts/cmake/vcpkg_from_sourceforge.cmake
+++ b/scripts/cmake/vcpkg_from_sourceforge.cmake
@@ -67,34 +67,6 @@ Specifies that the default removal of the top level folder should not occur.
#]===]
function(vcpkg_from_sourceforge)
- macro(check_file_content)
- if (EXISTS ${ARCHIVE})
- file(SIZE ${ARCHIVE} DOWNLOAD_FILE_SIZE)
- if (DOWNLOAD_FILE_SIZE LESS_EQUAL 1024)
- file(READ ${ARCHIVE} _FILE_CONTENT_)
- string(FIND "${_FILE_CONTENT_}" "the Sourceforge site is currently in Disaster Recovery mode." OUT_CONTENT)
- message("OUT_CONTENT: ${OUT_CONTENT}")
- if (OUT_CONTENT EQUAL -1)
- set(download_success 1)
- else()
- file(REMOVE ${ARCHIVE})
- endif()
- endif()
- endif()
- endmacro()
-
- macro(check_file_sha512)
- file(SHA512 ${ARCHIVE} FILE_HASH)
- if(NOT FILE_HASH STREQUAL _vdus_SHA512)
- message(FATAL_ERROR
- "\nFile does not have expected hash:\n"
- " File path: [ ${ARCHIVE} ]\n"
- " Expected hash: [ ${_vdus_SHA512} ]\n"
- " Actual hash: [ ${FILE_HASH} ]\n"
- "${CUSTOM_ERROR_ADVICE}\n")
- endif()
- endmacro()
-
set(booleanValueArgs DISABLE_SSL NO_REMOVE_ONE_LEVEL)
set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 FILENAME WORKING_DIRECTORY)
set(multipleValuesArgs PATCHES)
@@ -154,7 +126,8 @@ function(vcpkg_from_sourceforge)
string(SUBSTRING "${_vdus_SHA512}" 0 10 SANITIZED_REF)
- list(APPEND SOURCEFORGE_MIRRORS
+ set(Z_VCPKG_SOURCEFORGE_MIRRORS ${SOURCEFORGE_MIRRORS})
+ list(APPEND Z_VCPKG_SOURCEFORGE_MIRRORS
cfhcable # United States
pilotfiber # New York, NY
gigenet # Chicago, IL
@@ -176,56 +149,18 @@ function(vcpkg_from_sourceforge)
ufpr # Curitiba, Brazil
tenet # Wynberg, South Africa
)
-
- # Try to use auto-select first
- set(DOWNLOAD_URL ${URL}/download)
- message(STATUS "Trying auto-select mirror...")
+
+ set(URLS "${URL}/download")
+ foreach(SOURCEFORGE_MIRROR IN LISTS Z_VCPKG_SOURCEFORGE_MIRRORS)
+ list(APPEND URLS "${URL}/download?use_mirror=${SOURCEFORGE_MIRROR}")
+ endforeach()
+
vcpkg_download_distfile(ARCHIVE
- URLS "${DOWNLOAD_URL}"
- SKIP_SHA512
+ URLS ${URLS}
+ SHA512 "${_vdus_SHA512}"
FILENAME "${_vdus_FILENAME}"
- SILENT_EXIT
)
- check_file_content()
- if (download_success)
- check_file_sha512()
- else()
- message(STATUS "The default mirror is in Disaster Recovery mode, trying other mirrors...")
- endif()
-
- if (NOT download_success EQUAL 1)
- foreach(SOURCEFORGE_MIRROR ${SOURCEFORGE_MIRRORS})
- set(DOWNLOAD_URL ${URL}/download?use_mirror=${SOURCEFORGE_MIRROR})
- message(STATUS "Trying mirror ${SOURCEFORGE_MIRROR}...")
- vcpkg_download_distfile(ARCHIVE
- URLS "${DOWNLOAD_URL}"
- SKIP_SHA512
- FILENAME "${_vdus_FILENAME}"
- SILENT_EXIT
- )
-
- if (EXISTS ${ARCHIVE})
- set(download_success 1)
- check_file_content()
- if (download_success)
- check_file_sha512()
- else()
- message(STATUS "Mirror ${SOURCEFORGE_MIRROR} is in Disaster Recovery mode, trying other mirrors...")
- endif()
- break()
- endif()
- endforeach()
- endif()
- if (NOT download_success)
- message(FATAL_ERROR [[
- Couldn't download source from any of the sourceforge mirrors, please check your network.
- If you use a proxy, please set the HTTPS_PROXY and HTTP_PROXY environment
- variables to "http[s]://user:password@your-proxy-ip-address:port/".
- Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues
- ]])
- endif()
-
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE "${ARCHIVE}"