summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
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.cmake
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.cmake')
-rw-r--r--Modules/ExternalProject.cmake43
1 files changed, 18 insertions, 25 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 9752fc7..2249501 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -377,6 +377,7 @@ file::
#=============================================================================
# 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.
@@ -418,6 +419,9 @@ endif()
set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$")
+set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}")
+get_filename_component(_ExternalProject_SELF_DIR "${_ExternalProject_SELF}" PATH)
+
function(_ep_parse_arguments f name ns args)
# Transfer the arguments to this function into target properties for the
# new custom target we just added so that we can set up all the build steps
@@ -937,33 +941,22 @@ endfunction()
function(_ep_write_verifyfile_script script_filename LOCAL hash)
if("${hash}" MATCHES "${_ep_hash_regex}")
- set(algo "${CMAKE_MATCH_1}")
- string(TOLOWER "${CMAKE_MATCH_2}" expect_value)
- set(script_content "set(expect_value \"${expect_value}\")
-set(succeeded 0)
- file(${algo} \"\${file}\" actual_value)
- if(\"\${actual_value}\" STREQUAL \"\${expect_value}\")
- set(succeeded 1)
- endif()
-
-if(\${succeeded})
- message(STATUS \"verifying file... done\")
-else()
- message(FATAL_ERROR \"error: ${algo} hash of
- \${file}
-does not match expected value
- expected: \${expect_value}
- actual: \${actual_value}
-\")
-endif()")
+ set(ALGO "${CMAKE_MATCH_1}")
+ string(TOLOWER "${CMAKE_MATCH_2}" EXPECT_VALUE)
else()
- set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")")
+ set(ALGO "")
+ set(EXPECT_VALUE "")
endif()
- file(WRITE ${script_filename} "set(file \"${LOCAL}\")
-message(STATUS \"verifying file...
- file='\${file}'\")
-${script_content}
-")
+
+ # Used variables:
+ # * ALGO
+ # * EXPECT_VALUE
+ # * LOCAL
+ configure_file(
+ "${_ExternalProject_SELF_DIR}/ExternalProject-verify.cmake.in"
+ "${script_filename}"
+ @ONLY
+ )
endfunction()