[CMake] SHA is required (#3334)

This commit is contained in:
Dmitry Kurtaev authored and GitHub committed 2020-11-25 06:55:00 +03:00
1 parent 68f954709d
commit 5fc2724199
4 files changed
+6 -7

No files matched your search

+1 -2
View File
@@ -113,8 +113,7 @@ function (RESOLVE_DEPENDENCY NAME_OF_CMAKE_VAR)
endif()
if (NOT DEFINED SHA256)
message(WARNING "SHA is not specified for: " ${NAME_OF_CMAKE_VAR})
set(SHA256 "skip")
message(FATAL_ERROR "SHA is not specified for: " ${NAME_OF_CMAKE_VAR})
endif()
+2 -2
View File
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#
function (DownloadAndApply URL apply_to)
function (DownloadAndApply URL apply_to sha256)
if (EXISTS ${apply_to})
file(READ ${apply_to} patchFile4Bytes LIMIT 4)
@@ -16,7 +16,7 @@ function (DownloadAndApply URL apply_to)
file(REMOVE ${apply_to})
endif()
DownloadAndCheck(${URL} ${apply_to} TRUE result)
DownloadAndCheck(${URL} ${apply_to} TRUE result ${sha256})
else ()
set (MIGHT_BE_APPLIED 1)
endif()
+1 -1
View File
@@ -30,7 +30,7 @@ function (DownloadAndCheck from to fatal result sha256)
TIMEOUT 2000
RESULT_VARIABLE status_code)
file(SHA256 ${to} CHECKSUM)
if (NOT "${SHA256}" STREQUAL "skip" AND NOT ${CHECKSUM} STREQUAL ${sha256})
if (NOT ${CHECKSUM} STREQUAL ${sha256})
message(FATAL_ERROR "Hash mismatch:\n"
"expected: ${sha256}\n"
"got: ${CHECKSUM}")
+2 -2
View File
@@ -200,12 +200,12 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
string(REPLACE ${TEMP} ${ALTERNATIVE_PATH} archive_path ${archive_path})
debug_message("dependency different: use local path for fetching updated version: ${alternative_path}")
CheckOrDownloadAndExtract(${component} ${RELATIVE_URL} ${archive_name} ${unpacked_path} ${result_path} ${folder} ${fattal} ${resultExt} FALSE)
CheckOrDownloadAndExtract(${component} ${RELATIVE_URL} ${archive_name} ${unpacked_path} ${result_path} ${folder} ${fattal} ${resultExt} FALSE ${sha256})
else()
debug_message("dependency updated: download it again")
file(REMOVE_RECURSE "${unpacked_path}")
DownloadOrExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} status)
DownloadOrExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} status ${sha256})
endif()
endif ()
endif()