12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #
- # Copyright (c) Contributors to the Open 3D Engine Project.
- # For complete copyright and license terms please see the LICENSE at the root of this distribution.
- #
- # SPDX-License-Identifier: Apache-2.0 OR MIT
- #
- #
- set(LY_ROOT_FOLDER "@LY_ROOT_FOLDER@")
- set(CMAKE_SCRIPT_MODE_FILE TRUE)
- include(@LY_ROOT_FOLDER@/cmake/3rdPartyPackages.cmake)
- if(EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@")
- file(SHA256 "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@" hash_of_downloaded_file)
- if (NOT "${hash_of_downloaded_file}" STREQUAL "@CPACK_CMAKE_PACKAGE_HASH@")
- message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found at @LY_CMAKE_PACKAGE_DOWNLOAD_PATH@ but expected hash missmatches, re-downloading...")
- file(REMOVE "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@")
- else()
- message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found")
- endif()
- endif()
- if(NOT EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@")
- # download it
- string(REPLACE "." ";" _version_components "@CPACK_DESIRED_CMAKE_VERSION@")
- list(GET _version_components 0 _major_version)
- list(GET _version_components 1 _minor_version)
- set(_url_version_tag "v${_major_version}.${_minor_version}")
- set(_package_url "https://cmake.org/files/${_url_version_tag}/@CPACK_CMAKE_PACKAGE_FILE@")
- message(STATUS "Downloading CMake @CPACK_DESIRED_CMAKE_VERSION@ for packaging...")
- download_file(
- URL ${_package_url}
- TARGET_FILE @LY_CMAKE_PACKAGE_DOWNLOAD_PATH@
- EXPECTED_HASH @CPACK_CMAKE_PACKAGE_HASH@
- RESULTS _results
- )
- list(GET _results 0 _status_code)
- if (${_status_code} EQUAL 0 AND EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@")
- message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found")
- else()
- file(REMOVE "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@")
- list(REMOVE_AT _results 0)
- set(_error_message "An error occurred, code ${_status_code}. URL ${_package_url} - ${_results}")
- if(${_status_code} EQUAL 1)
- string(APPEND _error_message
- " Please double check the CPACK_CMAKE_PACKAGE_FILE and "
- "CPACK_CMAKE_PACKAGE_HASH properties before trying again.")
- endif()
- message(FATAL_ERROR ${_error_message})
- endif()
- endif()
|