diff options
| author | nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> | 2021-07-14 14:45:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-14 12:45:18 -0700 |
| commit | d369df7ecf194005eaca46f07368779cd486badd (patch) | |
| tree | 419f9861b796a7dc6e53646df13642c6c71108f2 /scripts/cmake/vcpkg_from_sourceforge.cmake | |
| parent | 932df5b8ede16b73fc5508445140d5b360ea0c68 (diff) | |
| download | vcpkg-d369df7ecf194005eaca46f07368779cd486badd.tar.gz vcpkg-d369df7ecf194005eaca46f07368779cd486badd.zip | |
[rollup:2021-07-06] Rollup PR (#18838)
* [rollup:2021-07-06 1/8] PR #18272 (@strega-nil)
[scripts-audit] vcpkg_from_*
* [rollup:2021-07-06 2/8] PR #18319 (@strega-nil)
[scripts-audit] add guidelines for cmake
* [rollup 2021-07-06 3/8] PR #18410 (@mheyman)
[vcpkg-cmake-config] documentation fix
* [rollup:2021-07-06 4/8] PR #18488 (@strega-nil)
[scripts-audit] vcpkg_execute_*
* [rollup:2021-07-06 5/8] PR #18517 (@strega-nil)
[scripts-audit] vcpkg_extract_source_archive
* [rollup:2021-07-06 6/8] PR #18674 (@NancyLi1013)
[vcpkg doc] Update examples
* [rollup:2021-07-06 7/8] PR #18695 (@JackBoosY)
[vcpkg] Update the minimum version of vcpkg
* [rollup:2021-07-06 8/8] PR #18758 (@ras0219-msft)
[vcpkg_from_git] Fix error if downloads folder does not exist
* build docs!
* fix bond:*-windows
* fix nmap
Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Co-authored-by: Michael Heyman <Michael.Heyman@jhuapl.edu>
Co-authored-by: NancyLi1013 <lirui09@beyondsoft.com>
Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Co-authored-by: Robert Schumacher <ras0219@outlook.com>
Diffstat (limited to 'scripts/cmake/vcpkg_from_sourceforge.cmake')
| -rw-r--r-- | scripts/cmake/vcpkg_from_sourceforge.cmake | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/scripts/cmake/vcpkg_from_sourceforge.cmake b/scripts/cmake/vcpkg_from_sourceforge.cmake index de0e6c509..a65cd7252 100644 --- a/scripts/cmake/vcpkg_from_sourceforge.cmake +++ b/scripts/cmake/vcpkg_from_sourceforge.cmake @@ -3,6 +3,10 @@ Download and extract a project from sourceforge. +This function automatically checks a set of sourceforge mirrors. +Additional mirrors can be injected through the `VCPKG_SOURCEFORGE_EXTRA_MIRRORS` +list variable in the triplet. + ## Usage: ```cmake vcpkg_from_sourceforge( @@ -53,9 +57,6 @@ A list of patches to be applied to the extracted sources. Relative paths are based on the port directory. -### DISABLE_SSL -Disable ssl when downloading source. - ### NO_REMOVE_ONE_LEVEL Specifies that the default removal of the top level folder should not occur. @@ -67,67 +68,51 @@ Specifies that the default removal of the top level folder should not occur. #]===] function(vcpkg_from_sourceforge) - set(booleanValueArgs DISABLE_SSL NO_REMOVE_ONE_LEVEL) - set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 FILENAME WORKING_DIRECTORY) - set(multipleValuesArgs PATCHES) - # parse parameters such that semicolons in options arguments to COMMAND don't get erased - cmake_parse_arguments(PARSE_ARGV 0 _vdus "${booleanValueArgs}" "${oneValueArgs}" "${multipleValuesArgs}") + cmake_parse_arguments(PARSE_ARGV 0 "arg" + "DISABLE_SSL;NO_REMOVE_ONE_LEVEL" + "OUT_SOURCE_PATH;REPO;REF;SHA512;FILENAME;WORKING_DIRECTORY" + "PATCHES") - if(NOT DEFINED _vdus_OUT_SOURCE_PATH) + if(NOT DEFINED arg_OUT_SOURCE_PATH) message(FATAL_ERROR "OUT_SOURCE_PATH must be specified.") endif() - - if(NOT DEFINED _vdus_SHA512) + if(NOT DEFINED arg_SHA512) message(FATAL_ERROR "SHA512 must be specified.") endif() - - if(NOT DEFINED _vdus_REPO) + if(NOT DEFINED arg_REPO) message(FATAL_ERROR "The sourceforge repository must be specified.") endif() - if(DEFINED _vdus_WORKING_DIRECTORY) - set(WORKING_DIRECTORY WORKING_DIRECTORY "${_vdus_WORKING_DIRECTORY}") - else() - set(WORKING_DIRECTORY) - endif() - if (_vdus_DISABLE_SSL) - set(URL_PROTOCOL http:) - else() - set(URL_PROTOCOL https:) + if(arg_DISABLE_SSL) + message(WARNING "DISABLE_SSL has been deprecated and has no effect") endif() - set(SOURCEFORGE_HOST ${URL_PROTOCOL}//sourceforge.net/projects) - - string(FIND ${_vdus_REPO} "/" FOUND_ORG) - if (NOT FOUND_ORG EQUAL -1) - string(SUBSTRING "${_vdus_REPO}" 0 ${FOUND_ORG} ORG_NAME) - math(EXPR FOUND_ORG "${FOUND_ORG} + 1") # skip the slash - string(SUBSTRING "${_vdus_REPO}" ${FOUND_ORG} -1 REPO_NAME) - if (REPO_NAME MATCHES "/") - message(FATAL_ERROR "REPO should contain at most one slash (found ${_vdus_REPO}).") - endif() - set(ORG_NAME ${ORG_NAME}/) + set(sourceforge_host "https://sourceforge.net/projects") + + if(arg_REPO MATCHES "^([^/]*)$") # just one element + set(org_name "${CMAKE_MATCH_1}") + set(repo_name "") + elseif(arg_REPO MATCHES "^([^/]*)/([^/]*)$") # two elements + set(org_name "${CMAKE_MATCH_1}") + set(repo_name "${CMAKE_MATCH_2}") else() - set(ORG_NAME ${_vdus_REPO}/) - set(REPO_NAME ) + message(FATAL_ERROR "REPO (${arg_REPO}) is not a valid repo name. It must be: + - an organization name without any slashes, or + - an organization name followed by a repository name separated by a single slash") endif() - if (DEFINED _vdus_REF) - set(URL "${SOURCEFORGE_HOST}/${ORG_NAME}files/${REPO_NAME}/${_vdus_REF}/${_vdus_FILENAME}") + if(DEFINED arg_REF) + set(url "${sourceforge_host}/${org_name}/files/${repo_name}/${arg_REF}/${arg_FILENAME}") + elseif(DEFINED repo_name) + set(url "${sourceforge_host}/${org_name}/${repo_name}/files/${arg_FILENAME}") else() - set(URL "${SOURCEFORGE_HOST}/${ORG_NAME}${REPO_NAME}/files/${_vdus_FILENAME}") + set(url "${sourceforge_host}/${org_name}/files/${arg_FILENAME}") endif() - set(NO_REMOVE_ONE_LEVEL ) - if (_vdus_NO_REMOVE_ONE_LEVEL) - set(NO_REMOVE_ONE_LEVEL "NO_REMOVE_ONE_LEVEL") - endif() - - string(SUBSTRING "${_vdus_SHA512}" 0 10 SANITIZED_REF) + string(SUBSTRING "${arg_SHA512}" 0 10 sanitized_ref) - set(Z_VCPKG_SOURCEFORGE_MIRRORS ${SOURCEFORGE_MIRRORS}) - list(APPEND Z_VCPKG_SOURCEFORGE_MIRRORS + set(sourceforge_mirrors cfhcable # United States pilotfiber # New York, NY gigenet # Chicago, IL @@ -149,26 +134,43 @@ function(vcpkg_from_sourceforge) ufpr # Curitiba, Brazil tenet # Wynberg, South Africa ) + if(DEFINED SOURCEFORGE_MIRRORS AND NOT DEFINED VCPKG_SOURCEFORGE_EXTRA_MIRRORS) + message(WARNING "Extension point SOURCEFORGE_MIRRORS has been deprecated. + Please use the replacement VCPKG_SOURCEFORGE_EXTRA_MIRRORS variable instead.") + list(APPEND sourceforge_mirrors "${SOURCEFORGE_MIRRORS}") + list(REMOVE_DUPLICATES sourceforge_mirrors) + elseif(DEFINED VCPKG_SOURCEFORGE_EXTRA_MIRRORS) + list(APPEND sourceforge_mirrors "${VCPKG_SOURCEFORGE_EXTRA_MIRRORS}") + list(REMOVE_DUPLICATES sourceforge_mirrors) + endif() - set(URLS "${URL}/download") - foreach(SOURCEFORGE_MIRROR IN LISTS Z_VCPKG_SOURCEFORGE_MIRRORS) - list(APPEND URLS "${URL}/download?use_mirror=${SOURCEFORGE_MIRROR}") + set(all_urls "${url}/download") + foreach(mirror IN LISTS sourceforge_mirrors) + list(APPEND all_urls "${url}/download?use_mirror=${mirror}") endforeach() - + vcpkg_download_distfile(ARCHIVE - URLS ${URLS} - SHA512 "${_vdus_SHA512}" - FILENAME "${_vdus_FILENAME}" + URLS ${all_urls} + SHA512 "${arg_SHA512}" + FILENAME "${arg_FILENAME}" ) + set(no_remove_one_level_param "") + set(working_directory_param "") + if(arg_NO_REMOVE_ONE_LEVEL) + set(no_remove_one_level_param "NO_REMOVE_ONE_LEVEL") + endif() + if(DEFINED arg_WORKING_DIRECTORY) + set(working_directory_param "WORKING_DIRECTORY" "${arg_WORKING_DIRECTORY}") + endif() vcpkg_extract_source_archive_ex( OUT_SOURCE_PATH SOURCE_PATH ARCHIVE "${ARCHIVE}" - REF "${SANITIZED_REF}" - ${NO_REMOVE_ONE_LEVEL} - ${WORKING_DIRECTORY} - PATCHES ${_vdus_PATCHES} + REF "${sanitized_ref}" + ${no_remove_one_level_param} + ${working_directory_param} + PATCHES ${arg_PATCHES} ) - set(${_vdus_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) + set("${arg_OUT_SOURCE_PATH}" "${SOURCE_PATH}" PARENT_SCOPE) endfunction() |
