Findo3de.cmake.in 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # Generated by O3DE
  9. include(FindPackageHandleStandardArgs)
  10. # This will be called from within the installed engine's CMakeLists.txt
  11. macro(ly_find_o3de_packages)
  12. if(LY_MONOLITHIC_GAME)
  13. set(monolithic_file "${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/Monolithic/o3de_subdirectories_${PAL_PLATFORM_NAME_LOWERCASE}.cmake")
  14. if(NOT EXISTS ${monolithic_file})
  15. message(FATAL_ERROR "O3DE SDK was not generated to support monolithic builds")
  16. endif()
  17. include("${monolithic_file}")
  18. else()
  19. include("${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/Default/o3de_subdirectories_${PAL_PLATFORM_NAME_LOWERCASE}.cmake")
  20. endif()
  21. find_package(LauncherGenerator)
  22. endmacro()
  23. function(o3de_current_file_path path)
  24. set(${path} ${CMAKE_CURRENT_FUNCTION_LIST_DIR} PARENT_SCOPE)
  25. endfunction()
  26. o3de_current_file_path(find_o3de_path)
  27. cmake_path(SET engine_root_folder NORMALIZE ${find_o3de_path}/..)
  28. set_property(GLOBAL PROPERTY O3DE_ENGINE_ROOT_FOLDER "${engine_root_folder}")
  29. # If the generation of the SDK layout had LY_DISABLE_TEST_MODULES cache variable set,
  30. # then the PAL_TRAIT_BUILD_TESTS_SUPPORTED value needs to be propagated as FALSE
  31. set(disable_test_modules @LY_DISABLE_TEST_MODULES@)
  32. if (disable_test_modules)
  33. set_property(GLOBAL PROPERTY PAL_TRAIT_BUILD_TESTS_SUPPORTED_DEFAULT FALSE)
  34. else()
  35. set_property(GLOBAL PROPERTY PAL_TRAIT_BUILD_TESTS_SUPPORTED_DEFAULT TRUE)
  36. endif()
  37. if ($ENV{O3DE_SNAP})
  38. list(APPEND CMAKE_REQUIRED_INCLUDES "$ENV{SNAP}/usr/include;$ENV{SNAP}/usr/include/x86_64-linux-gnu")
  39. list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "Wl,-L$ENV{SNAP}/usr/lib/x86_64-linux-gnu")
  40. list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-print-target-triple")
  41. endif()
  42. # Inject the CompilerSettings.cmake to be included before the project command
  43. set(CMAKE_PROJECT_INCLUDE_BEFORE "${engine_root_folder}cmake/CompilerSettings.cmake")
  44. # We are using the engine's CMakeLists.txt to handle initialization/importing targets
  45. # Since this is external to the project's source, we need to specify an output directory
  46. # even though we don't build
  47. macro(o3de_initialize)
  48. set(INSTALLED_ENGINE TRUE)
  49. set(LY_PROJECTS ${CMAKE_SOURCE_DIR})
  50. o3de_current_file_path(current_path)
  51. add_subdirectory(${current_path}/.. o3de)
  52. endmacro()