[vcpkg_download_distfile] Add condition for padding the SHA (#18459)

This commit is contained in:
NancyLi1013 2021-06-16 01:14:40 +08:00 committed by GitHub
parent 14418e1e48
commit 3910b29767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -27,7 +27,7 @@ vcpkg_from_github(
)
```
The important parts to update are `REPO` for the GitHub repository path, `REF` for a stable tag/commit to use, and `SHA512` with the checksum of the downloaded zipfile (you can get this easily by setting it to `1`, trying to install the package, and copying the checksum).
The important parts to update are `REPO` for the GitHub repository path, `REF` for a stable tag/commit to use, and `SHA512` with the checksum of the downloaded zipfile (you can get this easily by setting it to `0`, trying to install the package, and copying the checksum).
Finally, we configure the project with CMake, install the package, and copy over the license file:

View File

@ -80,12 +80,14 @@ function(vcpkg_download_distfile VAR)
message(FATAL_ERROR "vcpkg_download_distfile must not be passed both SHA512 and SKIP_SHA512.")
endif()
endif()
if(vcpkg_download_distfile_SHA512 STREQUAL "0")
string(REPEAT "0" 128 vcpkg_download_distfile_SHA512)
endif()
string(LENGTH "${vcpkg_download_distfile_SHA512}" vcpkg_download_distfile_SHA512_length)
if(NOT vcpkg_download_distfile_SHA512_length EQUAL "128")
message(FATAL_ERROR "Invalid SHA512: ${vcpkg_download_distfile_SHA512}. If you do not know the file's SHA512, set this to \"0\".")
if(NOT vcpkg_download_distfile_SKIP_SHA512)
if(vcpkg_download_distfile_SHA512 STREQUAL "0")
string(REPEAT "0" 128 vcpkg_download_distfile_SHA512)
endif()
string(LENGTH "${vcpkg_download_distfile_SHA512}" vcpkg_download_distfile_SHA512_length)
if(NOT vcpkg_download_distfile_SHA512_length EQUAL "128")
message(FATAL_ERROR "Invalid SHA512: ${vcpkg_download_distfile_SHA512}. If you do not know the file's SHA512, set this to \"0\".")
endif()
endif()
set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME})