verify.cmake.in 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. cmake_minimum_required(VERSION 3.5)
  4. if("@LOCAL@" STREQUAL "")
  5. message(FATAL_ERROR "LOCAL can't be empty")
  6. endif()
  7. if(NOT EXISTS "@LOCAL@")
  8. message(FATAL_ERROR "File not found: @LOCAL@")
  9. endif()
  10. function(do_verify)
  11. if("@ALGO@" STREQUAL "")
  12. message(WARNING "File will not be verified since no URL_HASH specified")
  13. return()
  14. endif()
  15. if("@EXPECT_VALUE@" STREQUAL "")
  16. message(FATAL_ERROR "EXPECT_VALUE can't be empty")
  17. endif()
  18. message(STATUS
  19. "verifying file...
  20. file='@LOCAL@'")
  21. file("@ALGO@" "@LOCAL@" actual_value)
  22. if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@")
  23. message(FATAL_ERROR
  24. "error: @ALGO@ hash of
  25. @LOCAL@
  26. does not match expected value
  27. expected: '@EXPECT_VALUE@'
  28. actual: '${actual_value}'
  29. ")
  30. endif()
  31. message(STATUS "verifying file... done")
  32. endfunction()
  33. do_verify()
  34. set(extract_script "@extract_script_filename@")
  35. if(NOT "${extract_script}" STREQUAL "")
  36. include("${extract_script}")
  37. endif()