CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. # Setup the gem meta variables that includes the "gem_path", "gem_name" and "gem_version"
  9. # The "pal_dir" variable is also set which refers to the Platform/<platform-name> directory
  10. # based on the directory of this CMakeLists.txt
  11. o3de_gem_setup("${Name}")
  12. # Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
  13. # traits for this platform. Traits for a platform are defines for things like whether or not something in this project
  14. # is supported by this platform.
  15. include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
  16. # Now that we have loaded our project traits for this platform, see if this project is even supported on this platform.
  17. # If its not supported we just return after including the unsupported.
  18. if(NOT PAL_TRAIT_${NameUpper}_SUPPORTED)
  19. return()
  20. endif()
  21. # We are on a supported platform, so add the ${gem_name} target
  22. # Note: We include the common files and the platform specific files which are set in ${NameLower}_files.cmake and
  23. # in ${pal_dir}/${NameLower}_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  24. # The ${gem_name}.Private.Object target is an internal target
  25. # It should not be used outside of this CMakeLists.txt
  26. ly_add_target(
  27. NAME ${gem_name}.Private.Object STATIC
  28. NAMESPACE Gem
  29. FILES_CMAKE
  30. ${NameLower}_files.cmake
  31. ${pal_dir}/${NameLower}_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  32. INCLUDE_DIRECTORIES
  33. PUBLIC
  34. Include
  35. BUILD_DEPENDENCIES
  36. PRIVATE
  37. AZ::AzGameFramework
  38. Gem::Atom_AtomBridge.Static
  39. )
  40. ly_add_target(
  41. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  42. NAMESPACE Gem
  43. FILES_CMAKE
  44. ${NameLower}_shared_files.cmake
  45. ${pal_dir}/${NameLower}_shared_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  46. INCLUDE_DIRECTORIES
  47. PUBLIC
  48. Include
  49. BUILD_DEPENDENCIES
  50. PRIVATE
  51. Gem::${gem_name}.Private.Object
  52. AZ::AzCore
  53. )
  54. # Include the gem name into the Client Module source file
  55. # for use with the AZ_DECLARE_MODULE_CLASS macro
  56. # This is to allow renaming of the gem to also cause
  57. # the CreateModuleClass_Gem_<gem-name> function which
  58. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  59. ly_add_source_properties(
  60. SOURCES
  61. Source/${Name}Module.cpp
  62. PROPERTY COMPILE_DEFINITIONS
  63. VALUES
  64. O3DE_GEM_NAME=${gem_name}
  65. O3DE_GEM_VERSION=${gem_version})
  66. # if enabled, ${gem_name} is used by all kinds of applications
  67. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name})
  68. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name})
  69. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  70. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  71. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  72. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  73. # for the primary gem variants used in most o3de applications
  74. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Builders Tools Clients Servers Unified)
  75. ################################################################################
  76. # Gem dependencies
  77. ################################################################################
  78. # Query the project name from the nearest project.json file in a directory at or above
  79. # the current one.
  80. # This gem is the project gem and therefore should be part of the project that is using it
  81. o3de_find_ancestor_project_root(project_path project_name "${CMAKE_CURRENT_SOURCE_DIR}")
  82. # If the project name could not be queried from a project.json file, then fallback
  83. # to using the name of the project provided when the project template was instantiated
  84. if (NOT project_name)
  85. set(project_name ${Name})
  86. endif()