CMakeLists.txt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. # Copyright (c) Contributors to the Open 3D Engine Project.
  2. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #
  6. # Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
  7. # Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
  8. # Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
  9. # in which case it will see if that platform is present here or in the restricted folder.
  10. # i.e. It could here in our gem : Gems/${gem_name}/Code/Platform/<platorm_name> or
  11. # <restricted_folder>/<platform_name>/Gems/${gem_name}/Code
  12. o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
  13. # Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
  14. # traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
  15. # is supported by this platform.
  16. include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
  17. # The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
  18. ly_add_target(
  19. NAME ${gem_name}.API INTERFACE
  20. NAMESPACE Gem
  21. FILES_CMAKE
  22. compression_api_files.cmake
  23. ${pal_dir}/compression_api_files.cmake
  24. INCLUDE_DIRECTORIES
  25. INTERFACE
  26. Include
  27. BUILD_DEPENDENCIES
  28. INTERFACE
  29. AZ::AzCore
  30. )
  31. # Add the ${gem_name}.Private.Object target
  32. # Note: We include the common files and the platform specific files which are set in
  33. # 1.compression_private_files.cmake
  34. # 2.${pal_dir}/compression_private_files.cmake
  35. ly_add_target(
  36. NAME ${gem_name}.Private.Object STATIC
  37. NAMESPACE Gem
  38. FILES_CMAKE
  39. compression_private_files.cmake
  40. ${pal_dir}/compression_private_files.cmake
  41. INCLUDE_DIRECTORIES
  42. PRIVATE
  43. Include
  44. Source
  45. BUILD_DEPENDENCIES
  46. PUBLIC
  47. AZ::AzCore
  48. AZ::AzFramework
  49. )
  50. # Here add ${gem_name} target, it depends on the Private Object library and Public API interface
  51. ly_add_target(
  52. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  53. NAMESPACE Gem
  54. FILES_CMAKE
  55. compression_shared_files.cmake
  56. ${pal_dir}/compression_shared_files.cmake
  57. INCLUDE_DIRECTORIES
  58. PUBLIC
  59. Include
  60. PRIVATE
  61. Source
  62. BUILD_DEPENDENCIES
  63. PUBLIC
  64. Gem::${gem_name}.API
  65. PRIVATE
  66. Gem::${gem_name}.Private.Object
  67. )
  68. # Inject the gem name into the Module source file
  69. ly_add_source_properties(
  70. SOURCES
  71. Source/Clients/CompressionModule.cpp
  72. PROPERTY COMPILE_DEFINITIONS
  73. VALUES
  74. O3DE_GEM_NAME=${gem_name}
  75. O3DE_GEM_VERSION=${gem_version})
  76. # By default, we will specify that the above target ${gem_name} would be used by
  77. # Client and Server type targets when this gem is enabled. If you don't want it
  78. # active in Clients or Servers by default, delete one of both of the following lines:
  79. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  80. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  81. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  82. # For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
  83. ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  84. ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  85. ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  86. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
  87. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  88. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  89. ly_add_target(
  90. NAME ${gem_name}.Editor.API INTERFACE
  91. NAMESPACE Gem
  92. FILES_CMAKE
  93. compression_editor_api_files.cmake
  94. ${pal_dir}/compression_editor_api_files.cmake
  95. INCLUDE_DIRECTORIES
  96. INTERFACE
  97. Include
  98. BUILD_DEPENDENCIES
  99. INTERFACE
  100. AZ::AzToolsFramework
  101. )
  102. # The ${gem_name}.Editor.Private.Object target is an internal target
  103. # which is only to be used by this Gem's CMakeLists.txt and any Subdirectories
  104. # Other Gems should not use this target
  105. ly_add_target(
  106. NAME ${gem_name}.Editor.Private.Object STATIC
  107. NAMESPACE Gem
  108. FILES_CMAKE
  109. compression_editor_private_files.cmake
  110. INCLUDE_DIRECTORIES
  111. PRIVATE
  112. Include
  113. Source
  114. BUILD_DEPENDENCIES
  115. PUBLIC
  116. AZ::AzToolsFramework
  117. ${gem_name}.Private.Object
  118. )
  119. ly_add_target(
  120. NAME ${gem_name}.Editor GEM_MODULE
  121. NAMESPACE Gem
  122. AUTOMOC
  123. FILES_CMAKE
  124. compression_editor_shared_files.cmake
  125. INCLUDE_DIRECTORIES
  126. PRIVATE
  127. Source
  128. PUBLIC
  129. Include
  130. BUILD_DEPENDENCIES
  131. PUBLIC
  132. Gem::${gem_name}.Editor.API
  133. PRIVATE
  134. Gem::${gem_name}.Editor.Private.Object
  135. )
  136. # Inject the gem name into the Module source file
  137. ly_add_source_properties(
  138. SOURCES
  139. Source/Tools/CompressionEditorModule.cpp
  140. PROPERTY COMPILE_DEFINITIONS
  141. VALUES
  142. O3DE_GEM_NAME=${gem_name}
  143. O3DE_GEM_VERSION=${gem_version})
  144. # By default, we will specify that the above target ${gem_name} would be used by
  145. # Tool and Builder type targets when this gem is enabled. If you don't want it
  146. # active in Tools or Builders by default, delete one of both of the following lines:
  147. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  148. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  149. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  150. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  151. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  152. endif()
  153. ################################################################################
  154. # Tests
  155. ################################################################################
  156. # See if globally, tests are supported
  157. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  158. # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
  159. if(PAL_TRAIT_COMPRESSION_TEST_SUPPORTED)
  160. # We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
  161. ly_add_target(
  162. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  163. NAMESPACE Gem
  164. FILES_CMAKE
  165. compression_tests_files.cmake
  166. INCLUDE_DIRECTORIES
  167. PRIVATE
  168. Tests
  169. Source
  170. Include
  171. BUILD_DEPENDENCIES
  172. PRIVATE
  173. AZ::AzTest
  174. AZ::AzFramework
  175. Gem::${gem_name}.Private.Object
  176. )
  177. ly_add_googletest(
  178. NAME Gem::${gem_name}.Tests
  179. )
  180. endif()
  181. # If we are a host platform we want to add tools test like editor tests here
  182. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  183. # We are a host platform, see if Editor tests are supported on this platform
  184. if(PAL_TRAIT_COMPRESSION_EDITOR_TEST_SUPPORTED)
  185. # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
  186. # private ${gem_name}.Editor.Private.Object target
  187. ly_add_target(
  188. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  189. NAMESPACE Gem
  190. FILES_CMAKE
  191. compression_editor_tests_files.cmake
  192. INCLUDE_DIRECTORIES
  193. PRIVATE
  194. Tests
  195. Source
  196. Include
  197. BUILD_DEPENDENCIES
  198. PRIVATE
  199. AZ::AzTest
  200. Gem::${gem_name}.Editor.Private.Object
  201. )
  202. ly_add_googletest(
  203. NAME Gem::${gem_name}.Editor.Tests
  204. )
  205. endif()
  206. endif()
  207. endif()