CMakeLists.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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/ROS2RobotImporter/Code/Platform/<platorm_name> or
  13. # <restricted_folder>/<platform_name>/Gems/ROS2RobotImporter/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. # Check to see if building the Gem Modules are supported for the current platform
  20. if(NOT PAL_TRAIT_ROS2ROBOTIMPORTER_SUPPORTED)
  21. return()
  22. endif()
  23. # The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
  24. ly_add_target(
  25. NAME ${gem_name}.API INTERFACE
  26. NAMESPACE Gem
  27. FILES_CMAKE
  28. ros2robotimporter_api_files.cmake
  29. ${pal_dir}/ros2robotimporter_api_files.cmake
  30. INCLUDE_DIRECTORIES
  31. INTERFACE
  32. Include
  33. BUILD_DEPENDENCIES
  34. INTERFACE
  35. AZ::AzCore
  36. )
  37. # The ${gem_name}.Private.Object target is an internal target
  38. # It should not be used outside of this Gems CMakeLists.txt
  39. ly_add_target(
  40. NAME ${gem_name}.Private.Object STATIC
  41. NAMESPACE Gem
  42. FILES_CMAKE
  43. ros2robotimporter_private_files.cmake
  44. ${pal_dir}/ros2robotimporter_private_files.cmake
  45. TARGET_PROPERTIES
  46. O3DE_PRIVATE_TARGET TRUE
  47. INCLUDE_DIRECTORIES
  48. PRIVATE
  49. Include
  50. Source
  51. BUILD_DEPENDENCIES
  52. PUBLIC
  53. AZ::AzCore
  54. AZ::AzFramework
  55. Gem::ROS2.Static
  56. )
  57. # Here add ${gem_name} 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. ros2robotimporter_shared_files.cmake
  63. ${pal_dir}/ros2robotimporter_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. # Include the gem name into the Client Module source file
  76. # for use with the AZ_DECLARE_MODULE_CLASS macro
  77. # This is to allow renaming of the gem to also cause
  78. # the CreateModuleClass_Gem_<gem-name> function which
  79. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  80. ly_add_source_properties(
  81. SOURCES
  82. Source/Clients/ROS2RobotImporterModule.cpp
  83. PROPERTY COMPILE_DEFINITIONS
  84. VALUES
  85. O3DE_GEM_NAME=${gem_name}
  86. O3DE_GEM_VERSION=${gem_version})
  87. # By default, we will specify that the above target ${gem_name} would be used by
  88. # Client and Server type targets when this gem is enabled. If you don't want it
  89. # active in Clients or Servers by default, delete one of both of the following lines:
  90. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  91. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  92. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  93. # For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
  94. ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  95. ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  96. ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  97. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  98. # for the Clients, Servers, Unified gem variants
  99. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
  100. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
  101. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  102. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  103. ly_add_target(
  104. NAME ${gem_name}.Editor.API INTERFACE
  105. NAMESPACE Gem
  106. FILES_CMAKE
  107. ros2robotimporter_editor_api_files.cmake
  108. ${pal_dir}/ros2robotimporter_editor_api_files.cmake
  109. INCLUDE_DIRECTORIES
  110. INTERFACE
  111. Include
  112. BUILD_DEPENDENCIES
  113. INTERFACE
  114. AZ::AzToolsFramework
  115. )
  116. # The ${gem_name}.Editor.Private.Object target is an internal target
  117. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  118. # Other gems should not use this target
  119. ly_add_target(
  120. NAME ${gem_name}.Editor.Private.Object STATIC
  121. NAMESPACE Gem
  122. AUTOMOC
  123. AUTORCC
  124. FILES_CMAKE
  125. ros2robotimporter_editor_private_files.cmake
  126. TARGET_PROPERTIES
  127. O3DE_PRIVATE_TARGET TRUE
  128. INCLUDE_DIRECTORIES
  129. PRIVATE
  130. Include
  131. Source
  132. BUILD_DEPENDENCIES
  133. PUBLIC
  134. AZ::AzToolsFramework
  135. Gem::CommonFeaturesAtom.Editor.Static
  136. Gem::PhysX5.Editor.Static
  137. Gem::ROS2.Editor.Static
  138. ${gem_name}.Private.Object
  139. PRIVATE
  140. AZ::AssetBuilderSDK
  141. 3rdParty::sdformat
  142. )
  143. ly_add_target(
  144. NAME ${gem_name}.Editor GEM_MODULE
  145. NAMESPACE Gem
  146. AUTOMOC
  147. FILES_CMAKE
  148. ros2robotimporter_editor_shared_files.cmake
  149. INCLUDE_DIRECTORIES
  150. PRIVATE
  151. Source
  152. PUBLIC
  153. Include
  154. BUILD_DEPENDENCIES
  155. PUBLIC
  156. Gem::${gem_name}.Editor.API
  157. PRIVATE
  158. Gem::${gem_name}.Editor.Private.Object
  159. )
  160. # Include the gem name into the Editor Module source file
  161. # for use with the AZ_DECLARE_MODULE_CLASS macro
  162. # This is to allow renaming of the gem to also cause
  163. # the CreateModuleClass_Gem_<gem-name> function which
  164. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  165. ly_add_source_properties(
  166. SOURCES
  167. Source/Tools/ROS2RobotImporterEditorModule.cpp
  168. PROPERTY COMPILE_DEFINITIONS
  169. VALUES
  170. O3DE_GEM_NAME=${gem_name}
  171. O3DE_GEM_VERSION=${gem_version})
  172. # By default, we will specify that the above target ${gem_name} would be used by
  173. # Tool and Builder type targets when this gem is enabled. If you don't want it
  174. # active in Tools or Builders by default, delete one of both of the following lines:
  175. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  176. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  177. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  178. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  179. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  180. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  181. # for the Tools and Builders gem variants
  182. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
  183. endif()
  184. ################################################################################
  185. # Tests
  186. ################################################################################
  187. # See if globally, tests are supported
  188. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  189. # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
  190. if(PAL_TRAIT_ROS2ROBOTIMPORTER_TEST_SUPPORTED)
  191. # We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
  192. ly_add_target(
  193. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  194. NAMESPACE Gem
  195. FILES_CMAKE
  196. ros2robotimporter_tests_files.cmake
  197. INCLUDE_DIRECTORIES
  198. PRIVATE
  199. Tests
  200. Source
  201. Include
  202. BUILD_DEPENDENCIES
  203. PRIVATE
  204. AZ::AzTest
  205. AZ::AzFramework
  206. Gem::${gem_name}.Private.Object
  207. )
  208. # Add ${gem_name}.Tests to googletest
  209. ly_add_googletest(
  210. NAME Gem::${gem_name}.Tests
  211. )
  212. endif()
  213. # If we are a host platform we want to add tools test like editor tests here
  214. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  215. # We are a host platform, see if Editor tests are supported on this platform
  216. if(PAL_TRAIT_ROS2ROBOTIMPORTER_EDITOR_TEST_SUPPORTED)
  217. # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
  218. # private ${gem_name}.Editor.Private.Object target
  219. ly_add_target(
  220. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  221. NAMESPACE Gem
  222. FILES_CMAKE
  223. ros2robotimporter_editor_tests_files.cmake
  224. INCLUDE_DIRECTORIES
  225. PRIVATE
  226. Tests
  227. Source
  228. Include
  229. BUILD_DEPENDENCIES
  230. PRIVATE
  231. AZ::AzTest
  232. AZ::AzTestShared
  233. AZ::AzToolsFramework
  234. Gem::${gem_name}.Editor.Private.Object
  235. 3rdParty::sdformat
  236. )
  237. # Add ${gem_name}.Editor.Tests to googletest
  238. ly_add_googletest(
  239. NAME Gem::${gem_name}.Editor.Tests
  240. )
  241. endif()
  242. endif()
  243. endif()