CMakeLists.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 version 3.22 is the minimum version needed for all of Open 3D Engine's supported platforms
  9. cmake_minimum_required(VERSION 3.22)
  10. if(NOT ${CMAKE_VERSION} VERSION_LESS "3.24")
  11. # CMP0135 - controls whether, when unpacking an archive file, it should:
  12. # (OLD) set the file timestamps to what they are in the archive (not recommended)
  13. # (NEW) set the file timestamps to the time of extraction (recommended)
  14. cmake_policy(SET CMP0135 NEW)
  15. endif()
  16. include(cmake/LySet.cmake)
  17. include(cmake/GeneralSettings.cmake)
  18. include(cmake/FileUtil.cmake)
  19. include(cmake/Version.cmake)
  20. include(cmake/OutputDirectory.cmake)
  21. if(NOT PROJECT_NAME)
  22. include(cmake/CompilerSettings.cmake)
  23. project(O3DE
  24. LANGUAGES C CXX
  25. VERSION ${O3DE_INSTALL_VERSION_STRING}
  26. )
  27. endif()
  28. ################################################################################
  29. # Initialize
  30. ################################################################################
  31. include(CTest)
  32. include(cmake/PAL.cmake)
  33. include(cmake/PALTools.cmake)
  34. include(cmake/RuntimeDependencies.cmake)
  35. include(cmake/Configurations.cmake) # Requires to be after PAL so we get platform variable definitions
  36. include(cmake/Dependencies.cmake)
  37. include(cmake/Deployment.cmake)
  38. include(cmake/3rdParty.cmake)
  39. include(cmake/LYPython.cmake)
  40. include(cmake/Install.cmake)
  41. include(cmake/LYWrappers.cmake)
  42. include(cmake/Gems.cmake)
  43. include(cmake/UnitTest.cmake)
  44. include(cmake/TestImpactFramework/TestImpactTestTargetConfig.cmake) # LYTestWrappers dependency
  45. include(cmake/LYTestWrappers.cmake)
  46. include(cmake/Monolithic.cmake)
  47. include(cmake/SettingsRegistry.cmake)
  48. include(cmake/CMakeFiles.cmake)
  49. include(cmake/O3DEJson.cmake)
  50. include(cmake/Subdirectories.cmake)
  51. include(cmake/TestImpactFramework/LYTestImpactFramework.cmake) # Put at end as nothing else depends on it
  52. # Gather the list of o3de_manifest external Subdirectories
  53. # into the O3DE_EXTERNAL_SUBDIRS_O3DE_MANIFEST_PROPERTY
  54. add_o3de_manifest_json_external_subdirectories()
  55. # Add the projects first so the Launcher can find them
  56. include(cmake/Projects.cmake)
  57. # Add external subdirectories listed in the engine.json.
  58. # O3DE_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
  59. # external subdirectories.
  60. add_engine_json_external_subdirectories()
  61. if(NOT INSTALLED_ENGINE)
  62. # Add the rest of the targets
  63. add_subdirectory(Assets)
  64. add_subdirectory(Code)
  65. add_subdirectory(python)
  66. add_subdirectory(Registry)
  67. add_subdirectory(scripts)
  68. add_subdirectory(Templates)
  69. add_subdirectory(Tools)
  70. # Invoke add_subdirectory on all external subdirectories
  71. # that is in use by the union of projects specified by path in LY_PROJECTS
  72. add_subdirectory_on_external_subdirs()
  73. else()
  74. ly_find_o3de_packages()
  75. add_subdirectory_on_external_subdirs()
  76. endif()
  77. ################################################################################
  78. # Post-processing
  79. ################################################################################
  80. # The following steps have to be done after all targets are registered:
  81. # 1. Add any dependencies registered via ly_enable_gems
  82. ly_enable_gems_delayed()
  83. # 2. Defer generation of the StaticModules.inl file which is needed to create the AZ::Module derived class in monolithic
  84. # builds until after all the targets are known and all the gems are enabled
  85. ly_delayed_generate_static_modules_inl()
  86. # 3. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
  87. # to provide applications with the filenames of gem modules to load
  88. # This must be done before ly_delayed_target_link_libraries() as that inserts BUILD_DEPENDENCIES as MANUALLY_ADDED_DEPENDENCIES
  89. # if the build dependency is a MODULE_LIBRARY. That would cause a false load dependency to be generated
  90. ly_delayed_generate_settings_registry()
  91. # 4. link targets where the dependency was yet not declared, we need to have the declaration so we do different
  92. # linking logic depending on the type of target
  93. ly_delayed_target_link_libraries()
  94. # 5. generate a registry file for unit testing for platforms that support unit testing
  95. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  96. ly_delayed_generate_unit_test_module_registry()
  97. endif()
  98. # 5. inject runtime dependencies to the targets. We need to do this after (1) since we are going to walk through
  99. # the dependencies
  100. ly_delayed_generate_runtime_dependencies()
  101. # 6. Perform test impact framework post steps once all of the targets have been enumerated
  102. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  103. ly_test_impact_post_step()
  104. endif()
  105. # 7. Generate the O3DE find file and setup install locations for scripts, tools, assets etc., required by the engine
  106. if(LY_INSTALL_ENABLED)
  107. # 8. Generate the O3DE find file and setup install locations for scripts, tools, assets etc., required by the engine
  108. ly_setup_o3de_install()
  109. # 9. CPack information (to be included after install)
  110. include(cmake/Packaging.cmake)
  111. endif()