123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- include_guard()
- include(${LY_ROOT_FOLDER}/cmake/LySet.cmake)
- set(LY_PACKAGE_SERVER_URLS "https://d3t6xeg4fgfoum.cloudfront.net" CACHE STRING "Server URLS to fetch packages from")
- if (DEFINED ENV{LY_PACKAGE_SERVER_URLS})
- set(LY_PACKAGE_SERVER_URLS $ENV{LY_PACKAGE_SERVER_URLS} ${LY_PACKAGE_SERVER_URLS})
- endif()
- set(LY_PACKAGE_KEEP_AFTER_DOWNLOADING TRUE CACHE BOOL "If enabled, packages will be kept after downloading them for later re-use")
- set(LY_PACKAGE_DOWNLOAD_CACHE_LOCATION @LY_3RDPARTY_PATH@/downloaded_packages CACHE PATH "Download location for packages (Defaults to @LY_3RDPARTY_PATH@/downloaded_packages)")
- if (DEFINED ENV{LY_PACKAGE_DOWNLOAD_CACHE_LOCATION})
- set(LY_PACKAGE_DOWNLOAD_CACHE_LOCATION $ENV{LY_PACKAGE_DOWNLOAD_CACHE_LOCATION})
- endif()
- string(CONFIGURE ${LY_PACKAGE_DOWNLOAD_CACHE_LOCATION} LY_PACKAGE_DOWNLOAD_CACHE_LOCATION @ONLY)
- set(LY_PACKAGE_UNPACK_LOCATION @LY_3RDPARTY_PATH@/packages CACHE PATH "Unpack location of downloaded packages (Defaults to @LY_3RDPARTY_PATH@/packages)")
- if (DEFINED ENV{LY_PACKAGE_UNPACK_LOCATION})
- set(LY_PACKAGE_UNPACK_LOCATION $ENV{LY_PACKAGE_UNPACK_LOCATION})
- endif()
- string(CONFIGURE ${LY_PACKAGE_UNPACK_LOCATION} LY_PACKAGE_UNPACK_LOCATION @ONLY)
- set(LY_PACKAGE_VALIDATE_CONTENTS FALSE CACHE BOOL "If enabled, will fully validate every file in every package based on the SHA256SUMS file from the package")
- set(LY_PACKAGE_VALIDATE_PACKAGE FALSE CACHE BOOL "If enabled, will validate that the downloaded package files hash matches the expected hash even if already downloaded and verified before.")
- set(LY_PACKAGE_DEBUG FALSE CACHE BOOL "If enabled, will output detailed information during package operations" )
- ly_set(LY_PACKAGE_EXT ".tar.xz")
- ly_set(LY_PACKAGE_HASH_EXT ".tar.xz.SHA256SUMS")
- ly_set(LY_PACKAGE_CONTENT_HASH_EXT ".tar.xz.content.SHA256SUMS")
- set(LY_PACKAGE_DOWNLOAD_RETRY_COUNT 3 CACHE STRING "3")
- if ("${LY_PACKAGE_DOWNLOAD_CACHE_LOCATION}" STREQUAL "")
- message(FATAL_ERROR "ly_package: LY_PACKAGE_DOWNLOAD_CACHE_LOCATION must be defined.")
- endif()
- macro(ly_package_message)
- if (LY_PACKAGE_DEBUG)
- message(${ARGN})
- endif()
- endmacro()
- include(${LY_ROOT_FOLDER}/cmake/LYPackage_S3Downloader.cmake)
- function(download_file_internal)
- set(_oneValueArgs URL TARGET_FILE EXPECTED_HASH RESULTS SHOULD_RETRY)
- cmake_parse_arguments(download_file_internal "" "${_oneValueArgs}" "" ${ARGN})
- if(NOT download_file_internal_URL)
- message(FATAL_ERROR "no URL arg passed into download_file_internal, it is required.")
- endif()
-
- if(NOT download_file_internal_TARGET_FILE)
- message(FATAL_ERROR "no TARGET_FILE arg passed into download_file_internal, it is required.")
- endif()
- if(NOT download_file_internal_EXPECTED_HASH)
- message(FATAL_ERROR "no EXPECTED_HASH arg passed into download_file_internal, it is required.")
- endif()
- if(NOT download_file_internal_RESULTS)
- message(FATAL_ERROR "no RESULTS arg passed into download_file_internal, it is required.")
- endif()
- if(NOT download_file_internal_SHOULD_RETRY)
- message(FATAL_ERROR "no SHOULD_RETRY arg passed into download_file_internal, it is required.")
- endif()
- set(${download_file_internal_RESULTS} "-1;unknown_error" PARENT_SCOPE)
- unset(${download_file_internal_SHOULD_RETRY} PARENT_SCOPE)
-
-
- ly_is_s3_url(${download_file_internal_URL} result_is_s3_bucket)
- if (result_is_s3_bucket)
- ly_s3_download("${download_file_internal_URL}" ${download_file_internal_TARGET_FILE} results)
- else()
- file(DOWNLOAD "${download_file_internal_URL}" ${download_file_internal_TARGET_FILE} STATUS results TLS_VERIFY ON LOG logic)
- list(APPEND results ${log})
- endif()
- list(GET results 0 code_returned)
-
-
- if (EXISTS ${download_file_internal_TARGET_FILE})
- file(SIZE ${download_file_internal_TARGET_FILE} target_size)
- if(target_size EQUAL 0)
- if(code_returned EQUAL 0)
-
- ly_package_message("Server gave us a zero byte file but still said ${results}, retrying...")
- set(code_returned 22)
- set(results "22;\nThe requested URL returned error: 500 Internal Error - Zero byte file returned despite good exit code\n")
- set(${download_file_internal_SHOULD_RETRY} TRUE PARENT_SCOPE)
- endif()
- endif()
- else()
-
- if (code_returned EQUAL 0)
- ly_package_message("Server gave us no file, but said ${results}, retrying...")
- set(code_returned 22)
- set(results "22;\nThe requested URL returned error: 500 Internal Error - Zero byte file returned despite good exit code\n")
- set(${download_file_internal_SHOULD_RETRY} TRUE PARENT_SCOPE)
- endif()
- endif()
- if(code_returned EQUAL 0)
-
- file(SHA256 ${download_file_internal_TARGET_FILE} hash_of_downloaded_file)
- if (NOT "${hash_of_downloaded_file}" STREQUAL "${download_file_internal_EXPECTED_HASH}" )
- set(results "1;Downloaded successfully, but the file hash did not match expected hash!")
- set(code_returned 1)
- endif()
- endif()
-
- if(code_returned)
-
-
- file(REMOVE ${download_file_internal_TARGET_FILE})
-
-
-
-
-
- if (${code_returned} EQUAL 22)
-
- string(REGEX MATCH "The requested URL returned error\\:([^\n]*)[\n]" found_string "${results}")
- if (found_string)
-
- ly_package_message("${results}")
-
- set(results ${code_returned} ${found_string})
-
-
-
-
- if (found_string MATCHES "500" OR found_string MATCHES "503")
- ly_package_message("500 or 503 code returned from server, will retry...")
- set(${download_file_internal_SHOULD_RETRY} TRUE PARENT_SCOPE)
- endif()
- endif()
- endif()
- endif()
- set(${download_file_internal_RESULTS} ${results} PARENT_SCOPE)
- endfunction()
- function(download_file)
- set(_oneValueArgs URL TARGET_FILE EXPECTED_HASH RESULTS)
- cmake_parse_arguments(download_file "" "${_oneValueArgs}" "" ${ARGN})
- if(NOT download_file_URL)
- message(FATAL_ERROR "no URL arg passed into download_file, it is required.")
- endif()
-
- if(NOT download_file_TARGET_FILE)
- message(FATAL_ERROR "no TARGET_FILE arg passed into download_file, it is required.")
- endif()
- if(NOT download_file_EXPECTED_HASH)
- message(FATAL_ERROR "no EXPECTED_HASH arg passed into download_file, it is required.")
- endif()
- if(NOT download_file_RESULTS)
- message(FATAL_ERROR "no RESULTS arg passed into download_file, it is required.")
- endif()
- set(${download_file_RESULTS} "-1;unknown_error" PARENT_SCOPE)
- foreach(retry_count RANGE 0 ${LY_PACKAGE_DOWNLOAD_RETRY_COUNT})
- download_file_internal( URL ${download_file_URL} TARGET_FILE ${download_file_TARGET_FILE} RESULTS results EXPECTED_HASH ${download_file_EXPECTED_HASH} SHOULD_RETRY should_retry)
- if (NOT should_retry)
- break()
- endif()
- ly_package_message("${retry_count} / ${LY_PACKAGE_DOWNLOAD_RETRY_COUNT} download retry attempts.")
- endforeach()
- set(${download_file_RESULTS} ${results} PARENT_SCOPE)
- endfunction()
- function(ly_package_internal_download_package package_name url_variable)
- unset(${url_variable} PARENT_SCOPE)
- unset(error_messages)
-
-
-
- if (NOT LY_PACKAGE_SERVER_URLS)
- message(SEND_ERROR "ly_package: - LY_PACKAGE_SERVER_URLS is empty, cannot download packages. enable LY_PACKAGE_DEBUG for details")
- return()
- endif()
- ly_get_package_expected_hash(${package_name} package_expected_hash)
- foreach(server_url ${LY_PACKAGE_SERVER_URLS})
- set(download_url ${server_url}/${package_name}${LY_PACKAGE_EXT})
- ly_package_get_target_cache(${package_name} package_download_cache_location)
- set(download_target ${package_download_cache_location}/${package_name}${LY_PACKAGE_EXT})
- file(REMOVE ${download_target})
- ly_package_message(STATUS "ly_package: trying to download ${download_url} to ${download_target}")
- ly_get_package_expected_hash(${package_name} expected_package_hash)
- download_file(URL ${download_url} TARGET_FILE ${download_target} EXPECTED_HASH ${expected_package_hash} RESULTS results)
- list(GET results 0 status_code)
-
- if (${status_code} EQUAL 0 AND EXISTS ${download_target})
- set(${url_variable} ${server_url} PARENT_SCOPE)
- ly_package_message(STATUS "ly_package: - downloaded ${server_url} for package ${package_name}")
- return()
- else()
-
- list(REMOVE_AT results 0)
- set(current_error_message "Error from server ${server_url} - ${status_code} - ${results}")
-
- string(REGEX REPLACE "[ \t\r\n]$" "" current_error_message "${current_error_message}")
- list(APPEND error_messages "${current_error_message}")
-
- file(REMOVE ${download_target})
- endif()
- endforeach()
-
-
-
-
- set(final_error_message "ly_package: - Unable to get package ${package_name} from any download server. Enable LY_PACKAGE_DEBUG to debug.")
- foreach(error_message ${error_messages})
- set(final_error_message "${final_error_message}\n${error_message}")
- endforeach()
- message(FATAL_ERROR "${final_error_message}")
- endfunction()
- function(parse_sha256sums_line input_hash_line output_hash output_file_name)
-
-
-
-
-
-
-
-
- set(REGEX_EXPRESSION "^([A-Za-z0-9]*) ( |\\*)(.*)$")
- string(REGEX REPLACE "${REGEX_EXPRESSION}" "\\1;\\3" temp_list "${input_hash_line}")
-
-
- list(LENGTH temp_list hash_length)
- if (NOT ${hash_length} EQUAL 2)
- unset(${output_hash} PARENT_SCOPE)
- unset(${output_file_name} PARENT_SCOPE)
- else()
- list(GET temp_list 0 temp_hash)
- list(GET temp_list 1 temp_filename)
- set(${output_hash} ${temp_hash} PARENT_SCOPE)
- set(${output_file_name} ${temp_filename} PARENT_SCOPE)
- endif()
- endfunction()
- function(ly_validate_sha256sums_file working_directory path_to_sha256sums_file)
- set(HASH_WAS_VALID FALSE PARENT_SCOPE)
- if (NOT EXISTS ${path_to_sha256sums_file})
- ly_package_message(STATUS "ly_package: Could not find SHA256SUMS file: ${path_to_sha256sums_file}")
- return()
- endif()
-
-
-
- set(ANY_HASH_MISMATCHES FALSE)
-
-
-
-
- file(STRINGS ${path_to_sha256sums_file} hash_data ENCODING UTF-8)
- foreach(hash_line IN ITEMS ${hash_data})
- parse_sha256sums_line("${hash_line}" expected_file_hash file_name)
- if (NOT expected_file_hash OR NOT file_name)
- message(SEND_ERROR "ly_package: Invalid format SHA256SUMS file: ${path_to_sha256sums_file} line ${hash_line} - cannot verify hashes. Enable LY_PACKAGE_DEBUG to debug.")
- return()
- endif()
- if (EXISTS ${working_directory}/${file_name})
- if (LY_PACKAGE_VALIDATE_CONTENTS)
- file(SHA256 ${working_directory}/${file_name} existing_hash)
- if (NOT "${existing_hash}" STREQUAL "${expected_file_hash}" )
- ly_package_message(STATUS "ly_package: File hash mismatch: ${working_directory}/${file_name}")
- set(ANY_HASH_MISMATCHES TRUE)
- else()
- ly_package_message(STATUS "ly_package: File hash matches: ${expected_file_hash} - ${file_name}")
- endif()
- endif()
- else()
- ly_package_message(STATUS "ly_package: Expected file was not found: ${working_directory}/${file_name}")
- set(ANY_HASH_MISMATCHES TRUE)
- endif()
- endforeach()
- if (${ANY_HASH_MISMATCHES})
- ly_package_message(STATUS "ly_package: Validation failed - files were missing, or had hash mismatches.")
- else()
- set(HASH_WAS_VALID TRUE PARENT_SCOPE)
- endif()
- endfunction()
- function(ly_package_get_target_folder package_name output_variable_name)
-
- get_property(overridden_location GLOBAL PROPERTY LY_PACKAGE_DOWNLOAD_LOCATION_${package_name})
- if (overridden_location)
- set(${output_variable_name} ${overridden_location} PARENT_SCOPE)
- elseif(NOT "${LY_PACKAGE_UNPACK_LOCATION}" STREQUAL "")
- set(${output_variable_name} ${LY_PACKAGE_UNPACK_LOCATION} PARENT_SCOPE)
- else()
- message(WARNING "ly_package: Could not locate the LY_PACKAGE_UNPACK_LOCATION variable"
- "'${LY_PACKAGE_UNPACK_LOCATION}' please fill it in!"
- " To compensate, this script will unpack into the build folder")
- set(${output_variable_name} ${CMAKE_BINARY_DIR} PARENT_SCOPE)
- endif()
- endfunction()
- function(ly_package_get_target_cache package_name output_variable_name)
- get_property(overridden_location GLOBAL PROPERTY LY_PACKAGE_DOWNLOAD_CACHE_LOCATION_${package_name})
- if (overridden_location)
- set(${output_variable_name} ${overridden_location} PARENT_SCOPE)
- else()
- set(${output_variable_name} ${LY_PACKAGE_DOWNLOAD_CACHE_LOCATION} PARENT_SCOPE)
- endif()
- endfunction()
- function(ly_validate_package package_name)
- ly_package_message(STATUS "ly_package: Validating ${package_name}...")
- unset(${package_name}_VALIDATED PARENT_SCOPE)
- ly_package_get_target_folder(${package_name} DOWNLOAD_LOCATION)
- if (NOT EXISTS "${DOWNLOAD_LOCATION}/${package_name}")
- ly_package_message(STATUS "ly_package: - ${package_name} is missing from ${DOWNLOAD_LOCATION}")
- return()
- endif()
-
- set(hash_file_name ${DOWNLOAD_LOCATION}/${package_name}/SHA256SUMS)
- set(json_file_name ${DOWNLOAD_LOCATION}/${package_name}/PackageInfo.json)
- if (NOT EXISTS ${hash_file_name})
- ly_package_message(STATUS "Hash file missing from package ${package_name} (or package does not exist at all)")
- return()
- endif()
- if (NOT EXISTS ${json_file_name})
- ly_package_message(STATUS "Package info file missing from package: ${json_file_name}")
- return()
- endif()
- set(package_stamp_file_name ${DOWNLOAD_LOCATION}/${package_name}.stamp)
- if (NOT EXISTS ${package_stamp_file_name})
-
-
-
-
- ly_package_message(STATUS "ly_package: Stamp file was missing, restoring: ${package_stamp_file_name}")
- file(TOUCH ${package_stamp_file_name})
- endif()
- if (LY_PACKAGE_VALIDATE_PACKAGE)
-
-
-
- message(STATUS "Checking downloaded package ${package_name} because LY_PACKAGE_VALIDATE_PACKAGE is TRUE")
- ly_package_get_target_cache(${package_name} package_download_cache_location)
- set(temp_download_target ${package_download_cache_location}/${package_name}${LY_PACKAGE_EXT})
- ly_get_package_expected_hash(${package_name} expected_package_hash)
- if (EXISTS ${temp_download_target})
- file(SHA256 ${temp_download_target} existing_hash)
- endif()
- if (NOT "${existing_hash}" STREQUAL "${expected_package_hash}" )
-
- ly_package_message(STATUS "LY_PACKAGE_VALIDATE_PACKAGE : $[package_name}${LY_PACKAGE_EXT} is either missing or has the wrong hash, re-downloading")
- return()
- endif()
- endif()
- if (NOT LY_PACKAGE_VALIDATE_CONTENTS)
- ly_package_message(STATUS "Basic validation checks performed only becuase LY_PACKAGE_VALIDATE_CONTENTS is not enabled.")
- set(${package_name}_VALIDATED TRUE PARENT_SCOPE)
- ly_package_message(STATUS "ly_package: Validated ${package_name} - Basic Validation OK")
- return()
- endif()
- ly_validate_sha256sums_file(
- ${DOWNLOAD_LOCATION}/${package_name}
- ${DOWNLOAD_LOCATION}/${package_name}/SHA256SUMS)
-
- if (HASH_WAS_VALID)
- set(${package_name}_VALIDATED TRUE PARENT_SCOPE)
- ly_package_message(STATUS "ly_package: Validated ${package_name} - Full Validation OK")
- endif()
- endfunction()
- function(ly_force_download_package package_name)
- unset(${package_name}_FOUND PARENT_SCOPE)
- unset(${package_name}_VALIDATED PARENT_SCOPE)
- ly_package_get_target_folder(${package_name} DOWNLOAD_LOCATION)
-
-
-
- if ("${package_name}" STREQUAL "" OR "${DOWNLOAD_LOCATION}" STREQUAL "")
- message(FATAL_ERROR "ly_package: ly_force_download_package called with invalid params! Enable LY_PACKAGE_DEBUG to debug.")
- endif()
- set(final_folder ${DOWNLOAD_LOCATION}/${package_name})
-
- ly_package_get_target_cache(${package_name} package_download_cache_location)
- set(temp_download_target ${package_download_cache_location}/${package_name}${LY_PACKAGE_EXT})
- ly_get_package_expected_hash(${package_name} expected_package_hash)
-
- if (EXISTS ${temp_download_target})
- ly_package_message(STATUS "The target ${temp_download_target} exists")
- file(SHA256 ${temp_download_target} existing_hash)
- endif()
- if (NOT "${existing_hash}" STREQUAL "${expected_package_hash}" )
- file(REMOVE ${temp_download_target})
-
-
-
- message(STATUS "Downloading package into ${final_folder}")
- ly_package_message(STATUS "ly_package: - downloading package '${package_name}' to '${final_folder}'")
- ly_package_internal_download_package(${package_name} ${temp_download_target})
-
-
- if (NOT EXISTS ${temp_download_target})
-
- return()
- endif()
- else()
- ly_package_message(STATUS "ly_package: - package already correct hash ${temp_download_target}, re-using")
- endif()
- if (EXISTS ${DOWNLOAD_LOCATION}/${package_name})
- ly_package_message(STATUS "ly_package: - removing folder ${DOWNLOAD_LOCATION}/${package_name} to replace it...")
- file(REMOVE_RECURSE ${DOWNLOAD_LOCATION}/${package_name})
- if (EXISTS ${DOWNLOAD_LOCATION}/${package_name})
- message(SEND_ERROR "ly_package: -folder ${DOWNLOAD_LOCATION}/${package_name} could not be removed. Check if some program has it open (VSCode, VS, Terminal windows, ...). Enable LY_PACKAGE_DEBUG to debug.")
- return()
- endif()
- endif()
-
- file(MAKE_DIRECTORY ${DOWNLOAD_LOCATION}/${package_name})
-
- ly_package_message(STATUS "ly_package: - unpacking package...")
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${temp_download_target}
- WORKING_DIRECTORY ${final_folder} COMMAND_ECHO STDOUT OUTPUT_VARIABLE unpack_result)
-
-
-
- file(GLOB_RECURSE package_files LIST_DIRECTORIES false ${final_folder}/*)
- file(TOUCH_NOCREATE ${package_files})
- if (NOT ${unpack_result} EQUAL 0)
- message(SEND_ERROR "ly_package: required package {package_name} could not be unpacked. Compile may fail! Enable LY_PACKAGE_DEBUG to debug.")
- return()
- else()
- if (NOT LY_PACKAGE_KEEP_AFTER_DOWNLOADING)
- ly_package_message(STATUS "ly_package: Removing package after unpacking (LY_PACKAGE_KEEP_AFTER_DOWNLOADING is ${LY_PACKAGE_KEEP_AFTER_DOWNLOADING})")
- file(REMOVE ${temp_download_target})
- endif()
- endif()
-
-
-
- set(LY_PACKAGE_VALIDATE_CONTENTS_old ${LY_PACKAGE_VALIDATE_CONTENTS})
- set(LY_PACKAGE_VALIDATE_CONTENTS TRUE)
- ly_validate_package(${package_name})
- set(LY_PACKAGE_VALIDATE_CONTENTS ${LY_PACKAGE_VALIDATE_CONTENTS_old})
- set(${package_name}_VALIDATED ${package_name}_VALIDATED PARENT_SCOPE)
- set(package_stamp_file_name ${DOWNLOAD_LOCATION}/${package_name}.stamp)
- if (${package_name}_VALIDATED)
-
- message(STATUS "Installed And Validated package at ${final_folder} - OK")
-
- file(TOUCH ${package_stamp_file_name})
- else()
- file(REMOVE ${package_stamp_file_name})
- endif()
- endfunction()
- function(ly_enable_package package_name)
-
-
-
- ly_package_get_target_folder(${package_name} DOWNLOAD_LOCATION)
-
-
- if (NOT "${DOWNLOAD_LOCATION}/${package_name}" IN_LIST "${CMAKE_MODULE_PATH}")
- set(CMAKE_MODULE_PATH ${DOWNLOAD_LOCATION}/${package_name} ${CMAKE_MODULE_PATH} PARENT_SCOPE)
- endif()
- get_property(existing_state GLOBAL PROPERTY LY_${package_name}_VALIDATED SET)
- if(NOT ${existing_state})
-
-
- set_property(GLOBAL PROPERTY LY_${package_name}_VALIDATED FALSE)
-
- ly_validate_package(${package_name})
- if (NOT ${package_name}_VALIDATED)
-
- ly_force_download_package(${package_name})
- endif()
-
- if(${package_name}_VALIDATED)
- set_property(GLOBAL PROPERTY LY_${package_name}_VALIDATED TRUE)
-
-
-
-
-
- message(STATUS "Using package ${DOWNLOAD_LOCATION}/${package_name}")
-
-
-
-
- set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${DOWNLOAD_LOCATION}/${package_name}/PackageInfo.json)
- endif()
- endif()
- endfunction()
- function(ly_associate_package)
- set(_oneValueArgs PACKAGE_NAME PACKAGE_HASH)
- set(_multiValueArgs TARGETS)
- cmake_parse_arguments(ly_associate_package "" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
-
- if(NOT ly_associate_package_TARGETS)
- message(FATAL_ERROR "ly_associate_package was called without the TARGETS argument, at least one target is required")
- endif()
-
- if(NOT ly_associate_package_PACKAGE_NAME)
- message(FATAL_ERROR "ly_associate_package was called without the PACKAGE_NAME argument, this is required")
- endif()
-
- if(NOT ly_associate_package_PACKAGE_HASH)
- message(FATAL_ERROR "ly_associate_package was called without the PACKAGE_HASH argument, this is required")
- endif()
-
- foreach(find_package_name ${ly_associate_package_TARGETS})
- set_property(GLOBAL PROPERTY LY_PACKAGE_ASSOCIATION_${find_package_name} ${ly_associate_package_PACKAGE_NAME})
- set_property(GLOBAL PROPERTY LY_PACKAGE_HASH_${ly_associate_package_PACKAGE_NAME} ${ly_associate_package_PACKAGE_HASH})
- endforeach()
- set_property(GLOBAL APPEND PROPERTY LY_PACKAGE_NAMES ${ly_associate_package_PACKAGE_NAME})
- set_property(GLOBAL PROPERTY LY_PACKAGE_TARGETS_${ly_associate_package_PACKAGE_NAME} ${ly_associate_package_TARGETS})
- endfunction()
- function(ly_get_package_association find_package_name output_variable)
- unset(${output_variable})
- get_property(is_associated GLOBAL PROPERTY LY_PACKAGE_ASSOCIATION_${find_package_name})
- if (is_associated)
- set(${output_variable} ${is_associated} PARENT_SCOPE)
- endif()
- endfunction()
- macro(ly_get_package_expected_hash actual_package_name output_variable)
- unset(${output_variable})
- get_property(package_hash_found GLOBAL PROPERTY LY_PACKAGE_HASH_${actual_package_name})
- if (package_hash_found)
- set(${output_variable} ${package_hash_found})
- else()
-
-
- message(FATAL_ERROR "ly_get_package_expected_hash could not find a hash for package ${actual_package_name}")
- endif()
- endmacro()
- macro(ly_set_package_download_location package_name download_location)
- set_property(GLOBAL PROPERTY LY_PACKAGE_DOWNLOAD_LOCATION_${package_name} ${download_location})
- endmacro()
- macro(ly_set_package_download_cache_location package_name download_location)
- set_property(GLOBAL PROPERTY LY_PACKAGE_DOWNLOAD_CACHE_LOCATION_${package_name} ${download_location})
- endmacro()
- macro(ly_download_associated_package find_library_name)
- unset(package_name)
- ly_get_package_association(${find_library_name} package_name)
- if (package_name)
-
- ly_enable_package(${package_name})
- endif()
- endmacro()
- function(ly_package_is_newer_than package_name reference_file output_variable)
- unset(${output_variable} PARENT_SCOPE)
- ly_package_get_target_folder(${package_name} DOWNLOAD_LOCATION)
- set(package_stamp_file_name ${DOWNLOAD_LOCATION}/${package_name}.stamp)
- if (EXISTS ${package_stamp_file_name} AND ${package_stamp_file_name} IS_NEWER_THAN ${reference_file})
- set(${output_variable} TRUE PARENT_SCOPE)
- endif()
- endfunction()
- if (NOT CMAKE_SCRIPT_MODE_FILE)
-
-
-
- include(${LY_ROOT_FOLDER}/cmake/3rdParty/BuiltInPackages.cmake)
- endif()
- if(PAL_TRAIT_BUILD_HOST_TOOLS)
- include(${LY_ROOT_FOLDER}/cmake/LYWrappers.cmake)
-
- ly_parse_third_party_dependencies(3rdParty::Qt)
- endif()
|