CMakeLists.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. # 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/MiniAudio/Code/Platform/<platorm_name> or
  13. # <restricted_folder>/<platform_name>/Gems/MiniAudio/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. # The MiniAudio.API target declares the common interface that users of this gem should depend on in their targets
  20. ly_add_target(
  21. NAME ${gem_name}.API INTERFACE
  22. NAMESPACE Gem
  23. FILES_CMAKE
  24. miniaudio_api_files.cmake
  25. ${pal_dir}/miniaudio_api_files.cmake
  26. INCLUDE_DIRECTORIES
  27. INTERFACE
  28. Include
  29. BUILD_DEPENDENCIES
  30. INTERFACE
  31. AZ::AzCore
  32. )
  33. # The MiniAudio.Private.Object target is an internal target
  34. # It should not be used outside of this Gems CMakeLists.txt
  35. ly_add_target(
  36. NAME ${gem_name}.Private.Object STATIC
  37. NAMESPACE Gem
  38. FILES_CMAKE
  39. miniaudio_private_files.cmake
  40. ${pal_dir}/miniaudio_private_files.cmake
  41. PLATFORM_INCLUDE_FILES
  42. ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
  43. TARGET_PROPERTIES
  44. O3DE_PRIVATE_TARGET TRUE
  45. INCLUDE_DIRECTORIES
  46. PRIVATE
  47. Include
  48. Source
  49. BUILD_DEPENDENCIES
  50. PUBLIC
  51. AZ::AzCore
  52. AZ::AzFramework
  53. PRIVATE
  54. 3rdParty::miniaudio
  55. 3rdParty::stb_vorbis
  56. )
  57. # Here add MiniAudio target, it depends on the Private Object library and Public API interface
  58. ly_add_target(
  59. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  60. NAMESPACE Gem
  61. FILES_CMAKE
  62. miniaudio_shared_files.cmake
  63. ${pal_dir}/miniaudio_shared_files.cmake
  64. INCLUDE_DIRECTORIES
  65. PUBLIC
  66. Include
  67. PRIVATE
  68. Source
  69. BUILD_DEPENDENCIES
  70. PUBLIC
  71. Gem::${gem_name}.API
  72. PRIVATE
  73. Gem::${gem_name}.Private.Object
  74. )
  75. # Inject the gem name into the Module source file
  76. ly_add_source_properties(
  77. SOURCES
  78. Source/Clients/MiniAudioModule.cpp
  79. PROPERTY COMPILE_DEFINITIONS
  80. VALUES
  81. O3DE_GEM_NAME=${gem_name}
  82. O3DE_GEM_VERSION=${gem_version})
  83. # By default, we will specify that the above target MiniAudio would be used by
  84. # Client and Server type targets when this gem is enabled. If you don't want it
  85. # active in Clients or Servers by default, delete one of both of the following lines:
  86. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  87. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  88. # For the Client and Server variants of MiniAudio Gem, an alias to the MiniAudio.API target will be made
  89. ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  90. ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  91. # If we are on a host platform, we want to add the host tools targets like the MiniAudio.Editor MODULE target
  92. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  93. # The MiniAudio.Editor.API target can be used by other gems that want to interact with the MiniAudio.Editor module
  94. ly_add_target(
  95. NAME ${gem_name}.Editor.API INTERFACE
  96. NAMESPACE Gem
  97. FILES_CMAKE
  98. miniaudio_editor_api_files.cmake
  99. ${pal_dir}/miniaudio_editor_api_files.cmake
  100. INCLUDE_DIRECTORIES
  101. INTERFACE
  102. Include
  103. BUILD_DEPENDENCIES
  104. INTERFACE
  105. AZ::AzToolsFramework
  106. )
  107. # The MiniAudio.Editor.Private.Object target is an internal target
  108. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  109. # Other gems should not use this target
  110. ly_add_target(
  111. NAME ${gem_name}.Editor.Private.Object STATIC
  112. NAMESPACE Gem
  113. FILES_CMAKE
  114. miniaudio_editor_private_files.cmake
  115. TARGET_PROPERTIES
  116. O3DE_PRIVATE_TARGET TRUE
  117. INCLUDE_DIRECTORIES
  118. PRIVATE
  119. Include
  120. Source
  121. BUILD_DEPENDENCIES
  122. PUBLIC
  123. AZ::AzToolsFramework
  124. AZ::AssetBuilderSDK
  125. ${gem_name}.Private.Object
  126. PRIVATE
  127. 3rdParty::miniaudio
  128. 3rdParty::stb_vorbis
  129. )
  130. ly_add_target(
  131. NAME ${gem_name}.Editor GEM_MODULE
  132. NAMESPACE Gem
  133. AUTOMOC
  134. FILES_CMAKE
  135. miniaudio_editor_shared_files.cmake
  136. INCLUDE_DIRECTORIES
  137. PRIVATE
  138. Source
  139. PUBLIC
  140. Include
  141. BUILD_DEPENDENCIES
  142. PUBLIC
  143. Gem::${gem_name}.Editor.API
  144. PRIVATE
  145. Gem::${gem_name}.Editor.Private.Object
  146. )
  147. # By default, we will specify that the above target MiniAudio would be used by
  148. # Tool and Builder type targets when this gem is enabled. If you don't want it
  149. # active in Tools or Builders by default, delete one of both of the following lines:
  150. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  151. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  152. # For the Tools and Builders variants of MiniAudio Gem, an alias to the MiniAudio.Editor API target will be made
  153. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  154. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  155. endif()