CMakeLists.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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/Archive/Code/Platform/<platorm_name> or
  11. # <restricted_folder>/<platform_name>/Gems/Archive/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. # Check to see if building the Gem Modules are supported for the current platform
  18. if(NOT PAL_TRAIT_ARCHIVE_SUPPORTED)
  19. return()
  20. endif()
  21. # The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
  22. ly_add_target(
  23. NAME ${gem_name}.API INTERFACE
  24. NAMESPACE Gem
  25. FILES_CMAKE
  26. archive_api_files.cmake
  27. ${pal_dir}/archive_api_files.cmake
  28. INCLUDE_DIRECTORIES
  29. INTERFACE
  30. Include
  31. BUILD_DEPENDENCIES
  32. INTERFACE
  33. AZ::AzCore
  34. Gem::Compression.API
  35. )
  36. # The ${gem_name}.Private.Object target is an internal target
  37. # It should not be used outside of this Gems CMakeLists.txt
  38. ly_add_target(
  39. NAME ${gem_name}.Private.Object STATIC
  40. NAMESPACE Gem
  41. FILES_CMAKE
  42. archive_private_files.cmake
  43. ${pal_dir}/archive_private_files.cmake
  44. TARGET_PROPERTIES
  45. O3DE_PRIVATE_TARGET TRUE
  46. INCLUDE_DIRECTORIES
  47. PRIVATE
  48. Include
  49. Source
  50. BUILD_DEPENDENCIES
  51. PUBLIC
  52. AZ::AzCore
  53. AZ::AzFramework
  54. Gem::${gem_name}.API
  55. )
  56. # Here add ${gem_name} target, it depends on the Private Object library and Public API interface
  57. ly_add_target(
  58. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  59. NAMESPACE Gem
  60. FILES_CMAKE
  61. archive_shared_files.cmake
  62. ${pal_dir}/archive_shared_files.cmake
  63. INCLUDE_DIRECTORIES
  64. PUBLIC
  65. Include
  66. PRIVATE
  67. Source
  68. BUILD_DEPENDENCIES
  69. PUBLIC
  70. Gem::${gem_name}.API
  71. PRIVATE
  72. Gem::${gem_name}.Private.Object
  73. )
  74. # Inject the gem name into the Module source file
  75. ly_add_source_properties(
  76. SOURCES
  77. Source/Clients/ArchiveModule.cpp
  78. PROPERTY COMPILE_DEFINITIONS
  79. VALUES
  80. O3DE_GEM_NAME=${gem_name}
  81. O3DE_GEM_VERSION=${gem_version})
  82. # By default, we will specify that the above target ${gem_name} would be used by
  83. # Client and Server type targets when this gem is enabled. If you don't want it
  84. # active in Clients or Servers by default, delete one of both of the following lines:
  85. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  86. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  87. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  88. # For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.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. ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  92. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
  93. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  94. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  95. ly_add_target(
  96. NAME ${gem_name}.Editor.API INTERFACE
  97. NAMESPACE Gem
  98. FILES_CMAKE
  99. archive_editor_api_files.cmake
  100. ${pal_dir}/archive_editor_api_files.cmake
  101. INCLUDE_DIRECTORIES
  102. INTERFACE
  103. Include
  104. BUILD_DEPENDENCIES
  105. INTERFACE
  106. AZ::AzToolsFramework
  107. ${gem_name}.API
  108. )
  109. # The ${gem_name}.Editor.Private.Object target is an internal target
  110. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  111. # Other gems should not use this target
  112. ly_add_target(
  113. NAME ${gem_name}.Editor.Private.Object STATIC
  114. NAMESPACE Gem
  115. FILES_CMAKE
  116. archive_editor_private_files.cmake
  117. TARGET_PROPERTIES
  118. O3DE_PRIVATE_TARGET TRUE
  119. INCLUDE_DIRECTORIES
  120. PRIVATE
  121. Include
  122. Source
  123. BUILD_DEPENDENCIES
  124. PUBLIC
  125. AZ::AzToolsFramework
  126. ${gem_name}.Editor.API
  127. ${gem_name}.Private.Object
  128. )
  129. ly_add_target(
  130. NAME ${gem_name}.Editor GEM_MODULE
  131. NAMESPACE Gem
  132. AUTOMOC
  133. FILES_CMAKE
  134. archive_editor_shared_files.cmake
  135. INCLUDE_DIRECTORIES
  136. PRIVATE
  137. Source
  138. PUBLIC
  139. Include
  140. BUILD_DEPENDENCIES
  141. PUBLIC
  142. Gem::${gem_name}.Editor.API
  143. PRIVATE
  144. Gem::${gem_name}.Editor.Private.Object
  145. )
  146. # Inject the gem name into the Module source file
  147. ly_add_source_properties(
  148. SOURCES
  149. Source/Tools/ArchiveEditorModule.cpp
  150. PROPERTY COMPILE_DEFINITIONS
  151. VALUES
  152. O3DE_GEM_NAME=${gem_name}
  153. O3DE_GEM_VERSION=${gem_version})
  154. # By default, we will specify that the above target ${gem_name} would be used by
  155. # Tool and Builder type targets when this gem is enabled. If you don't want it
  156. # active in Tools or Builders by default, delete one of both of the following lines:
  157. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  158. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  159. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  160. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  161. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  162. ### AssetBundler additions ###
  163. # Add the Clients.API and Tools.API as a build dependency of the AssetBundler if this gem is available
  164. # as part of the current project
  165. # This allows the Asset Bundler to have access to the gems API includes which it can use
  166. # to create O3AR archive format files
  167. target_link_libraries(AssetBundlerBatch.Static PUBLIC ${gem_name}.API ${gem_name}.Editor.API)
  168. endif()
  169. ################################################################################
  170. # Tests
  171. ################################################################################
  172. # See if globally, tests are supported
  173. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  174. # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
  175. if(PAL_TRAIT_ARCHIVE_TEST_SUPPORTED)
  176. # We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
  177. ly_add_target(
  178. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  179. NAMESPACE Gem
  180. FILES_CMAKE
  181. archive_tests_files.cmake
  182. INCLUDE_DIRECTORIES
  183. PRIVATE
  184. Tests
  185. Source
  186. Include
  187. BUILD_DEPENDENCIES
  188. PRIVATE
  189. AZ::AzTest
  190. AZ::AzFramework
  191. Gem::${gem_name}.Private.Object
  192. )
  193. # Add ${gem_name}.Tests to googletest
  194. ly_add_googletest(
  195. NAME Gem::${gem_name}.Tests
  196. )
  197. endif()
  198. # If we are a host platform we want to add tools test like editor tests here
  199. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  200. # We are a host platform, see if Editor tests are supported on this platform
  201. if(PAL_TRAIT_ARCHIVE_EDITOR_TEST_SUPPORTED)
  202. # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
  203. # private ${gem_name}.Editor.Private.Object target
  204. ly_add_target(
  205. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  206. NAMESPACE Gem
  207. FILES_CMAKE
  208. archive_editor_tests_files.cmake
  209. INCLUDE_DIRECTORIES
  210. PRIVATE
  211. Tests
  212. Source
  213. Include
  214. BUILD_DEPENDENCIES
  215. PRIVATE
  216. AZ::AzTest
  217. Gem::${gem_name}.Editor.Private.Object
  218. Compression.Editor.API
  219. RUNTIME_DEPENDENCIES
  220. Compression.Editor
  221. )
  222. # Add ${gem_name}.Editor.Tests to googletest
  223. ly_add_googletest(
  224. NAME Gem::${gem_name}.Editor.Tests
  225. )
  226. endif()
  227. endif()
  228. endif()