diff options
author | Craig Scott <craig.scott@crascit.com> | 2021-02-04 20:32:58 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2021-02-04 20:33:38 (GMT) |
commit | 4f3d1abbb4dca3d1e6b019471fa5d8be296492e3 (patch) | |
tree | f3614845c0e2c7c904cb0be116462f8d80f1af47 /Modules/ExternalProject/verify.cmake.in | |
parent | 23aab9ecce264b7ea198fc9d36f382a4bb4fbe28 (diff) | |
download | CMake-4f3d1abbb4dca3d1e6b019471fa5d8be296492e3.zip CMake-4f3d1abbb4dca3d1e6b019471fa5d8be296492e3.tar.gz CMake-4f3d1abbb4dca3d1e6b019471fa5d8be296492e3.tar.bz2 |
ExternalProject: Refactor pre-configure steps to support no-target uses
The mkdir, download, update and patch steps are used by
FetchContent during the configure phase of the main build. Because
these steps need a target, this has so far required a sub-build to be
set up. The changes here factor out the preparation of the scripts
from the creation of the targets, allowing future work to leverage these
steps without a sub-build (see #21703).
As part of the refactoring, some rationalisation of the stamp files,
repository info files and script names was done to make things more
consistent between download methods and step implementations.
Every download method now records its own specific repository info
in a file and that file is a dependency of the download step. The source
directory is also written to that file, so if the SOURCE_DIR changes, the
download will be retriggered (the existing implementation fails in this
scenario). Each download method now also has just one driver script
that implements the whole step (it may pull in other scripts to do its
task though). The patch step gained support for USES_TERMINAL as
a result of generalising the implementation for custom commands.
Fixes: #21748
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 0000000..f37059b --- /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() |