runtime_dependencies_common.cmake.in 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. cmake_minimum_required(VERSION 3.22)
  9. cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})"
  10. cmake_path(SET target_file_dir "@target_file_dir@")
  11. set(target_copy_files $<FILTER:$<REMOVE_DUPLICATES:"@target_copy_files@">,EXCLUDE,"^$">)
  12. set(target_target_files $<FILTER:$<REMOVE_DUPLICATES:"@target_target_files@">,EXCLUDE,"^$">)
  13. set(target_link_files $<FILTER:$<REMOVE_DUPLICATES:"@target_link_files@">,EXCLUDE,"^$">)
  14. set(target_imported_files $<FILTER:$<REMOVE_DUPLICATES:"@target_imported_files@">,EXCLUDE,"^$">)
  15. function(ly_copy source_files relative_target_directory)
  16. set(options)
  17. set(oneValueArgs TARGET_FILE_DIR SOURCE_TYPE SOURCE_GEM_MODULE)
  18. set(multiValueArgs)
  19. cmake_parse_arguments("${CMAKE_CURRENT_FUNCTION}" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  20. set(target_file_dir "${${CMAKE_CURRENT_FUNCTION}_TARGET_FILE_DIR}")
  21. set(source_type "${${CMAKE_CURRENT_FUNCTION}_SOURCE_TYPE}")
  22. set(source_is_gem "${${CMAKE_CURRENT_FUNCTION}_SOURCE_GEM_MODULE}")
  23. # Create the full path to the target directory
  24. cmake_path(APPEND target_directory "${target_file_dir}" "${relative_target_directory}")
  25. foreach(source_file IN LISTS source_files)
  26. cmake_path(GET source_file FILENAME target_filename)
  27. cmake_path(APPEND target_file "${target_directory}" "${target_filename}")
  28. cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location)
  29. if(NOT ${same_location})
  30. file(LOCK "${target_file}.lock" GUARD FUNCTION TIMEOUT 300)
  31. file(SIZE "${source_file}" source_file_size)
  32. if(EXISTS "${target_file}")
  33. file(SIZE "${target_file}" target_file_size)
  34. else()
  35. set(target_file_size 0)
  36. endif()
  37. if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}")
  38. message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...")
  39. file(MAKE_DIRECTORY "${full_target_directory}")
  40. file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
  41. file(TOUCH_NOCREATE "${target_file}")
  42. endif()
  43. endif()
  44. endforeach()
  45. endfunction()
  46. @LY_COPY_COMMANDS@
  47. file(TOUCH "@STAMP_OUTPUT_FILE@")