CMakeLists.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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/SimulationInterfaces/Code/Platform/<platorm_name> or
  11. # <restricted_folder>/<platform_name>/Gems/SimulationInterfaces/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_SIMULATIONINTERFACES_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. simulationinterfaces_api_files.cmake
  27. ${pal_dir}/simulationinterfaces_api_files.cmake
  28. INCLUDE_DIRECTORIES
  29. INTERFACE
  30. Include
  31. BUILD_DEPENDENCIES
  32. INTERFACE
  33. AZ::AzCore
  34. )
  35. # The ${gem_name}.Private.Object target is an internal target
  36. # It should not be used outside of this Gems CMakeLists.txt
  37. ly_add_target(
  38. NAME ${gem_name}.Private.Object STATIC
  39. NAMESPACE Gem
  40. FILES_CMAKE
  41. simulationinterfaces_private_files.cmake
  42. ${pal_dir}/simulationinterfaces_private_files.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. )
  54. # Here add ${gem_name} target, it depends on the Private Object library and Public API interface
  55. ly_add_target(
  56. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  57. NAMESPACE Gem
  58. FILES_CMAKE
  59. simulationinterfaces_shared_files.cmake
  60. ${pal_dir}/simulationinterfaces_shared_files.cmake
  61. INCLUDE_DIRECTORIES
  62. PUBLIC
  63. Include
  64. PRIVATE
  65. Source
  66. BUILD_DEPENDENCIES
  67. PUBLIC
  68. Gem::${gem_name}.API
  69. PRIVATE
  70. Gem::${gem_name}.Private.Object
  71. )
  72. # Include the gem name into the Client Module source file
  73. # for use with the AZ_DECLARE_MODULE_CLASS macro
  74. # This is to allow renaming of the gem to also cause
  75. # the CreateModuleClass_Gem_<gem-name> function which
  76. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  77. ly_add_source_properties(
  78. SOURCES
  79. Source/Clients/SimulationInterfacesModule.cpp
  80. PROPERTY COMPILE_DEFINITIONS
  81. VALUES
  82. O3DE_GEM_NAME=${gem_name}
  83. O3DE_GEM_VERSION=${gem_version})
  84. # By default, we will specify that the above target ${gem_name} would be used by
  85. # Client and Server type targets when this gem is enabled. If you don't want it
  86. # active in Clients or Servers by default, delete one of both of the following lines:
  87. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  88. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  89. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  90. # For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
  91. ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  92. ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  93. ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  94. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  95. # for the Clients, Servers, Unified gem variants
  96. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
  97. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
  98. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  99. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  100. ly_add_target(
  101. NAME ${gem_name}.Editor.API INTERFACE
  102. NAMESPACE Gem
  103. FILES_CMAKE
  104. simulationinterfaces_editor_api_files.cmake
  105. ${pal_dir}/simulationinterfaces_editor_api_files.cmake
  106. INCLUDE_DIRECTORIES
  107. INTERFACE
  108. Include
  109. BUILD_DEPENDENCIES
  110. INTERFACE
  111. AZ::AzToolsFramework
  112. )
  113. # The ${gem_name}.Editor.Private.Object target is an internal target
  114. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  115. # Other gems should not use this target
  116. ly_add_target(
  117. NAME ${gem_name}.Editor.Private.Object STATIC
  118. NAMESPACE Gem
  119. FILES_CMAKE
  120. simulationinterfaces_editor_private_files.cmake
  121. TARGET_PROPERTIES
  122. O3DE_PRIVATE_TARGET TRUE
  123. INCLUDE_DIRECTORIES
  124. PRIVATE
  125. Include
  126. Source
  127. BUILD_DEPENDENCIES
  128. PUBLIC
  129. AZ::AzToolsFramework
  130. ${gem_name}.Private.Object
  131. )
  132. ly_add_target(
  133. NAME ${gem_name}.Editor GEM_MODULE
  134. NAMESPACE Gem
  135. AUTOMOC
  136. FILES_CMAKE
  137. simulationinterfaces_editor_shared_files.cmake
  138. INCLUDE_DIRECTORIES
  139. PRIVATE
  140. Source
  141. PUBLIC
  142. Include
  143. BUILD_DEPENDENCIES
  144. PUBLIC
  145. Gem::${gem_name}.Editor.API
  146. PRIVATE
  147. Gem::${gem_name}.Editor.Private.Object
  148. )
  149. # Include the gem name into the Editor Module source file
  150. # for use with the AZ_DECLARE_MODULE_CLASS macro
  151. # This is to allow renaming of the gem to also cause
  152. # the CreateModuleClass_Gem_<gem-name> function which
  153. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  154. ly_add_source_properties(
  155. SOURCES
  156. Source/Tools/SimulationInterfacesEditorModule.cpp
  157. PROPERTY COMPILE_DEFINITIONS
  158. VALUES
  159. O3DE_GEM_NAME=${gem_name}
  160. O3DE_GEM_VERSION=${gem_version})
  161. # By default, we will specify that the above target ${gem_name} would be used by
  162. # Tool and Builder type targets when this gem is enabled. If you don't want it
  163. # active in Tools or Builders by default, delete one of both of the following lines:
  164. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  165. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  166. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  167. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  168. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  169. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  170. # for the Tools and Builders gem variants
  171. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
  172. endif()
  173. ################################################################################
  174. # Tests
  175. ################################################################################
  176. # See if globally, tests are supported
  177. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  178. # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
  179. if(PAL_TRAIT_SIMULATIONINTERFACES_TEST_SUPPORTED)
  180. # We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
  181. ly_add_target(
  182. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  183. NAMESPACE Gem
  184. FILES_CMAKE
  185. simulationinterfaces_tests_files.cmake
  186. INCLUDE_DIRECTORIES
  187. PRIVATE
  188. Tests
  189. Source
  190. Include
  191. BUILD_DEPENDENCIES
  192. PRIVATE
  193. AZ::AzTest
  194. AZ::AzFramework
  195. Gem::${gem_name}.Private.Object
  196. )
  197. # Add ${gem_name}.Tests to googletest
  198. ly_add_googletest(
  199. NAME Gem::${gem_name}.Tests
  200. )
  201. endif()
  202. # If we are a host platform we want to add tools test like editor tests here
  203. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  204. # We are a host platform, see if Editor tests are supported on this platform
  205. if(PAL_TRAIT_SIMULATIONINTERFACES_EDITOR_TEST_SUPPORTED)
  206. # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
  207. # private ${gem_name}.Editor.Private.Object target
  208. ly_add_target(
  209. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  210. NAMESPACE Gem
  211. FILES_CMAKE
  212. simulationinterfaces_editor_tests_files.cmake
  213. INCLUDE_DIRECTORIES
  214. PRIVATE
  215. Tests
  216. Source
  217. Include
  218. BUILD_DEPENDENCIES
  219. PRIVATE
  220. AZ::AzTest
  221. AZ::AzTestShared
  222. AZ::AzToolsFramework
  223. Legacy::CryCommon
  224. Legacy::EditorCommon
  225. Legacy::Editor.Headers
  226. AZ::AzManipulatorTestFramework.Static
  227. Gem::${gem_name}.API
  228. Gem::${gem_name}.Editor.Private.Object
  229. )
  230. # Add ${gem_name}.Editor.Tests to googletest
  231. ly_add_googletest(
  232. NAME Gem::${gem_name}.Editor.Tests
  233. )
  234. ly_add_target(
  235. NAME ${gem_name}.TestApp ${PAL_TRAIT_TEST_TARGET_TYPE}
  236. NAMESPACE Gem
  237. FILES_CMAKE
  238. simulationinterfaces_editor_app_test.cmake
  239. INCLUDE_DIRECTORIES
  240. PRIVATE
  241. Tests
  242. Source
  243. Include
  244. BUILD_DEPENDENCIES
  245. PRIVATE
  246. AZ::AzTest
  247. AZ::AzTestShared
  248. AZ::AzToolsFramework
  249. Legacy::CryCommon
  250. Legacy::EditorCommon
  251. Legacy::Editor.Headers
  252. AZ::AzManipulatorTestFramework.Static
  253. Gem::${gem_name}.API
  254. Gem::${gem_name}.Editor.Private.Object
  255. )
  256. # Add ${gem_name}.Editor.Tests to googletest
  257. ly_add_googletest(
  258. NAME Gem::${gem_name}.TestApp
  259. )
  260. endif()
  261. endif()
  262. endif()