CMakeLists.txt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # {BEGIN_LICENSE}
  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. # {END_LICENSE}
  8. # Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
  9. # Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
  10. # Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
  11. # in which case it will see if that platform is present here or in the restricted folder.
  12. # i.e. It could here in our gem : Gems/${Name}/Code/Platform/<platorm_name> or
  13. # <restricted_folder>/<platform_name>/Gems/${Name}/Code
  14. o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
  15. # Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
  16. # traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
  17. # is supported by this platform.
  18. include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
  19. # Check to see if building the Gem Modules are supported for the current platform
  20. if(NOT PAL_TRAIT_${NameUpper}_SUPPORTED)
  21. return()
  22. endif()
  23. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor target which
  24. # will also depend on ${gem_name}.Editor.API target
  25. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  26. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  27. ly_add_target(
  28. NAME ${gem_name}.Editor.API INTERFACE
  29. NAMESPACE Gem
  30. FILES_CMAKE
  31. ${NameLower}_editor_api_files.cmake
  32. ${pal_dir}/${NameLower}_editor_api_files.cmake
  33. INCLUDE_DIRECTORIES
  34. INTERFACE
  35. Include
  36. BUILD_DEPENDENCIES
  37. INTERFACE
  38. AZ::AzToolsFramework
  39. )
  40. # The ${gem_name}.Editor.Private.Object target is an internal target
  41. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  42. # Other gems should not use this target
  43. ly_add_target(
  44. NAME ${gem_name}.Editor.Private.Object STATIC
  45. NAMESPACE Gem
  46. AUTORCC
  47. FILES_CMAKE
  48. ${NameLower}_editor_private_files.cmake
  49. TARGET_PROPERTIES
  50. O3DE_PRIVATE_TARGET TRUE
  51. INCLUDE_DIRECTORIES
  52. PRIVATE
  53. Include
  54. Source
  55. BUILD_DEPENDENCIES
  56. PUBLIC
  57. AZ::AzToolsFramework
  58. )
  59. ly_add_target(
  60. NAME ${gem_name}.Editor GEM_MODULE
  61. NAMESPACE Gem
  62. AUTOMOC
  63. FILES_CMAKE
  64. ${NameLower}_editor_shared_files.cmake
  65. INCLUDE_DIRECTORIES
  66. PRIVATE
  67. Source
  68. PUBLIC
  69. Include
  70. BUILD_DEPENDENCIES
  71. PUBLIC
  72. Gem::${gem_name}.Editor.API
  73. PRIVATE
  74. Gem::${gem_name}.Editor.Private.Object
  75. RUNTIME_DEPENDENCIES
  76. Gem::QtForPython.Editor
  77. )
  78. # Include the gem name into the Editor Module source file
  79. # for use with the AZ_DECLARE_MODULE_CLASS macro
  80. # This is to allow renaming of the gem to also cause
  81. # the CreateModuleClass_Gem_<gem-name> function which
  82. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  83. ly_add_source_properties(
  84. SOURCES
  85. Source/Tools/${Name}EditorModule.cpp
  86. PROPERTY COMPILE_DEFINITIONS
  87. VALUES
  88. O3DE_GEM_NAME=${gem_name}
  89. O3DE_GEM_VERSION=${gem_version})
  90. # By default, we will specify that the above target ${gem_name} would be used by
  91. # Tool and Builder type targets when this gem is enabled. If you don't want it
  92. # active in Tools or Builders by default, delete one of both of the following lines:
  93. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  94. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  95. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  96. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  97. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  98. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  99. # for the Tools and Builders gem variants
  100. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
  101. endif()
  102. ################################################################################
  103. # Tests
  104. ################################################################################
  105. # See if globally, tests are supported
  106. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  107. # We globally support tests, see if we support tests on this platform for ${gem_name}.Editor.Tests
  108. # If we are a host platform we want to add tools test like editor tests here
  109. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  110. endif()
  111. endif()