summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject-verify.cmake.in
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2016-05-19 12:00:40 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-19 15:20:25 (GMT)
commite7d5e4b4bf864fa779e2fc90dfb352588bf82246 (patch)
treecdeaf46497e6800c86913220f63a0bab82bf68bc /Modules/ExternalProject-verify.cmake.in
parentebcc70271db52bd1ce8322485235152ac2c859aa (diff)
downloadCMake-e7d5e4b4bf864fa779e2fc90dfb352588bf82246.zip
CMake-e7d5e4b4bf864fa779e2fc90dfb352588bf82246.tar.gz
CMake-e7d5e4b4bf864fa779e2fc90dfb352588bf82246.tar.bz2
ExternalProject: Re-implement download verification as a dedicated script
Move the content to a `ExternalProject-verify.cmake.in` file and use `configure_file` to generate the final script.
Diffstat (limited to 'Modules/ExternalProject-verify.cmake.in')
-rw-r--r--Modules/ExternalProject-verify.cmake.in48
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 0000000..1d8db96
--- /dev/null
+++ b/Modules/ExternalProject-verify.cmake.in
@@ -0,0 +1,48 @@
+#=============================================================================
+# Copyright 2008-2013 Kitware, Inc.
+# Copyright 2016 Ruslan Baratov
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+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()
+
+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")