diff options
Diffstat (limited to 'Modules/ExternalProject/verify.cmake.in')
| -rw-r--r-- | Modules/ExternalProject/verify.cmake.in | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Modules/ExternalProject/verify.cmake.in b/Modules/ExternalProject/verify.cmake.in new file mode 100644 index 0000000000..f37059bf74 --- /dev/null +++ b/Modules/ExternalProject/verify.cmake.in @@ -0,0 +1,48 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.5) + +if("@LOCAL@" STREQUAL "") + message(FATAL_ERROR "LOCAL can't be empty") +endif() + +if(NOT EXISTS "@LOCAL@") + message(FATAL_ERROR "File not found: @LOCAL@") +endif() + +function(do_verify) + if("@ALGO@" STREQUAL "") + message(WARNING "File will not be verified since no URL_HASH specified") + return() + endif() + + if("@EXPECT_VALUE@" STREQUAL "") + message(FATAL_ERROR "EXPECT_VALUE can't be empty") + endif() + + message(STATUS +"verifying file... + file='@LOCAL@'") + + file("@ALGO@" "@LOCAL@" actual_value) + + if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@") + message(FATAL_ERROR +"error: @ALGO@ hash of + @LOCAL@ +does not match expected value + expected: '@EXPECT_VALUE@' + actual: '${actual_value}' +") + endif() + + message(STATUS "verifying file... done") +endfunction() + +do_verify() + +set(extract_script "@extract_script_filename@") +if(NOT "${extract_script}" STREQUAL "") + include("${extract_script}") +endif() |
