PALTools.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # PlatformTools enables to deal with tools that perform functionality cross-platform
  9. # For example, the AssetProcessor can generate assets for other platforms. For the
  10. # asset processor to be able to provide that, it requires to have the funcionality enabled.
  11. # This cmake file provides an entry point to discover variables that will allow to enable
  12. # the different platforms and variables that can be passed to enable those platforms to the
  13. # code.
  14. # Discover all the platforms that are available
  15. include(CMakePrintHelpers)
  16. set(LY_PAL_TOOLS_DEFINES)
  17. file(GLOB pal_tools_files "cmake/Platform/*/PALTools_*.cmake")
  18. foreach(pal_tools_file ${pal_tools_files})
  19. include(${pal_tools_file})
  20. endforeach()
  21. file(GLOB pal_restricted_tools_files "restricted/*/cmake/PALTools_*.cmake")
  22. foreach(pal_restricted_tools_file ${pal_restricted_tools_files})
  23. include(${pal_restricted_tools_file})
  24. endforeach()
  25. # Set the AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS macro using the aggregate of all the LY_PAL_TOOLS_RESTRICTED_PLATFORM_DEFINES variable
  26. if(LY_PAL_TOOLS_RESTRICTED_PLATFORM_DEFINES)
  27. list(JOIN LY_PAL_TOOLS_RESTRICTED_PLATFORM_DEFINES " " RESTRICTED_PLATFORM_DEFINES_MACRO)
  28. list(APPEND LY_PAL_TOOLS_DEFINES "AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS=${RESTRICTED_PLATFORM_DEFINES_MACRO}")
  29. endif()
  30. ly_set(LY_PAL_TOOLS_DEFINES ${LY_PAL_TOOLS_DEFINES})
  31. # Include files to the CMakeFiles project
  32. foreach(enabled_platform ${LY_PAL_TOOLS_ENABLED})
  33. string(TOLOWER ${enabled_platform} enabled_platform_lowercase)
  34. o3de_pal_dir(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${enabled_platform})
  35. ly_include_cmake_file_list(${pal_dir}/pal_tools_${enabled_platform_lowercase}_files.cmake)
  36. endforeach()
  37. function(ly_get_pal_tool_dirs out_list pal_path)
  38. set(pal_paths "")
  39. foreach(platform ${LY_PAL_TOOLS_ENABLED})
  40. o3d_pal_dir(path ${pal_path}/${platform} ${O3DE_ENGINE_RESTRICTED_PATH} ${LY_ROOT_FOLDER})
  41. list(APPEND pal_paths ${path})
  42. endforeach()
  43. set(${out_list} ${pal_paths} PARENT_SCOPE)
  44. endfunction()
  45. function(copy_java_to_build_dir common_relative_path file_paths)
  46. foreach(file_path ${file_paths})
  47. get_filename_component(target_path "${file_path}" DIRECTORY)
  48. # External Python script launches cmake with -B like C:/myProjectAndroid/app/o3de/profile/6v5z4r4t/arm64-v8a
  49. # We want to copy the extra Java source to C:/myProjectAndroid/app/src/main/${file_path}
  50. set(java_file_src ${CMAKE_CURRENT_SOURCE_DIR}/${common_relative_path}/${file_path})
  51. set(java_file_dest ${CMAKE_BINARY_DIR}/../../../../src/main/${target_path})
  52. cmake_print_variables(java_file_src)
  53. cmake_print_variables(java_file_dest)
  54. file(COPY ${java_file_src} DESTINATION ${java_file_dest})
  55. endforeach()
  56. endfunction()