Findo3de.cmake.in 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 ($ENV{O3DE_SNAP})
  30. list(APPEND CMAKE_REQUIRED_INCLUDES "$ENV{SNAP}/usr/include;$ENV{SNAP}/usr/include/x86_64-linux-gnu")
  31. list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "Wl,-L$ENV{SNAP}/usr/lib/x86_64-linux-gnu")
  32. list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-print-target-triple")
  33. endif()
  34. # Inject the CompilerSettings.cmake to be included before the project command
  35. set(CMAKE_PROJECT_INCLUDE_BEFORE "${engine_root_folder}cmake/CompilerSettings.cmake")
  36. # We are using the engine's CMakeLists.txt to handle initialization/importing targets
  37. # Since this is external to the project's source, we need to specify an output directory
  38. # even though we don't build
  39. macro(o3de_initialize)
  40. set(INSTALLED_ENGINE TRUE)
  41. set(LY_PROJECTS ${CMAKE_SOURCE_DIR})
  42. include(CTest) # automatically triggers enable_testing
  43. o3de_current_file_path(current_path)
  44. add_subdirectory(${current_path}/.. o3de)
  45. endmacro()